-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
local-css minified class names issue #3295
Comments
Here's a reproduction of this case in esbuild playground: |
I just came here to report this same issue! In my case, I have a component library compiled with esbuild and a then an app compiled with esbuild and many of the class names are clashing. Other bundlers minify the class names and then append a hash of the file contents to namespace them so class |
@nicksrandall for a component library I have imagined esbuild could check for a special field in package.json to get more resources for "reservedClassNames" like esbuild does for "sideEffect". A "reservedClassNames" field can be an array of string of reserved class names, or a string which would be path to a file. Library author could emit into this "reservedClassNames" field reserved class names produced by esbuild like I mentioned in my suggestions (2) I still think a,b,c,d etc. is a great minification technic to reduce bundle size but without fixing this name collision issue local-css will have a limited usage |
First of all thank you for adding support for "CSS Modules".
The algorithm behind class names minification is great but is not side effect free.
a,b,c,d etc. is excellent to reduce bundle size but they are too short and unexpected result may happen if we import multiple esbuild bundled (local-)css files inside the same page.
Please consider a context where we have 3 entry points, "header.js", "main.js" and "footer.js" where all 3 uses "CSS modules" and we need to bundle and import them inside a page.html separately as in the example attached below.
The result is that theses 3 class names minified names are all the same (for me it was "e") and unfortunately my index.html don't look like what I excepted.
However I have 4 solutions/suggestions
a combination of the 1 and the 2 solutions will be ideal for me
esbuild-local-css.zip
The text was updated successfully, but these errors were encountered: