Serpack
Plugin api
Plugin Guide
Plugin Guide
You can use the plugin feature to extend the compiler.
UNDER DEVELOPMENT
Plugin feature is under development.
#Usage
Typescript
export default <import('serpack').Options>{
compilerOptions: {
plugins: [yourPlugin()],
},
};
#Types
Typescript
export interface Plugin {
name?: string;
onSetup?(compilerOptions: CompilerOptions): CompilerOptions | void;
onLoad?(context: PluginContext): void;
onCompile?(
context: PluginContextOnCompile,
): CompilerOutput<{ code: string; map?: any }>;
onBundle?(): CompilerOutput<void>;
}
#Plugin Example
https://github.com/do4ng/serpack/tree/main/fixtures/plugin
#Execution Order
-
- setup compiler
-
- run
plugin.onSetup
- run
- ...
-
- load module
-
- run
plugin.onLoad
- run
-
- load & compile module // ==> output
-
- run
plugin.onCompile
// Loop
- run
- ...
-
- run
plugin.onBundle
- run