Skip to content

fix: keep named re-export ids when the same request is star-reexport - #22351

Merged
alexander-akait merged 1 commit into
mainfrom
fix/lazy-barrel-named-and-star-reexport
Sep 29, 2026
Merged

alexander-akait merged 1 commit into
mainfrom
fix/lazy-barrel-named-and-star-reexport

Conversation

@hai-x

@hai-x hai-x commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Summary

When a barrel re-exports one module both by name and with export *, i.e.

  1. export { default as Button } from "./Button/index.mjs";
  2. export * from "./Button/index.mjs";

the lazy barrel forwarded only the barrel's own names and dropped the named re-export's id, so the nested barrel never built its default target and the import resolved to undefined.

Now we merges the star-forwarded names with the named re-export ids of the same request.

cc @xiaoxiaojx

What kind of change does this PR introduce?

fix

Did you add tests for your changes?

Yes

Does this PR introduce a breaking change?

No

If relevant, what needs to be documented once your changesou already documented?

n/a

Use of AI

Yes

Summary by CodeRabbit

  • Bug Fixes
    • Fixed export handling for nested re-exports, so default and named exports—including utility class exports—are correctly available when modules are re-exported together.
    • Improved consistency when resolving exports forwarded through multiple barrels, including cases where a dependency exposes all exports. This helps ensure optimized production builds preserve the expected exports for consumers.

@hai-x
hai-x force-pushed the fix/lazy-barrel-named-and-star-reexport branch from ad3f3b5 to 3472285 Compare September 29, 2026 04:05
@changeset-bot

changeset-bot Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 295d697

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@changeset-bot

changeset-bot Bot commented Sep 29, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ad3f3b5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: webpack/webpack/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: a034deea-b5fe-4e03-96c4-143d6b774199

📥 Commits

Reviewing files that changed from the base of the PR and between d7f7e56 and 295d697.

📒 Files selected for processing (11)
  • lib/optimize/LazyBarrel.js
  • test/configCases/lazy-barrel/nested-default-reexport/index.js
  • test/configCases/lazy-barrel/nested-default-reexport/lib/Button/Button.mjs
  • test/configCases/lazy-barrel/nested-default-reexport/lib/Button/buttonClasses.mjs
  • test/configCases/lazy-barrel/nested-default-reexport/lib/Button/index.mjs
  • test/configCases/lazy-barrel/nested-default-reexport/lib/Table/Table.mjs
  • test/configCases/lazy-barrel/nested-default-reexport/lib/Table/index.mjs
  • test/configCases/lazy-barrel/nested-default-reexport/lib/Table/tableClasses.mjs
  • test/configCases/lazy-barrel/nested-default-reexport/lib/index.mjs
  • test/configCases/lazy-barrel/nested-default-reexport/package.json
  • test/configCases/lazy-barrel/nested-default-reexport/webpack.config.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

LazyBarrelController.request now collects forwarded IDs across direct and star re-exports, including recorded parent-barrel IDs. A new nested re-export test checks exported values and compilation modules with module concatenation enabled and disabled.

Changes

Lazy barrel re-export handling

