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
add tree-shaking to ProvidedDependency #15627
Conversation
For maintainers only:
|
/** | ||
* @param {ModuleGraph} moduleGraph the module graph | ||
* @returns {string[]} the imported ids | ||
*/ | ||
getIds(moduleGraph) { | ||
const meta = moduleGraph.getMetaIfExisting(this); | ||
if (meta === undefined) return this.ids; | ||
const ids = meta[idsSymbol]; | ||
return ids !== undefined ? ids : this.ids; | ||
} | ||
|
||
/** | ||
* @param {ModuleGraph} moduleGraph the module graph | ||
* @param {string[]} ids the imported ids | ||
* @returns {void} | ||
*/ | ||
setIds(moduleGraph, ids) { | ||
moduleGraph.getMeta(this)[idsSymbol] = ids; | ||
} | ||
|
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.
Actually you don't need that for tree shaking.
these [sg]etIds
stuff is only used for https://github.com/webpack/webpack/blob/main/lib/optimize/SideEffectsFlagPlugin.js and that checks only for HarmonyExportImportedSpecifierDependency
and HarmonyImportSpecifierDependency
.
@@ -53,23 +73,22 @@ class ProvidedDependency extends ModuleDependency { | |||
*/ | |||
updateHash(hash, context) { | |||
if (this._hashUpdate === undefined) { | |||
this._hashUpdate = | |||
this.identifier + (this.path ? this.path.join(",") : "null"); | |||
this._hashUpdate = this.identifier + (this.ids ? this.ids.join(",") : ""); |
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.
null
property could be in ids
Thanks |
What kind of change does this PR introduce?
feature
closes #12441
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