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

    1. setup compiler
    1. run plugin.onSetup
  • ...
    1. load module
    1. run plugin.onLoad
    1. load & compile module // ==> output
    1. run plugin.onCompile // Loop
  • ...
    1. run plugin.onBundle