nodejs / nodejs/node

ESM re-exports from CJS module not included in exports

オープン
#61,989 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

loaders
主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
283

説明

Version

node-v

Platform
Microsoft Windows NT 10.0.26100.0 x64
Subsystem

No response

What steps will reproduce the bug?
// main.mjs
import * as mod from "./mod.js";
console.log(mod);

// mod.js
module.exports = {
  ...require("./other.js")
};

// other.js
export function test() {}
> node main.mjs  
[Module: null prototype] {
  default: { test: [Function: test] },
  'module.exports': { test: [Function: test] }
}
> deno -A --unstable-detect-cjs main.mjs
[Module: null prototype] {
  default: { test: [Function: test] },
  "module.exports": { test: [Function: test] },
  test: [Function: test]
}
How often does it reproduce? Is there a required condition?

Every time.

What is the expected behavior? Why is that the expected behavior?

It should detect the "test" export from the ES module.

What do you see instead?

It's missing.

Additional information

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

node main.mjs を使って main.mjs、mod.js、other.js で問題を再現し、その後、Node の namespace 出力を Deno の例と比較します。Node による CommonJS-to-ESM export の検出を追跡し、other.js の test export が namespace に含まれていることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, nodejs
領域
backend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。