-
Notifications
You must be signed in to change notification settings - Fork 332
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
Css in autocomplete-theme-classic removed by Webpack due to sideEffects false? #586
Comments
Is this also the case if you manually import the built file? |
fixes #586 see the css example in https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free
@Haroenv no, but then I get a postcss error on column 16000 possibly because there are no line breaks in that file and it chokes. Manually including the contents of |
I've made a PR that adds the side effects for the css files, if you change manually in package.json, does that work? |
@Haroenv sorry, the sideEffects setting might be a red herring (even though it should probably not be set to false anyways). The trouble seems to be postcss, used by postcss-loader, who does not like the contents of the css file. It stops at exactly 16000, which makes me think it does not like the contents of the file being one large line without any spaces. I'll research if it's possible to extend the parsing buffer.
|
Does it make a difference if you break the file up into multiple lines? If you can reproduce this in a GitHub repo, it would be ideal |
@Haroenv some progress. in a fresh webpack project without any dependencies other than
will make the theme load correctly in the webpack bundle. Without the fix, it doesn't get included. The postcss issue is reproducible when this plugin is used https://github.com/csstools/postcss-preset-env Here's the github repository I've been playing with: https://github.com/joakimriedel/autocomplete-theme-bug edit: oh, and the bug with postcss seems to be related to parsing the variable edit2: ok found it. it seems as if postcss-preset-env does not like the following margin:0 calc(var(--aa-spacing)/-3); it has to be a space between the division and the minus sign like this margin:0 calc(var(--aa-spacing)/ -3); This explains why it started working when I formatted the css which added whitespace everywhere. You learn something new every day... 🤷♂️ (probably related to csstools/postcss-preset-env#184 and csstools/postcss-preset-env#163) |
That's a very confusing bug, but seems like it's more something in postcss, and not something we can help much about. In the mean time, you can likely force the version of postcss' value parser here: csstools/postcss-preset-env#163 (comment) |
fixes #586 see the css example in https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free
Hi @Haroenv, I can reproduce this bug with a blank Create-React-App. My organization is running into the same issue with Algolia CSS. Here is the git repo: https://github.com/hansod1/reproduce-css-bug
|
This worked for me! |
For me, it still is. Which is pretty strange. |
can you create a reproduction please @alexomon018 |
Description
I'm experimenting with the Autocomplete in a project that uses Webpack 5 as bundling tool. When following the getting started guide, and importing the default theme like this...
... it seems as if the contained css won't be included in the final bundle.
Researching a bit shows that this could possibly be due to the
sideEffects
setting beingfalse
inpackage.json
of https://github.com/algolia/autocomplete/blob/next/packages/autocomplete-theme-classic/package.json ?See https://webpack.js.org/guides/tree-shaking/#clarifying-tree-shaking-and-sideeffects
The text was updated successfully, but these errors were encountered: