Skip to content

Turbopack generates invalid bundle when using browserslist with latest caniuse-lite #86076

@KentoMoriwaki

Description

@KentoMoriwaki

Link to the code that reproduces this issue

https://github.com/KentoMoriwaki/turbopack-caniuse-repro

To Reproduce

Clone https://github.com/KentoMoriwaki/turbopack-caniuse-repro and follow README.md

Current vs. Expected behavior

Currently it produces broken bundle. It is expected to produce correct bundle.

before

// with caniuse-lite@1.0.30001753

function comment(value, root, parent, siblings) {
    return (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$stylis$40$4$2e$3$2e$2$2f$node_modules$2f$stylis$2f$src$2f$Tokenizer$2e$js__$5b$client$5d$__$28$ecmascript$29$__["node"])(value, root, parent, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$stylis$40$4$2e$3$2e$2$2f$node_modules$2f$stylis$2f$src$2f$Enum$2e$js__$5b$client$5d$__$28$ecmascript$29$__["COMMENT"], (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$stylis$40$4$2e$3$2e$2$2f$node_modules$2f$stylis$2f$src$2f$Utility$2e$js__$5b$client$5d$__$28$ecmascript$29$__["from"])((0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$stylis$40$4$2e$3$2e$2$2f$node_modules$2f$stylis$2f$src$2f$Tokenizer$2e$js__$5b$client$5d$__$28$ecmascript$29$__["char"])()), (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$stylis$40$4$2e$3$2e$2$2f$node_modules$2f$stylis$2f$src$2f$Utility$2e$js__$5b$client$5d$__$28$ecmascript$29$__["substr"])(value, 2, -2), 0, siblings);
}

after

// with caniuse-lite@1.0.30001754

function comment(value, root, parent, siblings) {
    return (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$stylis$40$4$2e$3$2e$2$2f$node_modules$2f$stylis$2f$src$2f$Tokenizer$2e$js__$5b$client$5d$__$28$ecmascript$29$__["node"])(value, root, parent, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$stylis$40$4$2e$3$2e$2$2f$node_modules$2f$stylis$2f$src$2f$Enum$2e$js__$5b$client$5d$__$28$ecmascript$29$__["COMMENT"], (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$stylis$40$4$2e$3$2e$2$2f$node_modules$2f$stylis$2f$src$2f$Utility$2e$js__$5b$client$5d$__$28$ecmascript$29$__["from"])(char()), (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$stylis$40$4$2e$3$2e$2$2f$node_modules$2f$stylis$2f$src$2f$Utility$2e$js__$5b$client$5d$__$28$ecmascript$29$__["substr"])(value, 2, -2), 0, siblings);
}

This may be a bit noisy, but if we extract the diff, we can see that the char() function, which is defined in the stylist module, is not being resolved correctly, resulting in an undefined error for char().

- __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$stylis$40$4$2e$3$2e$2$2f$node_modules$2f$stylis$2f$src$2f$Tokenizer$2e$js__$5b$client$5d$__$28$ecmascript$29$__["char"])()
+ char()

It is unclear why this is happening, but it started occurring when the caniuse-lite version was bumped to 1.0.30001754.
Even if we try to skip the stylis where this error occurs, similar errors occur in other places, so it seems that there is some kind of bug in turbopack.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Wed Oct 15 21:12:44 PDT 2025; root:xnu-11417.140.69.703.14~1/RELEASE_ARM64_T8112
  Available memory (MB): 24576
  Available CPU cores: 8
Binaries:
  Node: 22.10.0
  npm: 10.9.0
  Yarn: N/A
  pnpm: 9.15.3
Relevant Packages:
  next: 16.0.2 // Latest available version is detected (16.0.2).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

SWC, Turbopack, Pages Router, Module Resolution

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

The above error disappears with the following changes

  • Remove browserslist field from package.json
  • Or downgrade caniuse-lite to 1.0.30001753 or earlier

I'm not sure that this is an error of turbopack or SWC. But I think something about bundling or compiling is wrong in some conditions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Module ResolutionModule resolution (CJS / ESM, module resolving).Pages RouterRelated to Pages Router.SWCRelated to minification/transpilation in Next.js.TurbopackRelated to Turbopack with Next.js.linear: turbopackConfirmed issue that is tracked by the Turbopack team.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions