Builder Types

This section describes some of the type definitions provided by the Builder.


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>;


The type of the context property in the Builder instance.

import type { BuilderContext } from '@modern-js/builder';

const context: BuilderContext = builder.context;


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() {},


The type of build target.

import type { BuilderTarget } from '@modern-js/builder';


The type of the entry option to the createBuilder method.

import type { BuilderEntry } from '@modern-js/builder';


The param type of createBuilder method.

import type { CreateBuilderOptions } from '@modern-js/builder';