ESM build cannot be imported in Node.js: `dist/` emits extensionless relative specifiers
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, typescript
- 領域
- build-system
調査の方向性
ESM出力はtsconfig.build.jsonによって生成され、このファイルではmoduleがESNext、moduleResolutionがbundlerに設定されているため、./apiのような相対インポートはdist/*.jsで拡張子なしのままになります。まずこの設定とpackage.jsonのビルドスクリプトを読んでください。その後、ビルドを実行してnodeでdist/index.jsをインポートし、問題を再現してください。ESMのdistがERR_MODULE_NOT_FOUNDなしでNode上で読み込まれ、CJS出力も引き続き動作すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Importing @craftycodie/cstruct in a Node.js ES module fails at load time with ERR_MODULE_NOT_FOUND, whereas require("@craftycodie/cstruct") works via dist-cjs/index.js.
npm init -y && npm install @craftycodie/[email protected]
node --input-type=module -e 'import { c } from "@craftycodie/cstruct"; console.log(c.sizeof(c.struct({ x: c.u8() })));'
Actual output:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.../node_modules/@craftycodie/cstruct/dist/api' imported from .../node_modules/@craftycodie/cstruct/dist/index.js
Expected output:
1
tsconfig.build.json compiles the ESM output with "module": "ESNext" and "moduleResolution": "bundler", so tsc preserves extensionless relative and directory specifiers (such as "./api" and "./field-types") in dist/*.js, which Node's ESM resolver rejects.
Versions tested: @craftycodie/[email protected] and main (9421e72), Node.js v26.13.0.
Credit: https://ucsbplse.github.io/
- 主要言語
- TypeScript
- スター
- 4
- フォーク
- 0
- 平均マージ
- 21日 8時間
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
似ている issue
-
[analytics-core] getQueryParams does not decode `+` as space and truncates values containing `=`オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
amplitude/Amplitude-TypeScript#2179 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
ci good first issue severity: low
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
TMHSDigital/GH-Arcade#111 ·
-
AsnIntegerConverter.toASN coerces strings with +value, rounding integers outside safe-integer rangeオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
PeculiarVentures/asn1-schema#189 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100