Skip to content

fix(esm): add missing CJS interop runtime requirement - #14978

Merged
LingyuCoder merged 1 commit into
mainfrom
seal/fix-modern-module-cjs-default-interop
Jul 29, 2026
Merged

fix(esm): add missing CJS interop runtime requirement#14978
LingyuCoder merged 1 commit into
mainfrom
seal/fix-modern-module-cjs-default-interop

Conversation

@LingyuCoder

@LingyuCoder LingyuCoder commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix ReferenceError: compatGetDefaultExport is not defined when a modern-module build uses experiments.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_EXPORT with the CommonJS provider module, so the consuming entry could emit compatGetDefaultExport(...) 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_EXPORT when 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 original ReferenceError; with this change, both webpack and Rspack runtime-mode variants pass.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 1a12cac to fix(binding): preserve entry dependency identity (#14964) by harpsealjs

❌ Size increased by 4.00KB from 66.74MB to 66.75MB (⬆️0.01%)

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
popular-libs 1.7 MB 552.1 KB 0 0
react-1k 823.1 KB 217.0 KB 0 0
react-5k 2.7 MB 663.8 KB 0 0
react-10k 5.6 MB 1.3 MB 0 0
ui-components 4.9 MB 1.4 MB 0 0

Generated by Rsdoctor GitHub Action

@codspeed-hq

codspeed-hq Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 46 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing seal/fix-modern-module-cjs-default-interop (1a12cac) with main (a7c0970)

Open in CodSpeed

Footnotes

  1. 47 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.

@LingyuCoder
LingyuCoder force-pushed the seal/fix-modern-module-cjs-default-interop branch from a0ab9d8 to 1a12cac Compare July 29, 2026 03:35
@LingyuCoder LingyuCoder changed the title fix(runtime): fix modern-module runtime mode regressions fix(esm): add missing CJS interop runtime requirement Jul 29, 2026
@LingyuCoder
LingyuCoder marked this pull request as ready for review July 29, 2026 03:38
@hardfist
hardfist self-requested a review July 29, 2026 03:45
@LingyuCoder
LingyuCoder merged commit e6c6e2d into main Jul 29, 2026
58 of 60 checks passed
@LingyuCoder
LingyuCoder deleted the seal/fix-modern-module-cjs-default-interop branch July 29, 2026 06:12
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.

2 participants