Layer / File(s) Summary
Forwarded ID collection
lib/optimize/LazyBarrel.js
request gathers IDs while processing dependencies. For star re-exports, it merges recorded parent IDs and retains the existing true handling.
Nested re-export regression fixture
test/configCases/lazy-barrel/nested-default-reexport/*
The fixture defines nested Button and Table default and named exports. The test checks the Button value and utility class. Two webpack configurations check for Button.mjs with module concatenation disabled and enabled.

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 295d6

The change has no identified issue that needs resolution before merge. The nested re-export behavior has targeted regression coverage.

🚥 Pre-merge checks | ✅ 3 | ❓ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title uses the required Conventional Commit form with the allowed type fix and accurately describes the lazy-barrel re-export change. The branch prefix is not provided, so the required type-to-b… Provide the branch name or confirm that its prefix is fix.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title uses the required Conventional Commit form with the allowed type fix and accurately describes the lazy-barrel re-export change. The branch prefix is not provided, so the required type-to-branch-prefix match cannot be verified.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the area: optimization Tree-shaking, splitChunks, concatenation, ids (lib/optimize, lib/ids) label Sep 29, 2026
@hai-x
hai-x requested a review from xiaoxiaojx September 29, 2026 04:05
@hai-x
hai-x force-pushed the fix/lazy-barrel-named-and-star-reexport branch from 3472285 to 8bbc92e Compare September 29, 2026 04:08
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

This PR is packaged and the instant preview is available (045d2ab).

Install it locally:

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

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Types Coverage

Coverage after merging fix/lazy-barrel-named-and-star-reexport into main will be
97.05%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
bin
   webpack.js98.82%100%100%98.82%103
declarations
   WebpackOptions.ts99.94%100%100%99.94%4147
examples
   build-common.js100%100%100%100%
   buildAll.js100%100%100%100%
   examples.js100%100%100%100%
   template-common.js98.21%100%100%98.21%72
examples/custom-javascript-parser
   test.filter.js100%100%100%100%
examples/custom-javascript-parser/internals
   acorn-parse.js100%100%100%100%
   meriyah-parse.js100%100%100%100%
   oxc-parse.js100%100%100%100%
examples/markdown
   webpack.config.mjs100%100%100%100%
examples/module-federation
   test.filter.js100%100%100%100%
examples/reexport-components
   test.filter.js100%100%100%100%
examples/ssr
   test.filter.js100%100%100%100%
examples/typescript
   test.filter.js100%100%100%100%
examples/typescript-non-erasable
   test.filter.js50%100%100%50%5
examples/virtual-modules
   test.filter.js100%100%100%100%
examples/wasm-bindgen-esm
   test.filter.js100%100%100%100%
examples/wasm-complex
   test.filter.js100%100%100%100%
examples/wasm-emscripten
   test.filter.js100%100%100%100%
examples/wasm-simple
   test.filter.js100%100%100%100%
examples/wasm-simple-source-phase
   test.filter.js100%100%100%100%
lib
   Chunk.js100%100%100%100%
   Compilation.js98.59%100%100%98.59%1757, 2078, 2085, 2093, 2115, 2118, 23, 3054, 3533–3534, 3566, 4155, 4159, 4286, 4307, 4432, 4469, 4476, 4529–4530, 4534, 4539, 4555–4556, 4570–4571, 4576–4577, 5100, 5126, 5956, 5973, 5991, 6007, 6022, 6047, 6050, 6418, 6421–6422, 6427, 6442, 6525, 6549, 6663, 837–838
   Compiler.js98.81%100%100%98.81%1116, 1153, 1156, 1336–1337, 1345, 848, 934, 975
   Dependency.js100%100%100%100%
   DependencyTemplate.js100%100%100%100%
   EntryPlugin.js100%100%100%100%
   Entrypoint.js100%100%100%100%
   ExternalsPlugin.js100%100%100%100%
   FileSystemInfo.js100%100%100%100%
   InitFragment.js100%100%100%100%
   LibraryTemplatePlugin.js100%100%100%100%
   ModuleFilenameHelpers.js100%100%100%100%
   ModuleNotFoundError.js100%100%100%100%
   MultiCompiler.js98.88%100%100%98.88%460, 532, 719, 784
   NormalModule.js100%100%100%100%
   NullFactory.js100%100%100%100%
   ProgressPlugin.js100%100%100%100%
   RawModule.js100%100%100%100%
   RequestShortener.js100%100%100%100%
   SingleEntryPlugin.js100%100%100%100%
   WebpackError.js100%100%100%100%
   index.js99.77%100%100%99.77%206
   webpack.js97.84%100%100%97.84%278, 300, 302
lib/asset
   AssetBytesGenerator.js100%100%100%100%
   AssetBytesParser.js100%100%100%100%
   AssetGenerator.js100%100%100%100%
   AssetModule.js100%100%100%100%
   AssetModulesPlugin.js98.15%100%100%98.15%338, 362, 365, 495, 57, 62
   AssetParser.js100%100%100%100%
   AssetSourceGenerator.js100%100%100%100%
   AssetSourceParser.js100%100%100%100%
   RawDataUrlModule.js100%100%100%100%
   WebManifestGenerator.js100%100%100%100%
   WebManifestParser.js100%100%100%100%
lib/async-modules
   AsyncModuleHelpers.js100%100%100%100%
   AwaitDependenciesInitFragment.js100%100%100%100%
   InferAsyncModulesPlugin.js100%100%100%100%
   isGeneratorLowered.js100%100%100%100%
lib/bun
   BunTargetPlugin.js100%100%100%100%
lib/cache
   AddBuildDependenciesPlugin.js100%100%100%100%
   AddManagedPathsPlugin.js100%100%100%100%
   Cache.js96.49%100%100%96.49%10, 104
   CacheFacade.js100%100%100%100%
   IdleFileCachePlugin.js97.92%100%100%97.92%75, 87, 95
   MemoryCachePlugin.js92%100%100%92%33, 42
   MemoryWithGcCachePlugin.js93.42%100%100%93.42%106, 120–121, 130, 88
   PackFileCacheStrategy.js96.54%100%100%96.54%1304, 1404, 1408, 1470, 1716, 1800, 1823, 1853, 682, 701, 711–713, 715, 731–732, 737, 740, 742, 747, 752, 777, 783, 817, 823, 829, 834, 845, 854, 859–860, 862, 879, 885–886, 888
   ResolverCachePlugin.js100%100%100%100%
   getLazyHashedEtag.js100%100%100%100%
   mergeEtags.js100%100%100%100%
lib/config
   OptionsApply.js100%100%100%100%
   PlatformPlugin.js100%100%100%100%
   WebpackOptionsApply.js100%100%100%100%
   WebpackOptionsDefaulter.js100%100%100%100%
   browserslistTargetHandler.js100%100%100%100%
   cli.js98.61%100%100%98.61%116, 546, 578, 628, 9
   defaults.js99.44%100%100%99.44%1623–1625, 1633, 283, 286, 291, 295
   defineConfig.js100%100%100%100%
   getClaimedAssetTypes.js100%100%100%100%
   normalization.js99.12%100%100%99.12%279–280, 346, 361
   target.js100%100%100%100%
   validateSchema.js94.67%100%100%94.67%100, 87, 89, 98
lib/container
   ContainerEntryDependency.js100%100%100%100%
   ContainerEntryModule.js100%100%100%100%
   ContainerEntryModuleFactory.js100%100%100%100%
   ContainerExposedDependency.js100%100%100%100%
   ContainerPlugin.js100%100%100%100%
   ContainerReferencePlugin.js100%100%100%100%
   FallbackDependency.js100%100%100%100%
   FallbackItemDependency.js100%100%100%100%
   FallbackModule.js100%100%100%100%
   FallbackModuleFactory.js100%100%100%100%
   HoistContainerReferencesPlugin.js100%100%100%100%
   ModuleFederationPlugin.js100%100%100%100%
   RemoteModule.js100%100%100%100%
   RemoteRuntimeModule.js100%100%100%100%
   RemoteToExternalDependency.js100%100%100%100%
   declaredRemotes.js100%100%100%100%
   moduleFederationHooks.js100%100%100%100%
   options.js100%100%100%100%
lib/context
   ContextExclusionPlugin.js100%100%100%100%
   ContextModule.js99.88%100%100%99.88%1494
   ContextModuleFactory.js95.66%100%100%95.66%230, 257, 276, 280–281, 289, 465, 486, 491, 532, 541, 543, 547, 550, 556–557
   ContextReplacementPlugin.js100%100%100%100%
lib/css
   CssGenerator.js99.47%100%100%99.47%1085, 136, 842
   CssInjectStyleRuntimeModule.js100%100%100%100%
   CssLoadingRuntimeModule.js100%100%100%100%
   CssModule.js83.16%100%100%83.16%197, 202–210, 212–217
   CssModulesPlugin.js99.86%100%100%99.86%886
   CssParser.js99.44%100%100%99.44%2227, 24, 2861, 2864, 2870, 2911, 2914, 2953, 2956, 3293, 4698, 4701, 843, 959, 990
   CssServerStylesRuntimeModule.js100%100%100%100%
   conventions.js98.65%100%100%98.65%93
   cssMinify.js96.30%100%100%96.30%127, 136
   data.js99.83%100%100%99.83%224, 4043
   syntax-parser.js99.71%100%100%99.71%10136–10137, 10174, 10355, 10401, 12267, 12765, 13118, 14702, 2396, 3095, 3097, 3102, 3121, 3866, 3872, 7082, 7120, 7127, 9601–9602
   syntax-printer.js99.23%100%100%99.23%2282–2283, 2285–2286, 2288–2289, 2294, 2555–2558, 3341, 3474, 3583, 4022, 4271, 5050, 621, 80
   syntax.js100%100%100%100%
   topologicalSort.js100%100%100%100%
lib/debug
   ProfilingPlugin.js96.22%100%100%96.22%169, 425, 554, 561, 570, 574, 583, 588, 594, 599, 92
lib/define
   DefinePlugin.js98.85%100%100%98.85%1495, 268–269, 285, 304, 378, 936, 938, 943, 967
   DotenvPlugin.js98.07%100%100%98.07%391, 439, 452–453
   EnvironmentPlugin.js97.14%100%100%97.14%49
lib/deno
   DenoTargetPlugin.js100%100%100%100%
lib/dependencies
   ConstDependency.js100%100%100%100%
   ContextElementDependency.js100%100%100%100%
   NullDependency.js100%100%100%100%
lib/dependencies/amd
   AMDDefineDependency.js100%100%100%100%
   AMDDefineDependencyParserPlugin.js100%100%100%100%
   AMDPlugin.js99.31%100%100%99.31%54
   AMDRequireArrayDependency.js100%100%100%100%
   AMDRequireContextDependency.js100%100%100%100%
   AMDRequireDependenciesBlock.js100%100%100%100%
   AMDRequireDependenciesBlockParserPlugin.js100%100%100%100%
   AMDRequireDependency.js100%100%100%100%
   AMDRequireItemDependency.js100%100%100%100%
   AMDRuntimeModules.js95.45%100%100%

…truncated

@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.74%. Comparing base (d7f7e56) to head (295d697).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #22351      +/-   ##
==========================================
+ Coverage   94.50%   95.74%   +1.23%     
==========================================
  Files         767      770       +3     
  Lines      109227   109482     +255     
  Branches    34138    34198      +60     
==========================================
+ Hits       103230   104823    +1593     
+ Misses       5997     4659    -1338     
Flag Coverage Δ
css-parsing 25.63% <0.00%> (+<0.01%) ⬆️
html5lib 27.23% <0.00%> (+<0.01%) ⬆️
integration 84.17% <100.00%> (+1.84%) ⬆️
syntax-equivalence 79.17% <ø> (ø)
test262 48.51% <0.00%> (+<0.01%) ⬆️
unit 76.24% <72.72%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Generated code size

Comparing base (d7f7e56) to head (295d697). Merging this pull request adds 2 new asset(s).

What moved Tests Assets Gzip Raw Test edit
Changed, test untouched 0 0 — — —
Changed, test edited 0 0 — — —
New 1 2 ⚪ added +1.36 KiB ⚪ added +4.11 KiB —
Deleted 0 0 — — —
Unchanged — 8279 — — —

Read Changed, test untouched first: the test is byte-identical on both sides, so webpack generated the difference. Changed, test edited moved partly because the test did — Test edit is how many bytes the test gained, and a bundle that grew by less is not a regression. New and Deleted are whole files, not deltas — a new asset was created, not grown, so it reads gray (⚪ added) — and adding tests cannot bury a real change. Gzip decides, because that is what users download; raw is the tiebreak, and brotli and zstd are per asset below.

No asset that both runs emit changed size — everything below is new or deleted.

2 asset(s) this pull request adds
Asset Raw Gzip (9) Brotli (11) Zstd (19)
⚪ added lazy-barrel/nested-default-reexport 0/bundle0.js 3.34 KiB 1020 B 892 B 1.00 KiB
⚪ added lazy-barrel/nested-default-reexport 1/bundle1.js 790 B 377 B 326 B 379 B

No runtime that both runs build changed which runtime modules it carries.

1 runtime(s) this pull request adds or no longer builds
Runtime Modules
➕ lazy-barrel/nested-default-reexport 0/main 2

Built test/configCases with the defaults a user gets: 2288 test(s), 8281 asset(s), 96 emitted nothing.

@hai-x
hai-x force-pushed the fix/lazy-barrel-named-and-star-reexport branch from 8bbc92e to ed2d98c Compare September 29, 2026 04:53
@hai-x
hai-x force-pushed the fix/lazy-barrel-named-and-star-reexport branch from ed2d98c to 295d697 Compare September 29, 2026 06:01
@codspeed

codspeed Bot commented Sep 29, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by ×2.8

⚡ 1 improved benchmark
✅ 401 untouched benchmarks
⏩ 6 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Memory benchmark "concatenate-modules", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 2,790 KB 990.3 KB ×2.8

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix/lazy-barrel-named-and-star-reexport (295d697) with main (d7f7e56)

Open in CodSpeed

Footnotes

  1. 6 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. ↩

@hai-x
hai-x marked this pull request as ready for review September 29, 2026 07:28
@alexander-akait
alexander-akait merged commit 045d2ab into main Sep 29, 2026
70 checks passed
@alexander-akait
alexander-akait deleted the fix/lazy-barrel-named-and-star-reexport branch September 29, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: optimization Tree-shaking, splitChunks, concatenation, ids (lib/optimize, lib/ids)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants