fix(esm): add missing CJS interop runtime requirement - #14978
Merged
Conversation
Contributor
📦 Binary Size-limit
❌ Size increased by 4.00KB from 66.74MB to 66.75MB (⬆️0.01%) |
Contributor
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
Contributor
Merging this PR will not alter performance
Comparing Footnotes
|
LingyuCoder
force-pushed
the
seal/fix-modern-module-cjs-default-interop
branch
from
July 29, 2026 03:35
a0ab9d8 to
1a12cac
Compare
LingyuCoder
marked this pull request as ready for review
July 29, 2026 03:38
hardfist
self-requested a review
July 29, 2026 03:45
JSerFeng
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
ReferenceError: compatGetDefaultExport is not definedwhen a modern-module build usesexperiments.runtimeMode: "rspack", multiple entries, and re-exports a CommonJS default export across chunks.Root cause
The ESM linker records the generated CommonJS default interop access on the consuming chunk. The existing module-level runtime-requirements hook only associated
COMPAT_GET_DEFAULT_EXPORTwith the CommonJS provider module, so the consuming entry could emitcompatGetDefaultExport(...)without importing the helper from the shared runtime chunk.Solution
During additional chunk runtime-requirements collection, inspect that chunk's linked external interop records and add
COMPAT_GET_DEFAULT_EXPORTwhen a default interop access is present. Existing runtime-requirement processing then adds the helper and its dependencies to the runtime chunk and emits the required named import.Tests
Added a focused multi-entry ESM output case. On
main, the runtime-mode variant fails with the originalReferenceError; with this change, both webpack and Rspack runtime-mode variants pass.