Skip to content
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

experiments.css cannot be disabled when experiments.futureDefaults is enabled #15742

Closed
jdanil opened this issue May 1, 2022 · 2 comments · Fixed by #15746
Closed

experiments.css cannot be disabled when experiments.futureDefaults is enabled #15742

jdanil opened this issue May 1, 2022 · 2 comments · Fixed by #15746

Comments

@jdanil
Copy link
Contributor

jdanil commented May 1, 2022

Bug report

What is the current behavior?

When experiements.futureDefaults is enabled but experiments.css is disabled, webpack fails with the following error.

Error: Conflict: Multiple chunks emit assets to the same filename main.css

I believe this behaviour was introduced in 5.67.0 via (#15200). Specifically...

options === true ? {} : options === false ? undefined : options

When experiments.css is set to false, its value is normalised as undefined. So the experiments.futureDefaults value is used in its place here...

applyExperimentsDefaults(options.experiments, {

If the current behavior is a bug, please provide the steps to reproduce.

webpack.config.js

{
  experiments: {
    css: false,
    futureDefaults: true,
  },
}

What is the expected behavior?

webpack should build successfully with experiments.css disabled.

I would like to be able to enable experiments.futureDefaults so that I can ensure compatibility with the next major webpack version. But for some experiments, like experiments.css, I would like to be able opt-out for now until I better understand the upgrade path.

Other relevant information:
webpack version: 5.72.0
Node.js version: 16.14.2
Operating System: Ubuntu

@alexander-akait
Copy link
Member

Thanks for a report, feel free to send a fix

@sokra
Copy link
Member

sokra commented Jul 26, 2022

You can opt-out of that by changing the default module type for .css files to something else.

e. g. in your rule with test: /\.css$/i set type: "javascript/auto"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants