[PR #519] [MERGED] fix(replay): preserve CommonJS object as ESM default export #2045

Closed
opened 2026-10-16 21:13:41 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/519
Author: @rudycelekli
Created: 10/5/2026
Status: ✅ Merged
Merged: 10/5/2026
Merged by: @morluto

Base: main ← Head: fix/replay-commonjs-default-20261004


📝 Commits (2)

  • cc5c211 fix(replay): preserve CommonJS object as ESM default export
  • 2db74fa Merge origin/main into fix/replay-commonjs-default-20261004

📊 Changes

2 files changed (+106 additions, -4 deletions)

View changed files

📝 src/replay/JavaScriptReplayWorker.ts (+1 -1)
📝 tests/boundary/providers/replay/javascriptReplayWorker.test.ts (+105 -3)

📄 Description

Change

Summary

Keep the whole module.exports value as the default export when a selected ESM replay module imports a CommonJS factory. Skip the object's own default property while adding named exports to the synthetic namespace.

The namespace initially sets its default to module.exports, but then overwrites that export with module.exports.default. A CommonJS object carrying an ordinary default property therefore reaches the ESM consumer as that property's string/function value instead of the object. This changes selected-module observations.

Verification

  • Compare against actual pinned Node imports of owned temporary .cjs files for both __esModule false and true; before 2 failed / 12 passed, after 14 passed through the compiled production worker.
  • Existing Rspack require.n behavior and direct CommonJS factory default-export selection remain unchanged and tested.
  • Pinned build, TypeScript and official repository lint pass.
  • Full repository/package gates recorded separately before publication.

The Node CommonJS namespace contract assigns default to module.exports. This verifies the disposable worker and native Node import boundary, not Linux Bubblewrap/systemd or original-application behavior.

Reproduction and verification

2 failed/12 passed

  • npm run check:pr: passed (Test Files 352 passed (352); Tests 1803 passed | 2 skipped (1805)).
  • npm run check:ci: passed.
  • npm run verify:package: passed installed-tarball CLI/MCP verification, including optional-dependency degradation.
  • npm pack --dry-run: passed.
  • Exact lockfile installation on Node 24.18.0 and npm 11.16.0.

These tests exercise the production seams described above. No real Hopper, Ghidra, desktop browser or Linux sandbox end-to-end verification is claimed.

Prepared with AI assistance; the reproductions and verification commands above were executed locally.

Matching Linux replay lane

The unchanged upstream real-javascript-replay.yml workflow was dispatched on the exact signed head in the fork: run 37264859238. It completed successfully with the upstream REA_REPLAY_ALLOW_UNAVAILABLE=true setting, but its verifier payload was available:false, AnalysisCapabilityUnavailableError. This is a degraded prerequisite result, not positive Linux sandbox execution verification. The failing-before/passing-after compiled worker regressions above remain separate evidence; no Linux sandbox end-to-end proof is claimed.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/519 **Author:** [@rudycelekli](https://github.com/rudycelekli) **Created:** 10/5/2026 **Status:** ✅ Merged **Merged:** 10/5/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/replay-commonjs-default-20261004` --- ### 📝 Commits (2) - [`cc5c211`](https://github.com/morluto/rea/commit/cc5c211268c70930f0a342b953aff009733aea3d) fix(replay): preserve CommonJS object as ESM default export - [`2db74fa`](https://github.com/morluto/rea/commit/2db74fabfb2667d934d2f675604e78c7ae6ac472) Merge origin/main into fix/replay-commonjs-default-20261004 ### 📊 Changes **2 files changed** (+106 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/replay/JavaScriptReplayWorker.ts` (+1 -1) 📝 `tests/boundary/providers/replay/javascriptReplayWorker.test.ts` (+105 -3) </details> ### 📄 Description ## Change ## Summary Keep the whole `module.exports` value as the default export when a selected ESM replay module imports a CommonJS factory. Skip the object's own `default` property while adding named exports to the synthetic namespace. The namespace initially sets its default to module.exports, but then overwrites that export with module.exports.default. A CommonJS object carrying an ordinary default property therefore reaches the ESM consumer as that property's string/function value instead of the object. This changes selected-module observations. ## Verification - Compare against actual pinned Node imports of owned temporary `.cjs` files for both __esModule false and true; before 2 failed / 12 passed, after 14 passed through the compiled production worker. - Existing Rspack require.n behavior and direct CommonJS factory default-export selection remain unchanged and tested. - Pinned build, TypeScript and official repository lint pass. - Full repository/package gates recorded separately before publication. The [Node CommonJS namespace contract](https://nodejs.org/api/esm.html#commonjs-namespaces) assigns default to module.exports. This verifies the disposable worker and native Node import boundary, not Linux Bubblewrap/systemd or original-application behavior. ## Reproduction and verification 2 failed/12 passed - `npm run check:pr`: passed (Test Files 352 passed (352); Tests 1803 passed | 2 skipped (1805)). - `npm run check:ci`: passed. - `npm run verify:package`: passed installed-tarball CLI/MCP verification, including optional-dependency degradation. - `npm pack --dry-run`: passed. - Exact lockfile installation on Node 24.18.0 and npm 11.16.0. These tests exercise the production seams described above. No real Hopper, Ghidra, desktop browser or Linux sandbox end-to-end verification is claimed. Prepared with AI assistance; the reproductions and verification commands above were executed locally. ## Matching Linux replay lane The unchanged upstream `real-javascript-replay.yml` workflow was dispatched on the exact signed head in the fork: [run 37264859238](https://github.com/rudycelekli/rea/actions/runs/37264859238). It completed successfully with the upstream `REA_REPLAY_ALLOW_UNAVAILABLE=true` setting, but its verifier payload was `available:false`, `AnalysisCapabilityUnavailableError`. This is a degraded prerequisite result, **not positive Linux sandbox execution verification**. The failing-before/passing-after compiled worker regressions above remain separate evidence; no Linux sandbox end-to-end proof is claimed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-16 21:13:41 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2045
No description provided.