question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Bundles must have unique names

See original GitHub issue

🐛 bug report

During the migration from v1 to v2, Parcel seems to be unhappy with my bundles and I’m not sure why (nor sure how to fix them).

🎛 Configuration (.babelrc, package.json, cli command)

Not using a .babelrc file but heres’ the code:

v1

  parcel build \
    --public-url "." \
    --out-dir dist \
    $([[ $MINIFY ]] || echo --no-minify) \
    src/browser/register.ts \
    src/browser/serviceWorker.ts \
    src/browser/pages/login.ts \
    src/browser/pages/vscode.ts

v2

  parcel build \
    --public-url "." \
    --dist-dir dist \
    $([[ $MINIFY ]] || echo --no-optimize) \
    src/browser/register.ts \
    src/browser/serviceWorker.ts \
    src/browser/pages/login.ts \
    src/browser/pages/vscode.t

🤔 Expected Behavior

Parcel 2 should bundle the files like Parcel 1 did (assuming the correct changes have been made).

😯 Current Behavior

Parcel is spitting out an error.

🚨 Build failed.
Error: Bundles must have unique names
AssertionError [ERR_ASSERTION]: Bundles must have unique names
    at BundlerRunner.nameBundles (/Users/jp/Dev/code-server/node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:482:23)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async BundlerRunner.bundle (/Users/jp/Dev/code-server/node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:434:5)
    at async RequestTracker.runRequest (/Users/jp/Dev/code-server/node_modules/@parcel/core/lib/RequestTracker.js:694:20)
    at async Parcel._build (/Users/jp/Dev/code-server/node_modules/@parcel/core/lib/Parcel.js:661:25)
    at async Parcel.run (/Users/jp/Dev/code-server/node_modules/@parcel/core/lib/Parcel.js:510:18)
    at async run (/Users/jp/Dev/code-server/node_modules/parcel/lib/cli.js:367:7)

💁 Possible Solution

We thought it was because we had this line inside register.ts

import "./pages/error.css"
import "./pages/global.css"
import "./pages/login.css"

Sadly removing that did not solve the issue.

🔦 Context

We’re trying to migrate from v1 to v2 because there are vulnerabilities in v1 and fixing them causing v1 to break so we’re in a pickle 😅

💻 Code Sample

We use Parcel to bundle files for code-server (see here).

🌍 Your Environment

Software Version(s)
Parcel ^2.0.0-beta.3.1
Node v14.17.0
npm/Yarn 1.22.10
Operating System macOS Big Sur 11.3

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
mischniccommented, Jun 10, 2021

In case of your reproduction, the problem was this

diff --git package.json package.json
index 7978540..ac50166 100644
--- package.json
+++ package.json
@@ -1,7 +1,6 @@
 {
   "name": "parcel-v2-build-error",
   "version": "1.0.0",
-  "main": "index.js",
   "license": "MIT",
   "scripts": {
     "build": "./build.sh"

The “main” field should only be set if you’re building a library. And in this case all of the entry points passed to Parcel were assigned index.js as output.

Not sure if that is also causing your original problem though

3reactions
mischniccommented, Jun 10, 2021

The reason I tried to reproduce it is that the error message doesn’t really say which bundles are involved. So in that sense, a small repo would be great.

What you could also do is adding a console.log just before the failing assertion: https://github.com/parcel-bundler/parcel/blob/1ba0bd1833d785c1acf6af36e0a1d429f1ce1fb6/packages/core/core/src/requests/BundleGraphRequest.js#L336 and retrieve the bundle names that way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bundles must have unique names has no context, like many ...
Error: Bundles must have unique names AssertionError [ERR_ASSERTION]: Bundles must have unique names at BundlerRunner.nameBundles .
Read more >
ParcelJs: bundle an html file that contains an anchor tag and ...
html> it says: Error: Bundles must have unique names. Yes, any links in your index.html mentioning another "index.html" will yield this "unique ...
Read more >
Namer - Parcel
Overriding names for specific bundles. #. A common use case for a Namer plugin is to override Parcel's default naming scheme for specific...
Read more >
Failed to register bundle identifi… | Apple Developer Forums
I tried to manually add the Bundle ID on the developer portal and I get this error: An App ID with Identifier ''...
Read more >
Fregante on Twitter: "@devongovett Good to see more ...
Bug fixes are of course in addition to all of this, kinda goes unsaid. ... `Bundles must have unique names` has no context,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found