Announcing Rsbuild 0.2

December 11, 2023

The Rsbuild 0.2 contains some incompatible API changes. Please refer to the current documentation for upgrading.

Targets

We will move the target option of createRsbuild to rsbuild config, this change allows user to configure targets in the rsbuild config file.

  • before:
const rsbuild = await createRsbuild({
  target: ['web', 'node'],
});
  • after:
// rsbuild.config.ts
export default {
  output: {
    targets: ['web', 'node'],
  },
};

Only affect JavaScript API. Users using the Rsbuild CLI do not need to change.

Entry

Remove the deprecated source.entries config.

source.entries has been renamed to source.entry since Rsbuild 0.1.0, and we will remove the legacy source.entries config in Rsbuild v0.2.0.

  • before:
// rsbuild.config.ts
export default {
  source: {
    entries: {},
  },
};
  • after:
// rsbuild.config.ts
export default {
  source: {
    entry: {},
  },
};

Write to Disk

dev.writeToDisk defaults to false.

Motivation:

  • Reduce fs overhead and improve dev server performance.
  • Avoid trigger watcher of UnoCSS and other tools. See #654.
  • Align the default behavior with webpack-dev-middleware and other community dev servers.

User can enable writeToDisk manually:

export default {
  dev: {
    writeToDisk: true,
  },
};

Babel Plugin

@rsbuild/plugin-babel will move all babel-loader options to babelLoaderOptions:

  • before:
pluginBabel({
  plugins: [],
  presets: [],
});
  • after:
pluginBabel([
  babelLoaderOptions: {
    plugins: [],
    presets: [],
  }
]);

This change allows us to add more options for pluginBabel, such as include and exclude.

Source Map

output.disableSourceMap has been renamed to output.sourceMap.

  • before:
export default {
  output: {
    disableSourceMap: {
      js: true,
      css: true,
    },
  },
};
  • after:
export default {
  output: {
    sourceMap: {
      js: false,
      css: false,
    },
  },
};

The default value of source map has also been updated to improve build performance.

  • before: generate JS / CSS source map in development, generate JS source map in production.
  • after: generate JS source map in development, no source map are generated in production.

Inject Styles

Rename output.disableCssExtract to output.injectStyles to be clearer:

  • before:
export default {
  output: {
    disableCssExtract: true,
  },
};
  • after:
export default {
  output: {
    injectStyles: true,
  },
};