Skip to content

chore: gitignore auto-generated mockServiceWorker.js#2708

Closed
devmgn wants to merge 3 commits intomainfrom
chore/gitignore-msw-worker
Closed

chore: gitignore auto-generated mockServiceWorker.js#2708
devmgn wants to merge 3 commits intomainfrom
chore/gitignore-msw-worker

Conversation

@devmgn
Copy link
Copy Markdown
Owner

@devmgn devmgn commented Apr 17, 2026

Summary

  • MSW の postinstall が package.jsonmsw.workerDirectory 設定を見て public/mockServiceWorker.js を自動同期するため、update-msw.yml ワークフローは不要。
  • 生成ファイルを .gitignore に追加し、ワークフローを削除。

背景

pnpm install 時に MSW の postinstall が走り、worker スクリプトが MSW バージョンと自動同期される(pnpm.onlyBuiltDependenciesmsw を許可済み)。Renovate 更新時もこの仕組みで追従するので、CI で msw init --save → commit するワークフローは重複している。

変更

  • .gitignore: /public/mockServiceWorker.js を追加
  • public/mockServiceWorker.js: 追跡から削除(生成物)
  • .github/workflows/update-msw.yml: 削除
  • .claude/rules/ci.md: 該当行を削除

Test plan

  • pnpm install 後に public/mockServiceWorker.js が自動生成されること(ローカル検証済み)
  • 既存 CI(lint / test / build)が通ること
  • pnpm dev で MSW が従来どおり動作すること

🤖 Generated with Claude Code

devmgn and others added 3 commits April 17, 2026 21:50
MSW postinstall auto-syncs public/mockServiceWorker.js via
package.json "msw.workerDirectory", so the update-msw.yml workflow
is redundant. Ignore the generated file and remove the workflow.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
pnpm hardlinks msw from its global store after the first build, so
msw's postinstall doesn't re-run on subsequent installs — new clones
hitting a warm store would not get public/mockServiceWorker.js.

Run `msw init public --save` in the prepare script so every
`pnpm install` regenerates the worker deterministically.

Normalize workerDirectory to "public" to keep `--save` idempotent
(passing "./public" triggers msw to append both forms).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
postinstall runs on every install variant (including `pnpm add`),
while prepare can skip under `--production` or single-package adds.
postinstall also avoids a future conflict with tools that claim
prepare (e.g., Husky).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@devmgn devmgn closed this Apr 18, 2026
@devmgn devmgn deleted the chore/gitignore-msw-worker branch April 18, 2026 10:38
@devmgn devmgn restored the chore/gitignore-msw-worker branch April 18, 2026 13:27
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.

1 participant