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.

Css in autocomplete-theme-classic removed by Webpack due to sideEffects false?

See original GitHub issue

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…

import '@algolia/autocomplete-theme-classic';

… 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 being false in package.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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
Haroenvcommented, May 19, 2021

Is this also the case if you manually import the built file? import '@algolia/autocomplete-theme-classic/dist/theme.css';

1reaction
Haroenvcommented, May 20, 2021

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: https://github.com/csstools/postcss-preset-env/issues/163#issuecomment-679057151

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tree Shaking - webpack
All the code noted above does not contain side effects, so we can mark the property as false to inform webpack that it...
Read more >
Webpack not acting on sideEffects for css files - Stack Overflow
I have a javascript module that imports a CSS file. The CSS is included in the build in webpack 'development' mode, but not...
Read more >
Tree shaking JSON files with webpack - LogRocket Blog
Webpack performs out-of-the-box tree shaking when compiling multiple JSON files into a single one. Here's how and why you should use it.
Read more >
Tree Shaking simplified with Webpack! - Opcito
Any unused code that can be proved is automatically dropped from your final bundle or tree shaken. To carry out the tree shaking...
Read more >
Building a UI Library Capable of Tree Shaking: From A to Z
All libraries included in TOAST UI are bundled using the webpack. ... shaking cannot remove all unnecessary modules due to side effects.
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