Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

並び順

ブックマーク数

期間指定

  • から
  • まで

1 - 28 件 / 28件

新着順 人気順

commonjsの検索結果1 - 28 件 / 28件

タグ検索の該当結果が少ないため、タイトル検索結果を表示しています。

commonjsに関するエントリは28件あります。 node.jsjavascriptJavaScript などが関連タグです。 人気エントリには 『Node.js Dual Packages (CommonJS/ES Modules) に対応した npm パッケージの開発 - Cybozu Inside Out | サイボウズエンジニアのブログ』などがあります。
  • Node.js Dual Packages (CommonJS/ES Modules) に対応した npm パッケージの開発 - Cybozu Inside Out | サイボウズエンジニアのブログ

    こんにちは。フロントエンドエキスパートの平野(@shisama_)です。 フロントエンドエキスパートチームでは業務時間の 30 % の時間で技術探究を行っています。 今回は探究した技術の中から Node.js の ES Modules(以下 ESM)についてと Dual Package (CommonJS/ES Modules) に対応した npm パッケージの開発について紹介します。 ES Modules の特徴 ESM はブラウザ互換 ESM は Strict モード ESM は非同期 ESM は静的解析可能 Node.js の ESM 対応について Dual Package(CJS/ESM)に対応した npm パッケージの開発 Conditional Exports によるファイルの指定 .mjs と .cjs require など CJS 特有の機能を使う ESMから CJS ファ

      Node.js Dual Packages (CommonJS/ES Modules) に対応した npm パッケージの開発 - Cybozu Inside Out | サイボウズエンジニアのブログ
    • 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への移行する方法。トップダウンかボトムアップか
      • 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

        • CommonJS is hurting JavaScript

          JavaScript, the undisputed king of web development, is being sabotaged — not by a rival language or a revolutionary new technology, but by its own baggage from the past. This insidious saboteur is none other than CommonJS, the antique module system that we’ve tolerated for far too long. The rise of CommonJS About 15 years after its invention, JavaScript started expanding beyond the browser to the

            CommonJS is hurting JavaScript
          • CommonJSとES Modulesについてまとめる

            モチベーション 普段フロントエンドを領分にしているのになかなかこのあたりの基礎が足りていないと感じることが多いので、なんとかしたい。 ES Modules方式でしか対応されていないライブラリを使おうとしてコケたので色々調べたのも含め、まとめていく。 ちなみにその辺りについてはこの神記事見ると良い。 個人的に気になっているモジュールシステムについて掘り下げていく。 CommonJS CommonJSとは、サーバーサイドなどのウェブブラウザ環境外におけるJavaScriptの各種仕様を定めることを目標としたプロジェクトである。 from Wikipedia 例えばNode.jsで使われている。 Node.jsはデフォルトで全てのモジュールをCommonJSで扱うが、Node.jsは最近のバージョンでES Modulesに対応するなどしていて、潮流はES Modulesに流れつつある。 後述する

              CommonJSとES Modulesについてまとめる
            • import / exportの記法だけではない、CommonJS modulesとES modulesの違い

              本記事はsyumai Advent Calendar 2024 4日目の記事です。 内容としては、主にWeb Developer Conference 2024の休憩中に@NozomuIkutaさんと行った雑談を記事化したものです。 内容に何か問題があれば、本記事のコメント欄や、Xなどでご連絡ください。 require(esm)の登場 2024年、ついにNode.jsのCommonJS modulesから、ES modulesを利用できるようになりました。 使い方は簡単で、これまでCommonJS modulesから別のCommonJS modulesを利用するために使っていた require をそのままES modulesに対して使います。 // ES modules側 (counter.mjs) let count = 0; export const currentCount = ()

                import / exportの記法だけではない、CommonJS modulesとES modulesの違い
              • 7.14.0 Released: New class features enabled by default, TypeScript 4.3, and better CommonJS interop · Babel

                Babel 7.14.0 is out! This release enables class fields and private methods by default (they were promoted to Stage 4 during the recent April TC39 meeting!) and adds brand checks for private fields and static class blocks to @babel/preset-env's shippedProposals option. We added support for Stage 1 async do expressions (using @babel/plugin-proposal-async-do-expressions), which extends the Stage 1 do

                  7.14.0 Released: New class features enabled by default, TypeScript 4.3, and better CommonJS interop · Babel
                • TypeScript 5.8リリース — Node.jsで扱える文法のみに制限する--erasableSyntaxOnlyオプション、CommonJSからのESM読み込みサポートなど改善点多数

                    TypeScript 5.8リリース — Node.jsで扱える文法のみに制限する--erasableSyntaxOnlyオプション、CommonJSからのESM読み込みサポートなど改善点多数
                  • How CommonJS is making your bundles larger  |  Articles  |  web.dev

                    In this post, we'll look into what CommonJS is and why it's making your JavaScript bundles larger than necessary. Summary: To ensure the bundler can successfully optimize your application, avoid depending on CommonJS modules, and use ECMAScript module syntax in your entire application. What's CommonJS? CommonJS is a standard from 2009 that established conventions for JavaScript modules. It was ini

                    • 「なでしこ3」でESM対応JavaScriptライブラリが使用可能に ~v3.2.2がテスト公開/CommonJSからESModuleへ内部構造を変更。IE 11のサポートは打ち切り

                        「なでしこ3」でESM対応JavaScriptライブラリが使用可能に ~v3.2.2がテスト公開/CommonJSからESModuleへ内部構造を変更。IE 11のサポートは打ち切り
                      • よく分からなかったのでCommonJSとTypeScriptのES Modulesinteropについて調べてみた

                        TypeScriptでExpressをちょびちょび弄ってて、Expressをimportする際esModuleinterop関連のエラーに引っかかったので、ついでによく分からなかったCommonJSやesModuleinteropフラグについて自分なりに調べてまとめておきます。 具体的にはtsconfig.jsonを作成しないで node_modules/@types/express/index.d.ts:116:1 116 export = e; This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. // このモジュールは 'export =' で宣言されており、'esModuleInt

                        • JSエコシステムぶらり探訪(2): Node.jsとCommonJS modules - Qiita

                          Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?

                            JSエコシステムぶらり探訪(2): Node.jsとCommonJS modules - Qiita
                          • なぜJavaScriptには2つもモジュールシステムが混在しているのですか?(ES ModulesとCommonJS) · Issue #527 · yytypescript/book

                            これをお読みの皆さんの中には、JavaScriptやTypeScript以外のプログラミング言語を経験したことがある人もいるかと思います。他の言語で、複数のモジュールシステムが共存している言語を使ったことはありますでしょうか。 JavaScriptには、系統が異なるモジュールシステムが、少なくとも2つ存在しています。ESモジュールとCommonJSです。こうした状況は、プログラミング言語としては、珍しいことです。JavaScriptのモジュールまわりを理解するのを難しくしている要因でもあります。 では、どうしてJavaScriptは2系統もモジュールシステムを持つようになったのでしょうか? ここでは、JavaScriptの現状に至る流れを歴史からひも解いていきます。 ひとつめのモジュールシステム JavaScriptのモジュールシステムは、ブラウザよりも先んじて、サーバーサイドJavaSc

                              なぜJavaScriptには2つもモジュールシステムが混在しているのですか?(ES ModulesとCommonJS) · Issue #527 · yytypescript/book
                            • TypeScriptのesModuleinteropフラグを設定してCommonJSモジュールを実行可能とする | DevelopersIO

                              こんにちは、CX事業本部 IoT事業部の若槻です。 今回は、TypeScriptでのCommonJSなモジュールの実行のエラーを、esModuleinteropフラグの設定により回避できたので、書き残しておきます。 事象 snakecase-keysを使ってオブジェクトのキーをスネークケースに変換するスクリプトを作成しました。 import snakecaseKeys from 'snakecase-keys'; const camel = { aaaBbb: 'ccc', dddEdd: 'fff' }; const snake = snakecaseKeys(camel); console.log(snake); しかしこのスクリプトを実行するとエラーとなってしまいます。 $ npx ts-node script.ts Need to install the following pac

                                TypeScriptのesModuleinteropフラグを設定してCommonJSモジュールを実行可能とする | DevelopersIO
                              • GitHub - getify/moduloze: Convert CommonJS (CJS) modules to UMD and ESM formats

                                Moduloze enables authoring JS modules in the CommonJS (CJS) format that's native to the Node.js ecosystem, and converting those modules to Universal Module Definition (UMD) and ES Modules (ESM) formats. UMD is particularly useful in browsers where ESM is not already being used in the application. CJS continues to work fully in all versions of Node, but in the latest Node versions, the ESM format f

                                  GitHub - getify/moduloze: Convert CommonJS (CJS) modules to UMD and ESM formats
                                • GitHub - wessberg/cjstoesm: A tool that can transform CommonJS to ESM

                                  You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                                    GitHub - wessberg/cjstoesm: A tool that can transform CommonJS to ESM
                                  • Node Modules at War: Why CommonJS and ES Modules Can’t Get Along

                                    Dan Fabulich is a Principal Engineer at Redfin. (We’re hiring!) In Node 14, there are now two kinds of scripts: there are old-style CommonJS (CJS) scripts and new-style ESM scripts (aka MJS). CJS scripts use require() and module.exports; ESM scripts use import and export. ESM and CJS are completely different animals. Superficially, ESM looks very similar to CJS, but their implementations couldn’t

                                      Node Modules at War: Why CommonJS and ES Modules Can’t Get Along
                                    • TypeScriptにおいてCommonJSとES Moduleの両方に対応するパッケージを作る - Qiita

                                      はじめに 最近ではNode.jsのライブラリでも、pure ESMの考え方でES Moduleのみでしか利用できないものも出てきている。とはいえ、npm-esm-vs-cjsというリポジトリのデータによると、以下のようにCommonJSのライブラリのほうが圧倒的に多く、ES Moduleのみはまだ10%程度しかない(みたい)。 そこで、今回はライブラリを公開する際に、CommonJSとES Moduleの両方をサポートするようなプロジェクトの設定についてみていきたいと思う。 ※前提として、今回は1つのTypeScriptファイルからCommonJS・ES Moduleの両方に対応するJavaScriptファイルを作成することを考える(ファイル拡張子を".mts"や".cts"にして、コンパイル後のファイル拡張子を変えることでCommonJS・ES Moduleに対応する方法ではない)。その

                                        TypeScriptにおいてCommonJSとES Moduleの両方に対応するパッケージを作る - Qiita
                                      • ESモジュールとCommonJSと対応したTypeScriptパッケージの(たぶん)正しい作り方 - Qiita

                                        先日、JTC-utils という CommonJS と ESM に対応したデュアルパッケージを公開したのですが、とてつもなく苦労したのでここにメモを残しておくことにします。 デュアルパッケージに対応するという記事はいくつかありますが、この記事は次の条件の時に役に立つと思います。 ソースコードは TypeScript で作りたい。 CommonJS と ESモジュールの両方に対応したい。 サブモジュール1を作りたい。(←ここ重要) 何がそんなに難しいのか TypeScript で作成したソースコードを CommonJS と ESモジュールにトランスパイルするため、ひとつのプロジェクト内に3つのソースコードが共存することになります。この時、次の条件が満たされる必要があります。 開発時に JavaScript が TypeScript の型付きで認識されなければならない ビルド時に TypeSc

                                          ESモジュールとCommonJSと対応したTypeScriptパッケージの(たぶん)正しい作り方 - Qiita
                                        • dnt — the easiest way to publish a hybrid npm module for ESM and CommonJS

                                          dnt — the easiest way to publish a hybrid npm module for ESM and CommonJS Though browsers and JavaScript have come a long way, writing and publishing JavaScript modules is still painful. To maximize adoption, your module should support CommonJS and ESM, JavaScript with TypeScript declarations, and work in Deno, Node.js, and web browsers. To achieve that, many resort to complex release pipelines or

                                            dnt — the easiest way to publish a hybrid npm module for ESM and CommonJS
                                          • ES6, CommonJS, AMD, RequireJS, UMD, System.JS, TypeScriptのModule を完全に理解する|kuuubo

                                            ES6, CommonJS, AMD, RequireJS, UMD, System.JS, TypeScriptのModule を完全に理解する JavaScript, TypeScriptを利用していると様々なモジュールシステムに関するワードが出てきます。 AMD, CommonJS, ES6, ES5, Webpack, Babel, RequireJS, UMD,  SystemJS, System.register, module target etc... これらの用語の関係は複雑で混乱しがちな部分です。 この記事は、1つで全てを理解できる決定版を目指して記述しています。 少々長くなりますが、なんども振り返るノートとして利用していただければと思います。 では本題に入ります。 JavaScriptのModuleとは JavaScriptの新しい仕様ECMAScript2015(E

                                              ES6, CommonJS, AMD, RequireJS, UMD, System.JS, TypeScriptのModule を完全に理解する|kuuubo
                                            • GitHub - addaleax/gen-esm-wrapper: Generate ESM wrapper files for CommonJS modules

                                              You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                                                GitHub - addaleax/gen-esm-wrapper: Generate ESM wrapper files for CommonJS modules
                                              • (2023/06)Jest における CommonJS / ECMAScript Modules の扱いについて - Qiita

                                                Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article? 1. 概要 JavaScript における CommonJS(以下、CJS)と ECMAScript Modules(以下、ESM)の問題は色々なところで発生する厄介な問題です。 Jest を使ったテストコードにおいてもこの問題に直面することがあります。 この文章は Jest における CommonJS / ECMAScript Modules の扱いについて包括的な情報提供を目指して書いています。 これを書くにあたって私は様々な情報収集をした他、不明瞭なところは実験サンプルを作って動きをみたり、関連するモジュールの中身を見てみたり、色

                                                  (2023/06)Jest における CommonJS / ECMAScript Modules の扱いについて - Qiita
                                                • CommonJS と ESModules が混在している環境で、lodash を lodash-es に置き換え、バンドルサイズを減らす - Mobile Factory Tech Blog

                                                  こんにちは、21卒エンジニアの id:d-kimuson です。 先日、プロダクトで使用している lodash を lodash-es に置き換えることで、バンドルサイズの削減をしました。 lodash を lodash-es に置き換える話はよくありますが、今回のプロダクトは運用歴が長く CommonJS と ESModules が混在している少し特殊な環境での試みだったので、知見を共有したいと思います。 利用されていないコードを消し、バンドルサイズを減らす lodash はバンドルサイズの大きなライブラリです。minified な状態で 69.9KB のサイズになります。 参考: lodash v4.17.21 ❘ Bundlephobia webpack にはデッドコードを削除する TreeShaking という機能があり、ライブラリのデッドコードを削除することができるのでバンドルサ

                                                    CommonJS と ESModules が混在している環境で、lodash を lodash-es に置き換え、バンドルサイズを減らす - Mobile Factory Tech Blog
                                                  • JSエコシステムぶらり探訪(5): CommonJSモジュールバンドラー - Qiita

                                                    ←前 目次 次→ モジュールバンドラーとは 前3回までで説明したNode.jsのモジュールシステムとnpmのパッケージシステムは、再利用可能なJavaScriptプログラムを作り、配布し、利用する仕組みとして非常によくできたものでした。そのため、このNode.jsのモジュールシステムをブラウザでも利用したいという需要が生じることになりました。正確には以下の2つの需要がありました。 Node.js用に書いたプログラムをブラウザでも再利用したい。 純粋にブラウザ向けのJavaScriptコードでも、モジュールシステムやパッケージシステムを使いたい。 これらの願いを同時に叶えるべく、Browserifyをはじめとしたモジュールバンドラーというツールが開発されました。モジュールバンドラーは複数のJavaScriptモジュールを結合し、ひとつのJavaScriptファイルを生成します。 モジュールバ

                                                      JSエコシステムぶらり探訪(5): CommonJSモジュールバンドラー - Qiita
                                                    • CommonJS の台頭|JS モジュール三國志(from りあクト!)

                                                        CommonJS の台頭|JS モジュール三國志(from りあクト!)
                                                      • How to convert CommonJS to ESM

                                                        ECMAScript modules (”ESM”) are the official, modern way of writing and sharing JavaScript — it’s supported in many environments (e.g. browsers, the edge, and modern runtimes like Deno), and offers a better development experience (e.g. async loading and being able to export without globals). While CommonJS was the standard for many years, supporting CommonJS today is hurting the JavaScript communit

                                                          How to convert CommonJS to ESM
                                                        • CommonJS to ESM in Node.js

                                                          Yesterday, I refactored Place1, which is a non-trivial Node.js app, to use ECMAScript Modules (ESM). Here’s a diff of the full set of changes. This is the approach I took and some of the issues I ran into, in case it helps someone else: Find and replace First off, I started by running the following regular expression2 to quickly convert CommonJS require syntax to ESM import syntax: Find const (.*?

                                                            CommonJS to ESM in Node.js
                                                          1

                                                          新着記事