You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the module layout here: REPL
Specify preserveModules: true and treeShaking.moduleSideEffects: false
I understand the contract of the moduleSideEffects flag to mean, for a given module:
true: All modules imported later than this module may have an implicit dependency on this module, and therefore this module must not be moved to be later in the load order (but may potentially be moved earlier)
false: No modules have an implicit dependency on this module, and thus it may be safely moved later in the load order
Addressing this may be as simple as introducing a check in inlineChunkDependencies:
if (!dep.isEmpty) {
+ // In preserveModules mode, only inline the dep if it has side effects (being used elsewhere is not a side effect)+ if (!this.graph.preserveModules || !dep.facadeModule || dep.facadeModule.moduleSideEffects) {
this.dependencies.push(dep);
+ }
}
Edit: added info about moduleSideEffects expectations
Edit: added link to 3109
The text was updated successfully, but these errors were encountered:
The actual solution I implemented was a little more complicated as pruning dependencies should ideally happen on module level, not on chunk level. Nevertheless, there is a pending fix now: #3369 !
Search terms:
treeshaking
moduleSideEffects
preserveModules
empty imports
Related:
#3057
#3109
How Do We Reproduce?
Using the module layout here:
REPL
Specify
preserveModules: true
andtreeShaking.moduleSideEffects: false
I understand the contract of the
moduleSideEffects
flag to mean, for a given module:true
: All modules imported later than this module may have an implicit dependency on this module, and therefore this module must not be moved to be later in the load order (but may potentially be moved earlier)false
: No modules have an implicit dependency on this module, and thus it may be safely moved later in the load orderExpected Behavior
Actual Behavior
Addressing this may be as simple as introducing a check in
inlineChunkDependencies
:Edit: added info about
moduleSideEffects
expectationsEdit: added link to 3109
The text was updated successfully, but these errors were encountered: