Builder Types
This section describes some of the type definitions provided by the Builder.
BuilderInstance
The type of the Builder instance.
import type { BuilderInstance } from '@modern-js/builder';
let builder: BuilderInstance;
You can pass in the Provider type through generics to make the type definition of the Builder instance more accurate:
import type { createBuilder, type BuilderInstance } from '@modern-js/builder';
import type { BuilderWebpackProvider } from '@modern-js/builder-webpack-provider';
let builder: BuilderInstance<BuilderWebpackProvider>;
BuilderContext
The type of the context property in the Builder instance.
import type { BuilderContext } from '@modern-js/builder';
const context: BuilderContext = builder.context;
BuilderPlugin
The type of Builder plugin, should be used with the BuilderPluginAPI
type exported from the provider.
import type { BuilderPlugin } from '@modern-js/builder';
import type { BuilderPluginAPI } from '@modern-js/builder-webpack-provider';
const myPlugin: BuilderPlugin<BuilderPluginAPI> = {
name: 'my-plugin',
setup() {},
};
BuilderTarget
The type of build target.
import type { BuilderTarget } from '@modern-js/builder';
BuilderEntry
The type of the entry
option to the createBuilder
method.
import type { BuilderEntry } from '@modern-js/builder';
CreateBuilderOptions
The param type of createBuilder
method.
import type { CreateBuilderOptions } from '@modern-js/builder';