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
fix: fix pureDep returns null in some js files #16701
Conversation
For maintainers only:
|
d4a19f0
to
8e9f05f
Compare
8e9f05f
to
3902ac5
Compare
@alexander-akait @TheLarkInn @sokra This is a fatal error, please help to merge and release a version as soon as possible. For now I temporarily work around by disabling innerGraph // webpack.config.js
module.exports = {
//...
optimization: {
+ innerGraph: false,
},
}; By the way, another bugfix I submitted is best dealt with together, Thanks 🙏 |
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.
Sorry for delay, it looks good, but we need a test case here, can you add it?
@alexander-akait I can't reproduce it in a simple demo, maybe I have to read more Inner-module tree-shaking related codes to write it. It would be appreciated if you could quickly complete the test case. Otherwise I might spend some time |
@xiaoxiaojx it is not good to merge code without tests 😞 How you catch a such problem and how do you undestand that this fix helps? |
@alexander-akait This problem occurred in a project of our company, So I can't upload this part of the reproduced code 😢 ,I've been trying to reproduce in a simple demo, but it always works 😅 What I found out is that a {
29971: function (t, e, r) {
e.ZP =
5224 == r.j
? function (t, e, r) {
var i,
o = e.payload.cacheKey;
return n(n({}, t), (((i = {})[o] = m(t[o], e, r)), i));
}
: null;
}
} /** @typedef {string | SortableSet<string> | undefined} RuntimeSpec */ The value of this runtimes is But here only e.ZP = 5224 == r.j ? xxx : null At this time, if So I changed the parameter passed in when generating runtimeConditionExpression from runtime to mergedRuntimes - const runtimeCondition = filterRuntime(runtime, runtime => {
+ const merged = deepMergeRuntime(runtimes, runtime);
+ const runtimeCondition = filterRuntime(merged, runtime => { The code generated by e.ZP = [5224, 9768].includes(r.j) ? xxx : null |
Looks good for me, will be great to have a lot of @sokra here |
Can you please add a tests case for this? Happy to help with this. If it's fixing something we should guard against these with tests for future changes. |
@TheLarkInn I tried hard to reproduce it in the demo, and then wrote test cases, but in the end I couldn't reproduce it. I think the Inner-module tree-shaking part of the code is complicated 😢 ...... |
@xiaoxiaojx maybe you can provide what do you try to solve with simpel examples of code, so I can try to help you with tests |
@alexander-akait I'm not sure what conditions a Module has a runtimes array (RuntimeSpec[]). So far, no one else has reported this problem, and I have begun to wonder if this project uses a special plugin 🤷♂️. I can't provide more information at the moment, so let's put this pr on hold for now ... |
we should toggle it on after the fix webpack/webpack#16701
I just stumbled upon this issue after finding @xiaoxiaojx 's blog post pointing here (thank you!). We started seeing the mismatched module ID/null function export after switching from The workaround to disable I see there's some talk about tests, but my guess is that it might be hard to come up with a robust test here that captures the behaviour, since in our case we only saw this for one specific module in our monorepo out of thousands, and only after shipping a second, seemingly benign change (which presumably affected chunking/module concatenation/something else under the hood). If I were to take a stab at the conditions that cause this, I'd say:
If there's more info I can provide that would help get this merged, that would be great. |
Can confirm this is a bug. In this PR @plrthink commit/8b1b55b and @jdb8 also reported the same bug. Currently pr can run through all test cases. It may be a good choice to merge it first. cc @alexander-akait @TheLarkInn |
@xiaoxiaojx Hm, okay, our tests are success, so let's ship it, maybe in future we will add a test case here, sorry for delay |
@alexander-akait Thanks, looking forward to the new version ! |
@plrthink @jdb8 webpack@5.90.0 has fixed,Let's re-enable this optimization,Thanks to everyone. // webpack.config.js
module.exports = {
//...
optimization: {
+ innerGraph: true,
- innerGraph: false,
},
}; |
What kind of change does this PR introduce?
bugfix
Did you add tests for your changes?
Not easy to reproduce, TODO
Does this PR introduce a breaking change?
no
What needs to be documented once your changes are merged?
no