For AI agents: the complete documentation index is available at https://rspack.rs/llms.txt, the full documentation bundle is available at https://rspack.rs/llms-full.txt, and this page is available as Markdown at https://rspack.rs/plugins/runtime-chunk-plugin.md.
close

RuntimeChunkPlugin

RuntimeChunkPlugin creates separate Rspack runtime chunks and controls how they are named. optimization.runtimeChunk applies this plugin internally.

Examples

This configuration extracts the Rspack runtime used by two entry points into runtime.js:

rspack.config.mjs
import { rspack } from '@rspack/core';

export default {
  entry: {
    app: './src/app.js',
    admin: './src/admin.js',
  },
  output: {
    filename: '[name].js',
  },
  plugins: [
    new rspack.optimize.RuntimeChunkPlugin({
      name: 'runtime',
    }),
  ],
};

Rspack emits app.js, admin.js, and the shared runtime.js. Separating the Rspack runtime from entry bundles allows them to be cached independently.

Options

name

Sets the name of the Rspack runtime chunk. Accepts a string or a function that receives an entrypoint object with a name property and returns a string.

  • Type: string | ((entrypoint: { name: string }) => string)
new rspack.optimize.RuntimeChunkPlugin({
  name: ({ name }) => `runtime~${name}`,
});