Skip to content

fix: library module without export statement#19411

Merged
alexander-akait merged 3 commits intowebpack:mainfrom
hai-x:fix-library-disable-provided-export
Apr 16, 2025
Merged

fix: library module without export statement#19411
alexander-akait merged 3 commits intowebpack:mainfrom
hai-x:fix-library-disable-provided-export

Conversation

@hai-x
Copy link
Member

@hai-x hai-x commented Apr 10, 2025

What kind of change does this PR introduce?
Fixes #18056. Follows #18176.

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

@hai-x hai-x marked this pull request as ready for review April 10, 2025 16:35
new FlagDependencyExportsPlugin().apply(compiler);
}
}
}).apply(compiler);
Copy link
Member

Choose a reason for hiding this comment

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

Looks good, what is about apply it only for require libraries, i.e. where we use getExportsInfo()/getExportInfo()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh no, I think I forgot to push that code fragment. I’ll push it later tonight, my time.

Copy link
Member

Choose a reason for hiding this comment

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

Don't worry, thank you for your help

@hai-x
Copy link
Member Author

hai-x commented Apr 11, 2025

@alexander-akait

After detail check, I found that when providedExports: false, the following library will broken. I hope I haven't missed anything.

  1. commonjs-static broken bundle => lose one close bracket.
Image
  1. module + modern-module => lose export statement as mentioned in this issue.

For other call sites of getExportsInfo, I believe setting providedExports: false won't break the bundle. It should only result in less bundle optimization, which is the expected behavior of disabing.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Thank you

@alexander-akait alexander-akait merged commit fe2ce39 into webpack:main Apr 16, 2025
63 checks passed
@hai-x hai-x deleted the fix-library-disable-provided-export branch April 16, 2025 14:31
3ru pushed a commit to 3ru/webpack that referenced this pull request Jul 1, 2025
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.

when setting optimization.providedExports to false, outputModule wouldn't generate export statement

2 participants