並び順

ブックマーク数

期間指定

  • から
  • まで

1 - 32 件 / 32件

新着順 人気順

CommonJSの検索結果1 - 32 件 / 32件

  • 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 v7CommonJS ES Modules Secretlint v7.0.0Pure ESM CommonJS(CJS)ES Modules(ESM) CJSESM調 CJSESM   ESM Secretlintmonorepo40 
        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, ES Modules, UMD)をサポートしたnpmパッケージの作り方 in TypeScript - dackdive's blog


           npm  Node.js CommonJS  (module.exports / require() ) webpackRollup CommonJS  ES Modules  (export / import ) 使<script> UMD   TypeScript 
            複数のモジュール形式(CommonJS, ES Modules, UMD)をサポートしたnpmパッケージの作り方 in TypeScript - dackdive's blog
          • 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 CommonJSAbout 15 years after its invention, JavaScript started expanding beyond the browser to the s

              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についてまとめる
              • Hybrid npm packages (ESM and CommonJS)

                Warning: This blog post is outdated. It may contain incorrect information. Update 2019-11-22: ESM support in Node.js is not experimental, anymore. This post was updated to reflect that. Conditional exports are now explained. In this blog post, we look at npm packages that contain both ES modules and CommonJS modules. Required knowledge: How ES modules are supported natively on Node.js. You can rea

                • 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
                  • How CommonJS is making your bundles larger  |  Articles  |  web.dev

                    How CommonJS is making your bundles larger Stay organized with collections Save and categorize content based on your preferences. 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 ent

                    • よく分からなかったので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

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

                          「なでしこ3」でESM対応JavaScriptライブラリが使用可能に ~v3.2.2がテスト公開/CommonJSからESModuleへ内部構造を変更。IE 11のサポートは打ち切り
                        • JSエコシステムぶらり探訪(2): Node.jsとCommonJS modules - Qiita

                          JSエコシステムの進化を語るにはNode.jsを避けて通ることはできません。Node.jsと、それ自身の持つモジュール機能について歴史的な背景を踏まえつつ説明します。 ←前 目次 次→ Node.jsは非同期I/Oを備えたサーバーサイドJavaScriptのための実行環境として2009年に登場しました。1 現在はサーバーサイドJavaScriptだけではなく、JavaScriptのビルド環境として無くてはならないものになっています。 要するにNode.jsは、PerlスクリプトやRubyスクリプトと同じようにJavaScriptのコードを実行するための環境です。

                            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を使ってオブジェクトのキーをスネークケースに変換するスクリプトを作成しました。 script.ts 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 fol

                                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

                                  This is a tool that converts CommonJS modules into tree-shakeable ES Modules. This allows you to not only bundle CommonJS modules for the browser, but also makes it possible for you to bundle them in modern tools such as Rollup. It can also be used as a tool for migrating a CommonJS-based codebase to one based on ES-modules via a simple CLI. cjstoesm can be used from the Command Line, as a JavaScr

                                    GitHub - wessberg/cjstoesm: A tool that can transform CommonJS to ESM
                                  • Rollup なぜrollup-plugin-commonjs、rollup-plugin-node-resolveプラグインが必要なのか | nansystem

                                    Rollupで複数のファイルを1つにまとめる際にrollup-plugin-commonjs、rollup-plugin-node-resolveプラグインが使われる。この2つのプラグインはいったいどんな役割があるのだろうか。Rollupの概要をおさえた上で、環境をつくり動きを確認していく。 # Rollupとは Rollupとは、モジュールバンドラ(module bundler)だ。 モジュール(module)は機能ごとに分割されたファイルのことで、バンドラ(bundler)はそれらのモジュールをまとめることだ。RollupはES2015(ES6)をベースにしている。つまり、特に設定しなくてもimport、export文をつかって複数ファイルを1ファイルにまとめることができる。 # Rollupのインストール さっそくRollupが動く環境を準備していく。 package.jsonを用意

                                    • 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を作りたい。(←ここ重要) 2023/07/18 コメントを受け、一部訂正をいれています。 2023/07/19 さらに調べたところ、TypeScript の公式見解としては、たとえ型宣言ファイル(.d.ts)の内容が同じであっても、.cjs に対しては .d.cts を用意すべきとのことでしたので、その前提に基づき記述を全面的に見直しました。 何がそんなに難しいのか TypeScript

                                            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
                                            • 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
                                              • 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
                                                • JSモジュール化するしくみの規格はCommonJS、AMD、UMD、ES6(ES2015)の4つ - やってみる

                                                  複雑すぎる。 参考 https://tsuchikazu.net/javascript-module/ Modular JavaScript , CommonJs, AMD, UMD について – Supertrue 前回 http://ytyaru.hatenablog.com/entry/2019/03/25/000000 JSモジュール化する規格とその実装 規格 実装 形態 CommonJS browserify Node.js npm モジュール AMD require JSライブラリ UMD umd Node.js npm モジュール? ES2015 import、トランスパイラ(Babel) 言語仕様(構文) 何が違う? AMD define(['jquery'] , function ($) { return function () {}; }); 以下のように書くこともでき

                                                    JSモジュール化するしくみの規格はCommonJS、AMD、UMD、ES6(ES2015)の4つ - やってみる
                                                  • 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


                                                          3Node.jsnpmJavaScriptNode.js2 Node.js JavaScript使 BrowserifyJavaScriptJavaScript 
                                                        JSエコシステムぶらり探訪(5): CommonJSモジュールバンドラー - Qiita
                                                      • Introduction to CommonJS

                                                        Introduction to CommonJSJun 14, 2018→ Download my free JavaScript Handbook! The CommonJS module specification is the standard used in Node.js for working with modules. Client-side JavaScript that runs in the browser uses another standard, called ES Modules Modules are very cool, because they let you encapsulate all sorts of functionality, and expose this functionality to other JavaScript files, as

                                                          Introduction to CommonJS
                                                        • tsconfigのmoduleの設定値の違い: commonjs, amd, system, umd, es6, es2015, esnext, none - Qiita

                                                          本稿では、tsconfigのmoduleの設定値によってどのようなJavaScriptコードが生成されるかを確認するものである。次の設定値を試す: commonjs, amd, system, umd, es6, es2015, esnext, none。 コンパイルしてみるTypeScriptコード。

                                                            tsconfigのmoduleの設定値の違い: commonjs, amd, system, umd, es6, es2015, esnext, none - Qiita
                                                          • CommonJS の台頭|JS モジュール三國志(from りあクト!)

                                                              CommonJS の台頭|JS モジュール三國志(from りあクト!)
                                                            • CommonJS - Wikipedia

                                                              CommonJSとは、サーバーサイドなどのウェブブラウザ環境外におけるJavaScriptの各種仕様を定めることを目標としたプロジェクトである。 歴史[編集] CommonJSプロジェクトは元々、2009年1月にMozillaのエンジニアKevin DangoorによりServerJSプロジェクトとして立ち上げられた[1]。 What I’m describing here is not a technical problem. It’s a matter of people getting together and making a decision to step forward and start building up something bigger and cooler together. 2009年8月、プロジェクトはより広い範囲のAPIを対象とすることを示すために、現在のC

                                                              • 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
                                                                • (2023/06)Jest における CommonJS / ECMAScript Modules の扱いについて - Qiita

                                                                  1. 概要 JavaScript における CommonJS(以下、CJS)と ECMAScript Modules(以下、ESM)の問題は色々なところで発生する厄介な問題です。 Jest を使ったテストコードにおいてもこの問題に直面することがあります。 この文章は Jest における CommonJS / ECMAScript Modules の扱いについて包括的な情報提供を目指して書いています。 これを書くにあたって私は様々な情報収集をした他、不明瞭なところは実験サンプルを作って動きをみたり、関連するモジュールの中身を見てみたり、色々なことをしています。 正確な記載を心掛けますが、間違いを発見した場合は遠慮なく指摘をしてください。しかし、Node.js の世界は進歩が速いので受けた指摘をこの文章に反映するかどうかはわからないことを予め申し上げておきます。 基本的にはこの文章は執筆時点の

                                                                    (2023/06)Jest における CommonJS / ECMAScript Modules の扱いについて - Qiita
                                                                  1