Skip to content

add tree-shaking to ProvidedDependency#15627

Merged
sokra merged 2 commits intomainfrom
feat/issue-12441
Jul 25, 2022
Merged

add tree-shaking to ProvidedDependency#15627
sokra merged 2 commits intomainfrom
feat/issue-12441

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)

@vankop vankop force-pushed the feat/issue-12441 branch from 3bee91d to 0aabe2a Compare April 4, 2022 15:01
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.

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