並び順

ブックマーク数

期間指定

  • から
  • まで

1 - 21 件 / 21件

新着順 人気順

"ES Modules"の検索結果1 - 21 件 / 21件

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

"ES Modules"に関するエントリは21件あります。 node.jstechfeedjavascript などが関連タグです。 人気エントリには 『CommonJSからES Modulesへの移行する方法。トップダウンかボトムアップか』などがあります。
  • 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への移行する方法。トップダウンかボトムアップか
    • 最近のTypeScriptのES Modules対応事情

      ブックマークサービスQiNeel関連の記事や身の回りのよしなしごとをそこはかとなく書きつくっています。 コロナの影響で中止となった幻のTSConf 2020で、TypeScriptとES Modulesについて登壇する予定でした。 最近のTypeScriptは、モジュール関連で新たな仕様が出てきたようなので簡単にまとめておきます。前職同僚でNode.js Core Collaboratorのshisamaおよびdeno-ja Slackコミュニティーからの情報を勝手に集約しました。みなさんありがとうございます。 背景 JavaScript同様、TypeScriptでもimport構文(ES Modules)をサポートしています。しかし、ES ModulesではCommonJS形式のrequire()と異なり拡張子を省略できないという制約があります。 フロントエンド開発では、ほとんどの場合で

      • How to Use ES Modules in Node.js

        Starting version 13.2.0, Node.js has stable support of ES modules. In this post, you'll learn how to enable and use ES modules in Node.js. 1. Enabling ECMAScript modules in Node.js The default format of modules in Node.js is the CommonJS. But Node.js will treat a JavaScript file as an ECMAScript modules format if: The module's file extension is .mjs Or the module's nearest parent folder has { "typ

          How to Use ES Modules in Node.js
        • AWS LambdaがES Modulesをサポート開始

          Amazon Web Services(AWS)は、サーバレスコンピューティング基盤として提供しているAWS Lambdaで、Node.js 14のランタイムにおいてJavaScriptのモジュール機能であるES Modulesのサポートを開始したことを発表しました。 AWS Lambda now supports ES Modules and Top-Level Await for Node.js 14 AWS Lambda functions using the Node.js 14 runtime now support code packaged as ECMAScript modules, allowing Lambda customers to consume a wider range of JavaScript packages in th... https://t.co/

            AWS LambdaがES Modulesをサポート開始
          • Node.jsのネイティブES Modulesサポートが抱える問題を解決するBabelプラグインを書いた

            babel-plugin-node-cjs-interop というパッケージを作ったのでその紹介です。 (GitHub) 何が問題か Node.jsのネイティブES ModulesサポートとBabelやTypeScriptのES Modulesサポートを併用したときに問題が起きます。 ESMとCJS JavaScriptには標準のモジュールシステム (ES Modules, ESM) がありますが、ESMの策定前に先だっていくつかのコミュニティー定義のモジュールシステムが存在していました。そのうちNode.jsを中心として使われていたのがCommonJS Modules (CJS) です。そのNode.js界隈でもESMへの移行が進んでいます。 移行にあたって問題になることのひとつが、ESMとCJSのエクスポートモデルの違いです。 ESMでは、モジュールは0個以上の名前つきエクスポートを定

              Node.jsのネイティブES Modulesサポートが抱える問題を解決するBabelプラグインを書いた
            • 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の違い
                • 「ES Modules仕様、わけわからんくなってる」を整理する「Module Harmony」とは?

                  本記事は、TechFeed Experts Night#31 〜 フロントエンドアーキテクチャの現状と未来のセッション書き起こし記事になります。 イベントページのタイムテーブルから、その他のセッションに関する記事もお読み頂けますので、一度アクセスしてみてください。 本セッションの登壇者 セッション動画 「Module Harmonyについて」ということで発表を始めさせていただきます。「フロントエンドアーキテクチャーの現状と未来」というイベントタイトルからは少し外れますが、モジュールと言われるJavaScriptの1つの仕様の中で、こういうことが起きてるんだよという、少し角度を変えた話をさせていただければと思います。

                    「ES Modules仕様、わけわからんくなってる」を整理する「Module Harmony」とは?
                  • ES Modules are terrible, actually

                    es-modules-are-terrible-actually.md ES Modules are terrible, actually This post was adapted from an earlier Twitter thread. It's incredible how many collective developer hours have been wasted on pushing through the turd that is ES Modules (often mistakenly called "ES6 Modules"). Causing a big ecosystem divide and massive tooling support issues, for... well, no reason, really. There are no actual

                      ES Modules are terrible, actually
                    • ES modules in service workers  |  Articles  |  web.dev

                      Background ES modules have been a developer favorite for a while now. In addition to a number of other benefits, they offer the promise of a universal module format where shared code can be released once and run in browsers and in alternative runtimes like Node.js. While all modern browsers offer some ES module support, they don't all offer support everywhere that code can be run. Specifically, su

                      • なぜ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
                        • Using Node.js ES modules and top-level await in AWS Lambda | Amazon Web Services

                          AWS Compute Blog Using Node.js ES modules and top-level await in AWS Lambda This post is written by Dan Fox, Principal Specialist Solutions Architect, Serverless. AWS Lambda now enables the use of ECMAScript (ES) modules in Node.js 14 runtimes. This feature allows Lambda customers to use dependency libraries that are configured as ES modules, or to designate their own function code as an ES module

                            Using Node.js ES modules and top-level await in AWS Lambda | Amazon Web Services
                          • How to import JSON files in ES modules (Node.js)

                            The post was initially released in May 2021 when importing JSON in ECMAScript modules wasn't a straightforward task. I've kept this post up to date and am happy to say that we can mark the problem of importing JSON in Node.js modules as solved! After quite a bit of back and forth, the current Node.js LTS (currently v22) and future Node.js versions support JSON modules by using the JavaScript-nativ

                              How to import JSON files in ES modules (Node.js)
                            • Import JSON in ES modules

                              2 min read This blog post is part of What’s new in Node.js core? March 2022 edition. We’ve had really good ECMAScript (ES) module support in Node.js for a while, but up until now we’ve had to do messy little workarounds to import JSON files. The background on why is a blog post in itself, but the good news is that we can now import JSON modules in Node.js without an experimental flag. This recentl

                                Import JSON in ES modules
                              • Alternatives to __dirname in Node.js with ES modules - LogRocket Blog

                                So, you’ve listened to all the advice and sat down to migrate your code or learn a new standard, but you have questions. ES modules (also known as ESM) are here, but using them is not quite as simple as migrating all your require() expressions into import statements. ES modules were added to Node in Node 13, about the end of 2019. And Node 12—the last version without ESM—is set for “end of life” i

                                  Alternatives to __dirname in Node.js with ES modules - LogRocket Blog
                                • CommonJS と ES Modules の違い 🚀 - Qiita

                                  Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article? JavaScriptの世界には、モジュールを扱うための2つの主要なシステムがあります。それが「CommonJS」と「ESモジュール(ECMAScript Modules)」です。どちらもコードを分割し、再利用可能にするための仕組みですが、いくつか重要な違いがあります。 📚 モジュールとは? モジュールとは、特定の機能やデータを持つ独立したコードの単位のことです。モジュールにすることで、コードの可読性や保守性が向上し、大規模なアプリケーション開発がしやすくなります。🚀 🌟 CommonJS モジュール CommonJSは、主にNod

                                    CommonJS と ES Modules の違い 🚀 - Qiita
                                  • Migrate from Service Workers to ES Modules

                                    This guide will show you how to migrate your Workers from the Service Worker ↗ format to the ES modules ↗ format. There are several reasons to migrate your Workers to the ES modules format: Your Worker will run faster. With service workers, bindings are exposed as globals. This means that for every request, the Workers runtime must create a new JavaScript execution context, which adds overhead and

                                      Migrate from Service Workers to ES Modules
                                    • 2022年度のTypeScript製ES Modulesレシピ - Qiita

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

                                        2022年度のTypeScript製ES Modulesレシピ - Qiita
                                      • Google Apps Script の Web アプリで CORS 制約を回避して Web Woker や ES Modules を使う

                                        <!-- 前略 --> <script type="module"> import { module } from "https://xxx/module.js" cosnt worker = new Worker( "https://xxx/worker.js" ) </script> <!-- 後略 --> 開発コンソールで確認してみると「CORS」や「SOP」といった文言のエラーメッセージが出ていると思います。 CORSはオリジン間リソース共有、SOPは同一生成元ポリシーのことで、ざっくり言うと「他のWebサイトから持ってきてはいけない」というエラーです。 つまり、他所から持って来ていないように見せれば解決します。 失敗例 ContentServiceを使ってみる 同じ失敗をしないため、まずは失敗例の紹介から。 GASにはHTMLを表示するHtmlServiceに対してプレーンテキス

                                          Google Apps Script の Web アプリで CORS 制約を回避して Web Woker や ES Modules を使う
                                        • TypeScript: JestでES Modulesは問題なくテストできるのか?

                                          TypeScript + Node.js + ESM + Jestの組み合わせを調査する。 調査すること ES Modulesをts-jestで問題なく実行できるか? 実験コード 実験のために書いたコードはGitHubに置いてある suinplayground/typescript-nodejs-esm-jest

                                            TypeScript: JestでES Modulesは問題なくテストできるのか?
                                          • __dirname, __filename を ES Modules で使う方法

                                            const __dirname = import.meta.dirname; const __filename = import.meta.filename; const __dirname = import.meta.dir; const __filename = import.meta.path; // or const __dirname = import.meta.dirname; const __filename = import.meta.filename; import.meta.file はファイル名であり、ファイルへのパスではないので注意が必要です。 次のPRでv1.0.23からNode.jsとの互換性のため、dirname と filename もエイリアスとして追加されました。 個人的には、import.meta.filename と import.meta.file

                                              __dirname, __filename を ES Modules で使う方法
                                            1

                                            新着記事