Skip to content

Comments

.mjs拡張子を用いる方法からpackage.json"type": "module"と書く方法に変更#931

Open
chvmvd wants to merge 1 commit intomainfrom
migrate-to-type-module
Open

.mjs拡張子を用いる方法からpackage.json"type": "module"と書く方法に変更#931
chvmvd wants to merge 1 commit intomainfrom
migrate-to-type-module

Conversation

@chvmvd
Copy link
Contributor

@chvmvd chvmvd commented Feb 21, 2026

#926 に基づいて、該当箇所を修正しました。主な変更内容は次のようになります。全件の動作確認はできておりませんが、新しいライブラリを使っているものについては全件、動作確認をしています。

  • .mjs拡張子を.js拡張子に変更
  • package.json"type": "module"と追記
  • .mjs拡張子に関連する記述を削除
  • npm initの際に、typeと尋ねられたら、moduleと入力するという説明を追加
  • 関連する動画や写真を差し替え

ただし、次の事項については対応ができておりません。

  • 「データベース」の節の動画の差し替え
    現状、Prisma v7が最新のリリースとなっているが、教材がPrisma v7に対応できていないため、動画を撮ることができないため。
  • 「Renderへのデプロイ」の節のYouTube動画
    動画の中でStart Commandnode main.mjsとなっているため、node main.jsに書き換える必要がある。しかし、この動画撮影の労力は非常に高いため、すぐには対応できなかった。またの機会に対応することとする。

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 21, 2026

Deploying utcode-learn with  Cloudflare Pages  Cloudflare Pages

Latest commit: b8298ec
Status: ✅  Deploy successful!
Preview URL: https://b1bf0af2.utcode-learn.pages.dev
Branch Preview URL: https://migrate-to-type-module.utcode-learn.pages.dev

View logs

@chvmvd chvmvd force-pushed the migrate-to-type-module branch from 04dec4a to b8298ec Compare February 21, 2026 13:47
@chvmvd chvmvd marked this pull request as ready for review February 21, 2026 14:04
@chvmvd chvmvd requested a review from Copilot February 21, 2026 14:04
@chvmvd
Copy link
Contributor Author

chvmvd commented Feb 21, 2026

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8298ec905

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request migrates the codebase from using .mjs file extensions to using "type": "module" in package.json files for ES module support in Node.js. This change aligns with modern Node.js conventions and addresses issues mentioned in #926, particularly compatibility problems with tools like Prisma that generate .ts files rather than .mts files.

Changes:

  • Renamed all .mjs files to .js throughout documentation and sample code
  • Added "type": "module" to all package.json files in sample directories with npm dependencies
  • Updated all documentation references from .mjs to .js file extensions
  • Updated all npm start scripts from node main.mjs to node main.js
  • Updated module import statements from .mjs to .js extensions
  • Updated term definitions to reflect the new approach
  • Modified npm init instructions to guide users to specify "type": "module"

Reviewed changes

Copilot reviewed 36 out of 70 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/components/Term/definitions.ts Updated module definition to remove .mjs-specific language
docs/4-advanced/01-cookie/index.mdx Updated file references from .mjs to .js in documentation
docs/4-advanced/01-cookie/_samples/*/package.json Added "type": "module" and updated start scripts
docs/4-advanced/01-cookie/_samples/*/main.js Renamed from .mjs to .js
docs/3-web-servers/13-deploy-on-render/index.mdx Updated deployment command references
docs/3-web-servers/08-database/index.mdx Updated file references throughout database documentation
docs/3-web-servers/08-database/_samples/*/package.json Added "type": "module" and updated start scripts
docs/3-web-servers/08-database/_samples/*/main.js Renamed from .mjs to .js
docs/3-web-servers/07-fetch-api-post/index.mdx Updated all code examples and references
docs/3-web-servers/07-fetch-api-post/_samples/*/package.json Added "type": "module" and updated start scripts
docs/3-web-servers/07-fetch-api-post/_samples/*/main.js Renamed from .mjs to .js
docs/3-web-servers/06-fetch-api/index.mdx Updated all code examples and references
docs/3-web-servers/06-fetch-api/_samples/*/package.json Added "type": "module" and updated start scripts
docs/3-web-servers/06-fetch-api/_samples/*/main.js Renamed from .mjs to .js
docs/3-web-servers/05-server/index.mdx Updated server documentation and examples
docs/3-web-servers/05-server/_samples/*/package.json Added "type": "module" and updated start scripts
docs/3-web-servers/05-server/_samples/*/main.js Renamed from .mjs to .js
docs/3-web-servers/04-module/index.mdx Updated module system documentation and added npm init instructions
docs/3-web-servers/04-module/_samples/*/package.json Added "type": "module" to samples with npm dependencies
docs/3-web-servers/04-module/_samples/*/main.js Renamed from .mjs to .js, updated import paths
docs/3-web-servers/04-module/_samples/*/sub.js Renamed from .mjs to .js
docs/3-web-servers/03-node-js/index.mdx Updated initial Node.js examples
Comments suppressed due to low confidence (2)

docs/3-web-servers/04-module/_samples/named-export/main.js:1

  • This sample directory is missing a package.json file with "type": "module". Since the file extension was changed from .mjs to .js, Node.js will now interpret this as a CommonJS module by default, which means the import statement will cause an error. A package.json file with "type": "module" needs to be added to this directory to make it work properly.
    docs/4-advanced/01-cookie/index.mdx:125
  • この例では、User テーブルの password を平文の文字列として保存し、user.password !== request.body.password でそのまま比較しています。データベースが漏えいした場合にユーザーのパスワードがそのまま復元されてしまい、他サービスでのパスワード使い回しも含めて重大な被害につながります。パスワードは bcryptscryptArgon2 などの強力なハッシュ関数でソルト付きハッシュとして保存し、ログイン時も送信されたパスワードのハッシュ値を比較する方式に変更してください。

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chvmvd chvmvd requested a review from chelproc February 21, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

コードをESMとして解釈させるために.mjs拡張子を使うのではなく、package.json"type": "module"と書くように変更する

1 participant