Missing documentation for exports alternative paths
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.3k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 283
説明
Affected URL(s)
https://nodejs.org/api/packages.html
Description of the problem
Packages documentation is really helpful to understand motivations and practical usage of exports, from the simplest setup to nested conditions, wildcards, etc. However, it seems to lack a description and examples of "alternative paths" within exports, which I think is really powerful stuff, but currently underrated and not very popular (maybe because of the lack in documentation).
With "alternative paths" what I mean is using arrays as follows:
{
"exports": {
".": {
"development": {
"types": "./src/index.ts",
"import": "./src/index.js",
"require": "./src/index.cjs",
"default": "./src/index.cjs"
},
"import": {
"types": "./types/index.d.ts",
"default": [
"./src/index.js",
"./esm/index.js"
]
},
"require": [
"./src/index.cjs",
"./cjs/index.cjs"
],
"default": [
"./src/index.cjs",
"./cjs/index.cjs"
]
}
}
}
The only hint I found in the documentation, is string[] syntax under exports.
Beside that, there are some mentions around:
- Webpack's official docs citing Node.js behaviour: https://webpack.js.org/guides/package-exports/#alternatives.
- Notable TypeScript issue requesting aligning to Node.js behaviour: https://github.com/nodejs/node/issues/37928
I think that "alternative paths" is the perfect solution for situations like using your own package without having to build it first during development (e.g., TypeScript, transpiling, polyfilling, etc.)
If there is a spec I would love to update the docs myself.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
nodejs.org/api/packages.html のパッケージドキュメントにある「exports」セクションから始め、代替パスの動作について、リンクされている Webpack および TypeScript のリファレンスを確認してください。配列値のエクスポートパスについての説明と実用的な例を追加し、例がいつ適用されるのかをドキュメントで明確に説明してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, nodejs
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 65/100