.mjs拡張子を用いる方法からpackage.jsonに"type": "module"と書く方法に変更#931
Conversation
Deploying utcode-learn with
|
| 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 |
b1b2151 to
04dec4a
Compare
04dec4a to
b8298ec
Compare
|
@codex review |
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
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
.mjsfiles to.jsthroughout documentation and sample code - Added
"type": "module"to allpackage.jsonfiles in sample directories with npm dependencies - Updated all documentation references from
.mjsto.jsfile extensions - Updated all npm start scripts from
node main.mjstonode main.js - Updated module import statements from
.mjsto.jsextensions - 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でそのまま比較しています。データベースが漏えいした場合にユーザーのパスワードがそのまま復元されてしまい、他サービスでのパスワード使い回しも含めて重大な被害につながります。パスワードはbcryptやscrypt、Argon2などの強力なハッシュ関数でソルト付きハッシュとして保存し、ログイン時も送信されたパスワードのハッシュ値を比較する方式に変更してください。
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
#926 に基づいて、該当箇所を修正しました。主な変更内容は次のようになります。全件の動作確認はできておりませんが、新しいライブラリを使っているものについては全件、動作確認をしています。
.mjs拡張子を.js拡張子に変更package.jsonに"type": "module"と追記.mjs拡張子に関連する記述を削除npm initの際に、typeと尋ねられたら、moduleと入力するという説明を追加ただし、次の事項については対応ができておりません。
現状、Prisma v7が最新のリリースとなっているが、教材がPrisma v7に対応できていないため、動画を撮ることができないため。
動画の中で
Start Commandがnode main.mjsとなっているため、node main.jsに書き換える必要がある。しかし、この動画撮影の労力は非常に高いため、すぐには対応できなかった。またの機会に対応することとする。