fix: tree-shaking unused RawModule#19671
Conversation
| */ | ||
| getSideEffectsConnectionState(moduleGraph) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
That is wrong, raw module is just a raw and can have side effects
There was a problem hiding this comment.
It looks like all the RawModules generated by webpack appear to lack meaningful content, either /* (ignored) */ or being completely empty.
Do you mean that the class RawModule has been exported and could be used by plugins?
There was a problem hiding this comment.
Oh, I see. It should be determined by the source parameter.
There was a problem hiding this comment.
I've made a patch to read from this.factoryMeta.sideEffectFree. PTAL~
CodSpeed Performance ReportMerging #19671 will degrade performances by 72.85%Comparing Summary
Benchmarks breakdown
|
lib/Module.js
Outdated
| if (this.factoryMeta !== undefined) { | ||
| if (this.factoryMeta.sideEffectFree) return false; | ||
| if (this.factoryMeta.sideEffectFree === false) return true; | ||
| } |
There was a problem hiding this comment.
Please put this login inside RawModule, otherwise it is potential breaking changes for plugins
There was a problem hiding this comment.
Thanks! This make more sense
See: webpack/webpack#19670 This is a port of webpack/webpack#19671
close: #19670
What kind of change does this PR introduce?
a bugfix
Did you add tests for your changes?
Yes
Does this PR introduce a breaking change?
No
What needs to be documented once your changes are merged?
Nothing