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:
- Created 4 years ago
- Comments:12 (7 by maintainers)
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 😃
@swashcap Same here, on a project with no duplicate source files.