Proposal: Remove ESM/CJS duality from code samples in API docs
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 45/100
- Issue 類型
- 文件
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- javascript
研究方向
檢查 /doc/api 下的範例,並盤點 mjs 和 cjs 程式碼區塊,記錄明確展示 CommonJS 行為的情況。在將符合條件的範例整合到 js 區塊之前,與維護者確認範圍以及預設使用 ESM 的慣例。完成的標準是移除重複範例,同時確保 CJS 特有的示範仍然準確。
由索引模型根據 Issue 內容生成。
描述
Since the introduction of ESM to Node.js core, we have been providing togglable ESM/CJS code examples in the API docs.
These examples differ only in the lines of code containing core imports, but the entire codeblocks need duplicating due to the limitations of the web renderer, leading to whole reams of duplicated cruft across /doc/api. The documentation space is extremely patchy as to which examples are just ESM, just CJS, or both. We occasionally get very kind contributors submitting PRs to double-up existing CJS-only code examples, but these are not good uses of reviewer time.
Almost invariably, it is incredibly obvious as to how to convert an ESM import from a builtin module into a CJS import, or vice versa.
I suggest that we:
- get rid of ```mjs and ```cjs blocks in favour of a single ```js block
- canonicalise ESM imports as the example paradigm of choice, unless a example is specifically demonstrating something CJS-specific
- 主要語言
- JavaScript
- 星號
- 122k
- 分支
- 37.4k
- 平均合併
- 4 天 12 小時
- 30 天內合併 PR
- 296
環境準備
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
nodejs/node 的其他 Issue
-
flaky-test test v26.x
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
doc
難度 1/5 1 小時以內 新手友好度 90/100
維護者通常 1 天內回覆
-
doc
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
-
build
難度 1/5 1 小時以內 新手友好度 88/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 84/100
nodejs/node#65994 · 2 則留言 · 2 個 reaction ·
維護者通常 1 天內回覆
相似的 Issue
-
check:passed logos:add
難度 1/5 1 小時以內 新手友好度 82/100
維護者通常 1 天內回覆
-
component/administration domain/framework needs-triage Platform(Default) priority/low
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 90/100
semantic-release/gitlab#1032 ·
-
agent/guide documentation hive/hosted-available-lke648397-260827-5n31
難度 1/5 1 小時以內 新手友好度 92/100
維護者通常 1 天內回覆
-
agentic-workflows
難度 1/5 1 小時以內 新手友好度 85/100
githubnext/gh-aw-workshop#3933 ·
維護者通常 2 天內回覆