[PR #2234] [CLOSED] fix(javascript): collect exports through renamed bundler exports parameters #5103

Closed
opened 2026-10-31 01:03:57 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2234
Author: @chqcjq
Created: 10/12/2026
Status: ❌ Closed

Base: main ← Head: fix/webpack-renamed-exports-clean


📝 Commits (1)

  • 5d4ec0a fix(javascript): collect exports through renamed bundler exports parameters

📊 Changes

4 files changed (+62 additions, -6 deletions)

View changed files

📝 src/domain/javascript/javascriptAstFingerprint.ts (+21 -5)
📝 src/domain/javascript/javascriptStaticAnalysis.member_path_depth.test.ts (+28 -0)
📝 src/domain/javascript/javascriptStaticAnalysisBundler.ts (+5 -1)
📝 src/domain/javascript/javascriptStaticAnalysisHelpers.ts (+8 -0)

📄 Description

Fixes #2171.

Problem

Webpack/Rspack chunk module factories that bind the exports object to a renamed second parameter (e.g. __webpack_exports__ or e) produce empty exports metadata. The equivalent factory using the parameter name exports returns the names correctly.

Root cause

collectJavaScriptExports (javascriptAstFingerprint.ts) only recognized exports and module.exports as export targets. When a bundler factory renames the exports parameter (e.g. function(m, e, r) { r.d(e, { ... }) }), the __webpack_require__.d(e, ...) call is not recognized as an export declaration because e does not match the hard-coded exports identifier.

Fix

  • collectJavaScriptExports now accepts an optional exportsName parameter.
  • The bundler module recovery passes the factory's second parameter name (via the new factoryExportsName helper) so renamed exports objects are recognized.
  • Both assignment exports (e.alpha = 1) and call exports (r.d(e, { ... }) / Object.defineProperty(e, ...)) are covered.

Verification

  • Issue reproduction fixture: modules 1 (__webpack_exports__), 2 (e), and 4 (Object.defineProperty on __webpack_exports__) now report their export names correctly. Module 6 (exports to an unrelated object) correctly remains empty.
  • New regression test covers all five parameter-name variants.
  • All 1,147 JavaScript domain tests pass.
  • npm run check, docs:check, and verify:test-discovery (923 files) all pass.

🔄 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/2234 **Author:** [@chqcjq](https://github.com/chqcjq) **Created:** 10/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/webpack-renamed-exports-clean` --- ### 📝 Commits (1) - [`5d4ec0a`](https://github.com/morluto/rea/commit/5d4ec0a404abcdaafdebf9c99b48e7be958a9b02) fix(javascript): collect exports through renamed bundler exports parameters ### 📊 Changes **4 files changed** (+62 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/javascript/javascriptAstFingerprint.ts` (+21 -5) 📝 `src/domain/javascript/javascriptStaticAnalysis.member_path_depth.test.ts` (+28 -0) 📝 `src/domain/javascript/javascriptStaticAnalysisBundler.ts` (+5 -1) 📝 `src/domain/javascript/javascriptStaticAnalysisHelpers.ts` (+8 -0) </details> ### 📄 Description Fixes #2171. ## Problem Webpack/Rspack chunk module factories that bind the exports object to a renamed second parameter (e.g. `__webpack_exports__` or `e`) produce empty `exports` metadata. The equivalent factory using the parameter name `exports` returns the names correctly. ## Root cause `collectJavaScriptExports` (`javascriptAstFingerprint.ts`) only recognized `exports` and `module.exports` as export targets. When a bundler factory renames the exports parameter (e.g. `function(m, e, r) { r.d(e, { ... }) }`), the `__webpack_require__.d(e, ...)` call is not recognized as an export declaration because `e` does not match the hard-coded `exports` identifier. ## Fix - `collectJavaScriptExports` now accepts an optional `exportsName` parameter. - The bundler module recovery passes the factory's second parameter name (via the new `factoryExportsName` helper) so renamed exports objects are recognized. - Both assignment exports (`e.alpha = 1`) and call exports (`r.d(e, { ... })` / `Object.defineProperty(e, ...)`) are covered. ## Verification - Issue reproduction fixture: modules 1 (`__webpack_exports__`), 2 (`e`), and 4 (`Object.defineProperty` on `__webpack_exports__`) now report their export names correctly. Module 6 (exports to an unrelated object) correctly remains empty. - New regression test covers all five parameter-name variants. - All 1,147 JavaScript domain tests pass. - `npm run check`, `docs:check`, and `verify:test-discovery` (923 files) all pass. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:03:57 +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#5103
No description provided.