Skip to content

Docs: codeSplitting.groups should recommend strictExecutionOrder for CJS-heavy projects #8803

@chte

Description

@chte

Docs: codeSplitting.groups should recommend strictExecutionOrder for CJS-heavy projects

Not a bug — but a documentation gap

After extensive debugging (initially filed as a potential deconfliction bug), we found that codeSplitting.groups works correctly when paired with strictExecutionOrder: true. Without it, grouped chunks form circular import cycles that cause runtime errors that are extremely misleading. They look like variable collisions or deconfliction failures, not execution order issues.

Minimal config that triggers the issue

output: {
    codeSplitting: {
        groups: [
            { name: "vendor", test: /node_modules/, maxSize: 1_000_000 },
            { name: "shared", minShareCount: 2, minSize: 10_000 },
        ],
    },
},

Fix

Add strictExecutionOrder: true as a sibling output option:

output: {
    strictExecutionOrder: true,
    codeSplitting: {
        groups: [
            { name: "vendor", test: /node_modules/, maxSize: 1_000_000 },
            { name: "shared", minShareCount: 2, minSize: 10_000 },
        ],
    },
},

When it happens

  • Large dependency tree with many CJS packages (antd, @microsoft/signalr, rxjs, zod, etc.)
  • Vendor group captures enough modules that the resulting chunks form import cycles
  • Libraries using TypeScript-compiled class inheritance (__extends/extendStatics from tslib) are most visibly affected, but the issue is not specific to them

Why it's hard to diagnose

  • With minification, errors show as _ is not a function or h is not a function — looks like a variable name collision
  • With minify: false, errors show as extendStatics is not a function — looks like a deconfliction failure
  • The actual cause (circular chunk imports causing uninitialized bindings) is not visible in the error message
  • Automatic splitting (codeSplitting: true) works because it produces chunks that don't form cycles

Suggestion

The codeSplitting.groups documentation briefly mentions strictExecutionOrder but doesn't convey how critical it is for real-world projects with CJS dependencies. Consider:

  1. Defaulting strictExecutionOrder: true when codeSplitting.groups is used
  2. Or at minimum, adding a prominent warning to the groups documentation that strictExecutionOrder: true is effectively required for projects with CJS dependencies

Environment

  • Vite 8.0.1, Rolldown 1.0.0-rc.10
  • ~7000 modules, mixed CJS/ESM (antd, @microsoft/signalr, rxjs, zod, stylis, tslib, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions