0.0.14 • Published 7 months ago

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

Weekly downloads
-
License
-
Repository
-
Last release
7 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

7 months ago

0.0.13

7 months ago

0.0.12

8 months ago

0.0.11

8 months ago

0.0.10

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago