vercel / vercel/next.js

minifier inlines a comma-assigned helper arrow which causes (SyntaxError: Identifier 'b' has already been declared) in npm run build

Open
#97,517 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

SWC Turbopack Webpack
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/ebanek/identifier-e-already-declared-nextjs-minification/

To Reproduce
To Reproduce

In a default npx create-next-app@latest my-app --yes.

repro.js

var join, run;
join = (e, t) => e + t,
  run = (rows) => {
    rows.map((s) => join(s.g, s.r));
    return rows.map((s) => (i) => join(s.g, i.l));
  };
export { run };

app/page.tsx

import * as M from "../repro.js";

export default function Home() {
  return <pre>{Object.keys(M).join(", ")}</pre>;
}

running "npm run build" gives:

 Collecting page data using 5 workers  .Error [ChunkLoadError]: Failed to load chunk server/chunks/ssr/[root-of-the-server]__0f7v31e._.js from runtime for chunk server/app/page.js
    at Object.<anonymous> (.next/server/app/page.js:2:3) {
  [cause]: SyntaxError: Identifier 'b' has already been declared
      at <unknown> (.next/server/chunks/ssr/[root-of-the-server]__0f7v31e._.js:1)
}

> Build error occurred
Error: Failed to collect page data for /
    at ignore-listed frames {
  type: 'Error'
}

This is a minimal example that produces the error I have.
It came from importing superdoc library, which is already minified. Everything works if I set --no-mangling for the next build in package.json.

Current vs. Expected behavior

I expect that the above example displays an empty page. Here I get a syntax error when running npm run build.

Provide environment information
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:56 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 24.18.0
  npm: 11.16.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.3.1 // Latest available version is detected (16.3.1).
  eslint-config-next: N/A
  react: 19.2.8
  react-dom: 19.2.8
  typescript: 5.9.3
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

Webpack, SWC, Turbopack

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

next build (local)

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the minimal reproduction using repro.js, app/page.tsx, and npm run build, then compare it with the --no-mangling configuration. Trace the selected Webpack, SWC, or Turbopack minification path for the comma-assigned arrow helpers. Done means the reproduction builds successfully and the generated code no longer raises the duplicate-identifier SyntaxError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs, webpack
Domain
build-system, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.