本文へスキップ
Skillpedia
一般的なプログラミング75k · #2836

es-modules

できること

このスキルは、古いモジュールの構文を使う JavaScript のファイルを確認し、現在の標準を提案します。より軽く、分かりやすいコードがほしい開発者向けです。

使う場面

  • ✓JavaScript のファイルがまだ require() や module.exports を使っているとき。
  • ✓バンドルに、使っていないコードが含まれているとき。
  • ✓スクリプトをネイティブのブラウザのモジュールとして読み込みたいとき。

スキルのリンク

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/es-modules/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/es-modules/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“JavaScript ファイルの require 文を、import の構文に変換してもらえますか。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、require と module.exports の行を見つけ、対応する import と export の文を提案します。合う場合は、名前付きの export も推奨します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Use ES modules (import/export)

ES modules are statically analyzable — bundlers can determine at build time what code is actually used and eliminate the rest (tree-shaking). CommonJS require() is dynamic and prevents this optimization. ES modules are also the browser-native standard, reducing the need for build-time transformation.

Quick Reference

  • Use import/export syntax instead of require()/module.exports
  • Named exports improve IDE autocompletion and enable tree-shaking
  • Add type="module" to script tags or use a bundler to load ES modules in browsers
  • Default exports are fine but named exports scale better in large codebases

Check

Identify any use of require(), module.exports, or exports in this JavaScript file that should be converted to ES module syntax.

Fix

Convert all require() and module.exports statements to ES module import/export syntax.

Explain

Explain the benefits of ES modules over CommonJS, including tree-shaking, static analysis, and browser support.

Code Review

Review scripts, client components, and browser execution paths related to Use ES modules (import/export). Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/es-modules

よくある質問

ツリーシェイキングとは何ですか?

バンドラーが使われていないコードを取り除き、ファイルを小さくすることです。新しいモジュールの構文によって可能になります。

名前付きの export を使うべきですか?

大きなコードベースでは名前付きの export のほうが拡張しやすいとこのスキルは説明していますが、既定の export でも問題ありません。

ブラウザでモジュールを読み込むにはどうしますか?

script タグに type=module を追加するか、バンドラーを使うことをこのスキルは提案しています。

詳細

作者による元の説明

Use when reviewing scripts, client components, bundles, or runtime behavior related to Use ES modules (import/export). Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

repo: thedaviddias/Front-End-Checklist

人気

GitHubのスター
75k
ランキング
#2836
ライセンス
MIT
更新日
2026/10/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル