0.0.14 • Published 9 months ago

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

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

9 months ago

0.0.13

9 months ago

0.0.12

10 months ago

0.0.11

10 months ago

0.0.10

10 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago