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

The transitive only side effects may cause the effect of option optimization.chunkIds: "deterministic" not to be as expected #676

Closed
l5oo00 opened this issue Jan 11, 2021 · 2 comments · Fixed by webpack/webpack#12396

Comments

@l5oo00
Copy link

l5oo00 commented Jan 11, 2021

  • Operating System: Mac & LInux
  • Node Version: v13.14.0 & v12.16.1
  • NPM Version: v6.14.4 & v6.13.4
  • webpack Version: v5.11.1
  • mini-css-extract-plugin Version: v0.12.0 and above

Expected Behavior

See the final example, npm run build:disable-feature is the expected behavior:

$ npm run build:disable-feature

Right:
    Expect chunkIds: 179 362
    Received chunkIds: 179 362

Actual Behavior

See the final example, npm run build is the actual behavior:

$ npm run build

Wrong:
    Expect chunkIds: 179 362
    Received chunkIds: 179 924

Code

This bug may caused by this feature: #599 .

How Do We Reproduce?

Here is an example repository: https://github.com/l5oo00/demo-for-mini-css-extract-plugin

@l5oo00
Copy link
Author

l5oo00 commented Jan 11, 2021

I'm not sure if this bug belongs mini-css-extract-plugin or webpack.

The suspicious code I found in webpack:

@sokra
Copy link
Member

sokra commented Jan 11, 2021

Ok there are two problems here:

  1. identifier() should be:
  identifier() {
-   return `css ${this._identifier} ${this._identifierIndex}`;
+   return `css|${this._identifier}|${this._identifierIndex}`;
  }

So that absolute paths can be replaced.

That can be fixed in mini-css-plugin.

  1. chunk names and ids are determined from the chunk root modules. The root modules are a set of modules from which all modules of the chunk are reachable. But when some modules in the middle are dropped due to no side effects (like the js part of the css module) the reachability is not correctly determined and the css part is considered as root module, which should not be that way.

This can be fixed in webpack.

When 2. is fixed 1. will no occur that often, but it could still happen in certain splitChunks configurations, which puts the css parts into separate chunks.

sokra added a commit to webpack/webpack that referenced this issue Jan 11, 2021
sokra added a commit to webpack/webpack that referenced this issue Jan 11, 2021
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