Skip to content

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

Open
scameron wants to merge 3 commits into
webpack:mainfrom
scameron:export-mangling
Open

fix attempt: enable export mangling for modules used only as export objects#19219
scameron wants to merge 3 commits into
webpack:mainfrom
scameron:export-mangling

Conversation

@scameron

Copy link
Copy Markdown
Contributor

This is a first attempt at a fix for issue #19153. I'm almost certain that this is wrong, but it seems to work in my case. The hope is that running this through the automated tests will show more info about specifically what is wrong with this.

I tried this in my full production build and it succeeds there as well. The chunk size is reduced by nearly 3MB overall after this change (in an enormous 484MB build, but still).

What kind of change does this PR introduce?

In cases where a depency has no specific used exports, but instead is used as an "export object" via an export of import *, we no longer mark the usage as "unknown" but instead mark it as used.

Did you add tests for your changes?

No new tests. This is an experiment to see what existing tests break.

Does this PR introduce a breaking change?

Not sure yet...

What needs to be documented once your changes are merged?

No documentation

@TheLarkInn TheLarkInn requested a review from Copilot February 12, 2025 20:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (3)

lib/ExportsInfo.js:402

  • The new method setUsedAsExportObject should be covered by tests to ensure it behaves as expected.
setUsedAsExportObject(runtime) {

lib/FlagDependencyUsagePlugin.js:93

  • The new behavior introduced by setUsedAsExportObject should be covered by tests to ensure correctness and prevent regressions.
if (exportsInfo.setUsedAsExportObject(runtime)) {

lib/optimize/MangleExportsPlugin.js:25

  • The removal of this check might change the intended behavior of the canMangle function. Please ensure this change is intentional and doesn't introduce any bugs.
if (exportsInfo.otherExportsInfo.getUsed(undefined) !== UsageState.Unused)

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests cases?

@alexander-akait

Copy link
Copy Markdown
Member

Looks like a problem with default in our tests

@Vansh5632

Copy link
Copy Markdown
Contributor

@scameron from failing test cases i can think there is some error in the code style in which you have written try to fix that and re run the yarn test --basic to see further outputs

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants