タグ

articleとCommonJSに関するefclのブックマーク (4)

  • require(esm) in Node.js

    Recently I landed experimental support for require()-ing synchronous ES modules in Node.js, a feature that has been long overdue. In the pull request, I commented with my understanding about why it did not happen sooner before this pull request in 2024. This post expands on that comment a bit more. The opinions in this post are my own and reflect my perception of the ESM development in Node.js as

    efcl
    efcl 2024/03/19
    Node.jsに実装された`--experimental-require-module`で、CommonJSからESMを`require`できる仕組みについて。 Top-Level awaitの非同期をスコープ外にすることで実装が進んだ
  • CommonJSからES Modulesへの移行する方法。トップダウンかボトムアップか

    Secretlint v7でCommonJS からES Modulesへの移行を行いました。 Secretlint v7.0.0をリリースしました。Pure ESMへの書き直し この記事では、CommonJS(CJS)からES Modules(ESM)への移行を行った経緯と、移行する方法について紹介します。 CJSからESMへの移行は、率直に言えば単調な作業で、メリットが見えにくい作業です。 しかし、将来的にCJSよりもESMが主流になることは間違いないので、移行することは必要です。 移行の作業は、移行方法が決まれば大部分は機械的な書き換えが可能です。 では、実際にどうやって移行したのかを紹介します。 ESMへの移行の影響は依存元へと連鎖する Secretlintのリポジトリはmonorepoになっていて、だいたい40コぐらいのパッケージが含まれています。 そしてパッケージ間で依存関係があ

    CommonJSからES Modulesへの移行する方法。トップダウンかボトムアップか
    efcl
    efcl 2023/07/05
    Node.jsにおけるESMへの移行は、依存関係の読み込み側に影響を与えるため、ボトムアップではなくトップダウンで段階的な移行ができるという話。 依存ツリーの作成や段階的な移行をするための境界線の見つけ方、CJSからESM
  • CommonJS is not going away | Bun Blog

    We're hiring C/C++ and Zig engineers to build the future of JavaScript! Join our team → Some may be surprised to see the recent release notes for Bun mention CommonJS support. After all, CommonJS is a legacy module system, and the future of JavaScript is ES Modules (ESM), right? As a "forward-thinking" "next-gen" runtime, why would Bun put so much effort into improving CommonJS support? The latest

    efcl
    efcl 2023/07/03
    BunがCommonJSをサポートするのはなぜかについて。 CommonJSとECMAScript Moduleを比べると同期と非同期の違いがあるため起動時のロード時間が異なることや、すでに多くのCommonJSモジュールがあるため
  • Ship ESM & CJS in one Package

    [[toc]] ESM & CJS ESM - ECMAScript modules CJS - CommonJS In the past decade, due to the lack of a standard module system of JavaScript, CommonJS (a.k.a the require('xxx') and module.exports syntax) has been the way how Node.js and NPM packages work. Until 2015, when ECMAScript modules finally show up as the standard solution, the community start migrating to native ESM gradually. // CJS const cir

    Ship ESM & CJS in one Package
    efcl
    efcl 2021/11/30
    CommonJSとESMのデュアルフォーマットでのパッケージ公開について。 `package.json`の`exports`フィールドでの使い分け、tsupとunbuildのビルドについて。 ESMでは利用できないCommonJSの`__dirname`などの補完方法について
  • 1