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.

Parcel 2: Bundles must have unique filePaths when using duplicate content in files

See original GitHub issue

🐛 bug report

When including two files with the same content and name but in different folders, the build fails with Bundles must have unique filePaths.

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

None, see example here: https://github.com/garthenweb/parcel2-unique-filePaths-example

🤔 Expected Behavior

In a perfect world parcel should detect that both assets are equal and could just include one in the bundle. But I can imagine that this might have side effects. I would be fine if the build would not fail. A warning would be nice as well as I was not aware that I have duplicate files in my bundle before running parcel 2.

😯 Current Behavior

Errors with

🚨 Bundles must have unique filePaths
    at BundlerRunner.nameBundles (<path>/node_modules/@parcel/core/lib/BundlerRunner.js:121:21)
    at async BundlerRunner.bundle (<path>/node_modules/@parcel/core/lib/BundlerRunner.js:92:5)
    at async Parcel.build (<path>/node_modules/@parcel/core/lib/Parcel.js:289:25)
    at async Parcel.run (<path>/node_modules/@parcel/core/lib/Parcel.js:196:18)
    at async Command.run (<path>/node_modules/parcel/lib/cli.js:132:7)

💁 Possible Solution

Including the file path into the hash generation would maybe help.

🔦 Context

I was running parcel 2 on a bigger code base and had round about 10 files of type scss, svg and js in the bundle that caused this error. I detected the files by adding the following into the BundleRunner.js file which throw the error:

console.log(bundlePaths.filter((val, index,list) => {
  return list.indexOf(val) !== index;
}))

While creating the example project I found out that css files worked perfectly fine but for scss files it was failing.

💻 Code Sample

See example here: https://github.com/garthenweb/parcel2-unique-filePaths-example

🌍 Your Environment

Software Version(s)
Parcel 2.0.0-alpha.1.1
Node v12.8.1
npm 6.10.2
Operating System Max OSX

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

56reactions
sw-yxcommented, Jun 16, 2021

leaving this for anyone running into this issue: if you have a “main” field in package.json that says “index.html” and also run parcel build index.html you get this error.

just remove the “main” field and ur good.

edit from the future: hi ali 😃

4reactions
Berkmann18commented, Apr 4, 2020

@swashcap Same here, on a project with no duplicate source files.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parcel 2 RC
Differential bundling is the idea of shipping multiple versions of your code for different targets, and allowing the browser to choose the most ......
Read more >
Trouble building webapp with parcel-bundler (Not loading ...
@parcel/namer-default: Target "main" declares an output file path of "index.js" which does not match the compiled bundle type "html". /Users/abc ...
Read more >
API - ESBuild
Passing esbuild multiple input files with bundling enabled will create ... If you really need to bundle code that does this, you will...
Read more >
Bundle your Web application with ParcelJS - codeburst
To bundle your project for production, you don't have to do any configuration or stress yourself, Parcel will automatically figure out all your...
Read more >
parcel-plugin-static-files-copy - npm
ParcelJS plugin to copy static files from static dir to bundle directory.. Latest version: 2.6.0, last published: 2 years ago. Start using ......
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