Skip to content

Conversation

@JSerFeng
Copy link
Contributor

@JSerFeng JSerFeng commented Dec 17, 2025

Summary

When reexports dynamic, runtime code will like this:

var __WEBPACK_REEXPORT_OBJECT__ = {};
for(var __WEBPACK_IMPORT_KEY__ in path__WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== "default") __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => { return path__WEBPACK_IMPORTED_MODULE_0__[__WEBPACK_IMPORT_KEY__]; }

However this getter only access variable __WEBPACK_IMPORT_KEY__ when it really gets invoked, but the __WEBPACK_IMPORT_KEY__ is declared using var, which is in global scope not block scope in for stmt.

That will cause every getter access the last __WEBPACK_IMPORT_KEY__ in the end.

What kind of change does this PR introduce?

Fix

Did you add tests for your changes?

Yep.

Does this PR introduce a breaking change?

Nope.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

@changeset-bot
Copy link

changeset-bot bot commented Dec 17, 2025

🦋 Changeset detected

Latest commit: 2c4e037

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@JSerFeng JSerFeng marked this pull request as ready for review December 17, 2025 12:19
@JSerFeng
Copy link
Contributor Author

I can't find the exact browserslist that supports arrowFunction but not supports const, however we really repro it in one of the internal repo so...

@alexander-akait
Copy link
Member

@JSerFeng Let's fix style, just update prettier

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 17, 2025

CodSpeed Performance Report

Merging #20249 will not alter performance

Comparing JSerFeng:fix/re-exports-dynamic (2c4e037) with main (0c213ce)

Summary

✅ 54 untouched
⏩ 18 skipped1

Footnotes

  1. 18 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@JSerFeng JSerFeng changed the title fix(re-exports): should render use arrow getter for dynamic reexports… fix(re-exports): should render use arrow getter for dynamic reexports when using const as decl Dec 18, 2025
@JSerFeng JSerFeng force-pushed the fix/re-exports-dynamic branch from 6af3489 to f3efe56 Compare December 18, 2025 03:52
@JSerFeng JSerFeng changed the title fix(re-exports): should render use arrow getter for dynamic reexports when using const as decl fix(re-exports): reexports runtime calculation should not accessing __WEBPACK_IMPORT_KEY__ decl with var Dec 18, 2025
@alexander-akait alexander-akait merged commit 2efd21b into webpack:main Dec 18, 2025
48 of 50 checks passed
@github-actions
Copy link
Contributor

This PR is packaged and the instant preview is available (2efd21b).

Install it locally:

  • npm
npm i -D webpack@https://pkg.pr.new/webpack@2efd21b
  • yarn
yarn add -D webpack@https://pkg.pr.new/webpack@2efd21b
  • pnpm
pnpm add -D webpack@https://pkg.pr.new/webpack@2efd21b

Copy link

@Andreo2301 Andreo2301 left a comment

Choose a reason for hiding this comment

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

@

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.

3 participants