Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Proposal: Remove ESM/CJS duality from code samples in API docs

未關閉
#65,536 3 則留言 18 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
45/100
Issue 類型
文件
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
javascript
領域
documentation

研究方向

檢查 /doc/api 下的範例,並盤點 mjs 和 cjs 程式碼區塊,記錄明確展示 CommonJS 行為的情況。在將符合條件的範例整合到 js 區塊之前,與維護者確認範圍以及預設使用 ESM 的慣例。完成的標準是移除重複範例,同時確保 CJS 特有的示範仍然準確。

由索引模型根據 Issue 內容生成。

描述

discuss doc

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

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

nodejs/node 的其他 Issue

查看 nodejs/node 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。