Plugin System API
Overview
CompilerOptions.plugins supports 4 types of extension points:
parser: Parsing phase.transformer: Transformation phase.codegen: Code generation phase.- Post-compilation plugins: Keys under
pluginsexcluding the first three types, executed after compilation is completed.
Basic Types
ts
interface PluginRegister<T> {
[name: string]: (result: T, ctx: ICompilationContext) => void;
}Configuration Example
ts
import { defineConfig } from '@vureact/compiler-core';
export default defineConfig({
plugins: {
parser: {
collectParseMeta(result, ctx) {
// ParseResult extension
},
},
transformer: {
inspectIR(result, ctx) {
// ReactIRDescriptor extension
},
},
codegen: {
patchOutput(result, ctx) {
// GeneratorResult extension
},
},
afterCompile(result, ctx) {
// Post-processing of CompilationResult
},
},
});Execution Order
- parser
- transformer
- codegen
- Post-compilation plugins
Constraints
- Plugins follow a synchronous execution model.
- Plugin exceptions are caught and printed, and will not directly interrupt the entire compilation process.
- Plugins should avoid relying on undocumented internal details and should only depend on public structures as much as possible.
