Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix attempt: enable export mangling for modules used only as export objects #19219

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions 45 lib/ExportsInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,33 @@ class ExportsInfo {
return changed;
}

/**
* @param {RuntimeSpec} runtime the runtime
* @returns {boolean} true, when something changed
*/
setUsedAsExportObject(runtime) {
let changed = false;
for (const exportInfo of this._exports.values()) {
if (exportInfo.setUsedAsExportObject(runtime)) {
changed = true;
}
}
if (this._redirectTo !== undefined) {
if (this._redirectTo.setUsedAsExportObject(runtime)) {
changed = true;
}
} else if (
this._otherExportsInfo.setUsedConditionally(
used => used !== UsageState.Used,
UsageState.Used,
runtime
)
) {
changed = true;
}
return changed;
}

/**
* @param {RuntimeSpec} runtime the runtime
* @returns {boolean} true, when something changed
Expand Down Expand Up @@ -966,6 +993,24 @@ class ExportInfo {
return changed;
}

/**
* @param {RuntimeSpec} runtime only apply to this runtime
* @returns {boolean} true, when something changed
*/
setUsedAsExportObject(runtime) {
let changed = false;
if (
this.setUsedConditionally(
used => used !== UsageState.Used,
UsageState.Used,
runtime
)
) {
changed = true;
}
return changed;
}

/**
* @param {RuntimeSpec} runtime only apply to this runtime
* @returns {boolean} true, when something changed
Expand Down
2 changes: 1 addition & 1 deletion 2 lib/FlagDependencyUsagePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class FlagDependencyUsagePlugin {
canMangle = usedExportInfo.canMangle !== false;
}
if (usedExport.length === 0) {
if (exportsInfo.setUsedInUnknownWay(runtime)) {
if (exportsInfo.setUsedAsExportObject(runtime)) {
queue.enqueue(module, runtime);
}
} else {
Expand Down
2 changes: 0 additions & 2 deletions 2 lib/optimize/MangleExportsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ const { compareSelect, compareStringsNumeric } = require("../util/comparators");
* @returns {boolean} mangle is possible
*/
const canMangle = exportsInfo => {
if (exportsInfo.otherExportsInfo.getUsed(undefined) !== UsageState.Unused)
return false;
let hasSomethingToMangle = false;
for (const exportInfo of exportsInfo.exports) {
if (exportInfo.canMangle === true) {
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.