-
Notifications
You must be signed in to change notification settings - Fork 513
fix(index): don't crash with dynamic import()
#728
fix(index): don't crash with dynamic import()
#728
Conversation
src/index.js
Outdated
@@ -218,7 +233,9 @@ class ExtractTextPlugin { | |||
// chunk.sortModules(); | |||
|
|||
async.forEach( | |||
Array.from(chunk.modulesIterable), | |||
Array.from(chunk.modulesIterable).sort( | |||
(a, b) => a.index - b.index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the chunk-modules-css-wrong-order
test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this use .index2
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index2
is the ESM evaluation order.index
is the CJS evaluation order@sokra
css-loader@latest
returns a CJS module, so index
should be fine for now. Please add a comment to check/switch to index2
in case this plugin will see ESM input in the future 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually not up to css-loader, but up to the ETWP pitching loader's result. The pitch result is a commonjs module, so even if css-loader is converted, it won't be able to be picked by concatenated modules because it'll be required via commonjs.
I have no idea what is broken in CI but it's not our code 🤔 |
@Kovensky very strange, seems problem in |
I suspect a conflict because of |
@Kovensky you should be able to use this comment to disable JSDOM for a test file:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better to wait for webpack/webpack#6597
src/index.js
Outdated
@@ -218,7 +233,9 @@ class ExtractTextPlugin { | |||
// chunk.sortModules(); | |||
|
|||
async.forEach( | |||
Array.from(chunk.modulesIterable), | |||
Array.from(chunk.modulesIterable).sort( | |||
(a, b) => a.index - b.index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index2
is the ESM evaluation order.index
is the CJS evaluation order@sokra
css-loader@latest
returns a CJS module, so index
should be fine for now. Please add a comment to check/switch to index2
in case this plugin will see ESM input in the future 😛
const source = new ConcatSource(); | ||
|
||
for (const chunkModule of chunk.modulesIterable) { | ||
let moduleSource = chunkModule.source(); | ||
let moduleSource = chunkModule.source( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That workaround breaks for other types of Module; it's best to just treat these 2 arguments as part of the Module API now.
commitlint.config.js
Outdated
@@ -12,7 +12,7 @@ const Configuration = { | |||
'subject-full-stop': [2, 'never', '.'], | |||
'type-case': [2, 'always', 'lower-case'], | |||
'type-empty': [2, 'never'], | |||
'type-enum': [ | |||
'type-enum': [2, 'always', [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert please, if it is a bug then it needs to be fixed in webpack-defaults
instead. Not sure actually, seeing this commit messages :D :P https://github.com/webpack-contrib/extract-text-webpack-plugin/pull/728/commits. Use git commit -m '...' --no-verify
in the meantime, they will be squashed anyways :)
import()
37a19cc
to
0ea1d55
Compare
ETWP is not supposed to run in a browser
@probablyup that problem wasn't with one file but with all files; since ETWP is supposed to run on node instead of in a browser the default testEnvironment was wrong to begin with. |
Released in v4.0.0-beta.0 🎉
|
import()
import()
Issues
as well as works around an issue where javascript source code of concat modules is being included in extracted css.
Notable Changes
This also works around an issue where
meta.content
can have more than one entry, which I could not figure out how to reproduce for the unit tests, but which was happening in a codebase I am trying to migrate to webpack@4. I don't know if the result is 100% correct, but it compiles, is no longer missing huge amounts of CSS that was definitely supposed to be there, and on quick inspection doesn't seem to have visual artifacts on my page.This also fixes the commitlint config because it didn't want to let me commit otherwise 🤷♀️