Open goldylucks opened 2 years ago
Also tried adding this file with no effect:
// .postcssrc.js
module.exports = {
modules: true,
plugins: {
"postcss-modules": {
generateScopedName: "[folder]__[local]___[hash:base64:6]",
},
},
}
do you have a reproduction we can try?
sure, here it is: https://github.com/goldylucks/browser-extension-template
thanks for the help and getting back to me so promptly!
Appears to be generating two bundles named content.css
. This is because there is a content.css
file referenced from manifest.json
(marked as needsStableName
, not sure if required), and the sibling CSS file for content.js
also gets named content.css
. I guess the namer needs to be a bit smarter about it.
Note: this is not specific to CSS modules, it could happen with any CSS file. As a workaround, you could either rename content.js
or content.css
to something else for now.
but if I rename the file the collision will just happen for the new name no?
or am I missing smthn here?
Parcel generates {name}.css from {name}.js file which imports CSS files. In this case, parcel generates content.css from content.js and this will lead a collision fo filename. so to rename content.js to {other than content}.js or content.css to {other than content}.css can be workaround.
CSS Modules aren't currently supported in the web extension config. Although #7050 will fix this specific issue, it's still probably a good idea to work around name collisions in the default namer even if needsStableName
is present on multiple assets with the same name.
I am seeing the same bug with SVG files when I use parcel-namer-custom plugin. The plugin logs that the name()
is being repeatedly being called on the same SVG file (I suspect this is because multiple references are being generated by prior SVG plugins). In any case, this prevents renaming the file unless one uses a hash in the renamed file.
Edit: I can confirm this is caused by SVG transformer plugin on larger SVG files. Turning it off will remove multiple invocation in the namer plugin.
As the reason of #7230, I tried to remove import 'index.css';
manually, so I disabled the Source Map in package.json
to avoid incorrect Debugging Break-point:
{
"devDependencies": {
"@parcel/packager-ts": "~2.7.0",
"@parcel/transformer-less": "~2.7.0",
"@parcel/transformer-typescript-types": "~2.7.0",
"parcel": "~2.7.0",
"typescript": "~4.7.4"
},
"browserslist": "> 0.5%, last 2 versions, not dead",
"targets": {
+ "default": {
+ "sourceMap": false
+ },
"main": {
"optimize": true
}
},
"scripts": {
"build": "parcel build"
}
}
But I got the same error:
AssertionError [ERR_ASSERTION]: Bundles must have unique names
If I replace the JSON option with the CLI parameter --no-source-maps
, the building succeed with a warning:
> 4 | import * as style from './index.module.less';
> | ^^^^^^^^^^^^^^^^^^^^^^ Cannot find module './index.module.less' or its corresponding type declarations.
Guys of @parcel-bundler team, you can find the reproduce code in idea2app/Idea-React#20.
π bug report
results in
π Configuration (.babelrc, package.json, cli command)
π€ Expected Behavior
should work
π― Current Behavior
throws the error
π Possible Solution
no idea π€·ββοΈ
π¦ Context
trying to use css modules (alongside global css and npm css files, tho those work fine)
π» Code Sample
π Your Environment