Skip to content

codeSplitting ​

  • Type: boolean | object with the properties below
  • Optional

Controls how code splitting is performed.

  • true: Default behavior, automatic code splitting. (default)
  • false: Inline all dynamic imports into a single bundle (equivalent to deprecated inlineDynamicImports: true).
  • object: Advanced manual code splitting configuration.

For deeper understanding, please refer to the in-depth documentation.

WARNING

Be aware that manual code splitting can change the behavior of the application if side effects are triggered before the corresponding modules are actually used. You can change the chunking configuration to keep order-sensitive modules together, or you can use the output.strictExecutionOrder option to preserve source execution order. The option wraps modules so their bodies run in source order, at a bundle-size cost; experimental.onDemandWrapping replaces wrap-all with a conservative plan derived from predicted chunk execution hazards.

Example ​

Basic vendor chunk

js
export default defineConfig({
  output: {
    codeSplitting: {
      minSize: 20000,
      groups: [
        {
          name: 'vendor',
          test: /node_modules/,
        },
      ],
    },
  },
});

Multiple chunk groups with priorities

js
export default defineConfig({
  output: {
    codeSplitting: {
      groups: [
        {
          name: 'react-vendor',
          test: /node_modules[\\/]react/,
          priority: 20,
        },
        {
          name: 'ui-vendor',
          test: /node_modules[\\/]antd/,
          priority: 15,
        },
        {
          name: 'vendor',
          test: /node_modules/,
          priority: 10,
        },
        {
          name: 'common',
          minShareCount: 2,
          minSize: 10000,
          priority: 5,
        },
      ],
    },
  },
});

Size-based splitting

js
export default defineConfig({
  output: {
    codeSplitting: {
      groups: [
        {
          name: 'large-libs',
          test: /node_modules/,
          minSize: 100000, // 100KB
          maxSize: 250000, // 250KB
          priority: 10,
        },
      ],
    },
  },
});

Default ​

ts
true

experimentalInlineCommonChunks? ​

Inline small automatic common chunks into their consumers to reduce the chunk count. This duplicates code and adds runtime overhead.

Set maxSize above 0 to enable it. Requires output.format: 'es' and an explicit preserveEntrySignatures: false. Requires strictExecutionOrder, which is enabled automatically when omitted. Incompatible with output.preserveModules.

Plugins must support modules appearing in multiple output chunks. See the Inline Common Chunks guide for behavior, tradeoffs and plugin compatibility.

Example ​

js
import { defineConfig } from 'rolldown';

export default defineConfig({
  preserveEntrySignatures: false,
  output: {
    format: 'es',
    codeSplitting: {
      experimentalInlineCommonChunks: {
        maxSize: 10 * 1024, // Example threshold in bytes.
      },
    },
  },
});

This feature is experimental. Its behavior and option shape may change in any release.

groups? ​

Groups to be used for code splitting.

includeDependenciesRecursively? ​

  • Type: boolean
  • Optional

Global fallback of group.includeDependenciesRecursively, if it's not specified in the group.

maxModuleSize? ​

  • Type: number
  • Optional

Global fallback of group.maxModuleSize, if it's not specified in the group.

maxSize? ​

  • Type: number
  • Optional

Global fallback of group.maxSize, if it's not specified in the group.

minModuleSize? ​

  • Type: number
  • Optional

Global fallback of group.minModuleSize, if it's not specified in the group.

minShareCount? ​

  • Type: number
  • Optional

Global fallback of group.minShareCount, if it's not specified in the group.

minSize? ​

  • Type: number
  • Optional

Global fallback of group.minSize, if it's not specified in the group.

Was this page helpful?