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

# RuntimeChunkPlugin

`RuntimeChunkPlugin` creates separate Rspack runtime chunks and controls how they are named. [`optimization.runtimeChunk`](https://rspack.rs/config/optimization.md#optimizationruntimechunk) applies this plugin internally.

## Examples

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

```js title="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)`

```js
new rspack.optimize.RuntimeChunkPlugin({
  name: ({ name }) => `runtime~${name}`,
});
```
