0.0.14 • Published 6 months ago

@build-script/heft-codegen-plugin v0.0.14

Weekly downloads
-
License
-
Repository
-
Last release
6 months ago

codegen task - 代码生成器

根据tsconfig搜索项目,找到所有以XXX.generator.ts结尾的文件,调用其中的generate函数,将结果写入XXX.generated.ts

// XXX.generator.ts
import type { FileBuilder, IOutputShim } from '@build-script/heft-codegen-plugin';

export async function generate(builder: FileBuilder, logger: IOutputShim) {
	return 'some-string';
	// or don't return to use builder content
}

/** optional */
export async function dispose(logger: IOutputShim) {
	// do something
}

也可以这样写

// XXX.generator.ts
import type { FileBuilder, IOutputShim } from '@build-script/heft-codegen-plugin';

class Generator {
	async generate(builder: FileBuilder, logger: IOutputShim) {}
	async dispose(logger: IOutputShim) {}
}

export default new Generator();

建议:

  • 在tsconfig中添加exclude: **/*.generator.ts
  • .gitignore添加: *.generated.ts
0.0.14

6 months ago

0.0.13

6 months ago

0.0.12

6 months ago

0.0.11

6 months ago

0.0.10

6 months ago

0.0.9

6 months ago

0.0.8

6 months ago

0.0.7

6 months ago

0.0.6

6 months ago

0.0.5

6 months ago

0.0.4

6 months ago

0.0.3

7 months ago

0.0.2

7 months ago