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.

3.4.2 "sideEffects: false" option causes site to render improperly

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.4.2

Environment

webpack 4.6.0

Reproduction link

Edit on CodeSandbox

Steps to reproduce

With 3.4.2 I notice antd components CSS doesn’t load on my production site. If I edit node_modules/antd/package.json and remove the line “sideEffects: false” it goes back to normal.

My build makes use of babel-plugin-import, MiniCssExtractPlugin, less-loader to build the css

The development site with hot-reloading works fine, but when i build the production site it looks like no antd css loads at all

excerpt from webpack.prod.js

{
        test: /\.(css|less)$/,
        use: [
          MiniCssExtractPlugin.loader,
          'css-loader',
          {
            loader: 'less-loader',
            options: {
              modifyVars: antdTheme,
              javascriptEnabled: true,
            },
          },
        ],
      },

with 3.4.1 a “yarn build” will produce a vendors.js and vendors.css, but with 3.4.2 the vendors.css does not get generated at all

What is expected?

The production build worked in 3.4.1 and also works if i remove “sideEffects: false” from node_modules/antd/package.json

What is actually happening?

unknown


Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
plhoskcommented, Apr 23, 2018

If I modify "sideEffects": false and instead set it to

  "sideEffects": [
    "es/**/style/*"
  ]

the problem goes away.

It might have to do with this from the Tree Shaking page on webpack.js.org:

“Note that any imported file is subject to tree shaking. This means if you use something like css-loader in your project and import a CSS file, it needs to be added to the side effect list so it will not be unintentionally dropped in production mode”

1reaction
tim-softcommented, Apr 23, 2018

I see, so if you are using babel-import-plugin you’ll need to use this config { libraryName: 'antd', "libraryDirectory": "es", style: true }.

The default option of lib doesn’t work after this change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Does Webpack 4 Expect From A Package With sideEffects
The "sideEffects": false flag in big-module's package.json indicates that the package's modules have no side effects (on evaluation) and only ...
Read more >
INTRODUCTION - Maine.gov
2.31 “Medication Error” means the administration of any medication incorrectly, e.g., dosage, selection of drug, selection of consumer, time or method of ...
Read more >
unittest — Unit testing framework — Python 3.11.1 ...
The class setting can be overridden in individual test methods by assigning an instance attribute, self.longMessage, to True or False before calling the...
Read more >
Changelog — pytest documentation
issue #7807: Fixed regression in pytest 6.1.0 causing incorrect rootdir to be determined in some non-trivial cases where parent directories have config ...
Read more >
Bison 3.8.1 - GNU.org
A GLR parser splitting inadvertently may cause problems less obvious than an LR parser statically choosing the wrong alternative in a conflict.
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