Skip to content
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

Merged
merged 2 commits into from Jul 25, 2022
Merged

add tree-shaking to ProvidedDependency #15627

merged 2 commits into from Jul 25, 2022

Conversation

vankop
Copy link
Member

@vankop vankop commented Apr 4, 2022

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

@webpack-bot
Copy link
Contributor

For maintainers only:

  • This needs to be documented (issue in webpack/webpack.js.org will be filed when merged)
  • This needs to be backported to webpack 4 (issue will be created when merged)

Comment on lines 58 to 77
/**
* @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;
}

Copy link
Member

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.

@webpack-bot
Copy link
Contributor

@vankop Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@sokra Please review the new changes.

@@ -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(",") : "");
Copy link
Member Author

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

@sokra sokra merged commit 7b63346 into main Jul 25, 2022
@sokra sokra deleted the feat/issue-12441 branch July 25, 2022 07:28
@sokra
Copy link
Member

sokra commented Jul 25, 2022

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The webpack.ProvidePlugin does not tree shake code as documented
3 participants