Skip to content

Commit 10c006c

Browse files
devmgnclaude
andcommitted
chore: add msw init to prepare script
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]>
1 parent b4bd31d commit 10c006c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"build-storybook": "storybook build",
2525
"generate-api": "pnpm dlx @openapitools/openapi-generator-cli generate -i openapi.yml -g typescript-fetch -o ./src/api/openapi -c openapiconfig.json --openapi-normalizer SET_TAGS_FOR_ALL_OPERATIONS=default",
2626
"generate-api:clean": "rm -rf src/api/openapi && pnpm generate-api",
27-
"generate-mock": "msw-auto-mock openapi.yml -o ./src/mocks --typescript --base-url https://jsonplaceholder.typicode.com && sed -i '' 's|from \"@faker-js/faker\"|from \"@faker-js/faker/locale/ja\"|' ./src/mocks/handlers.ts"
27+
"generate-mock": "msw-auto-mock openapi.yml -o ./src/mocks --typescript --base-url https://jsonplaceholder.typicode.com && sed -i '' 's|from \"@faker-js/faker\"|from \"@faker-js/faker/locale/ja\"|' ./src/mocks/handlers.ts",
28+
"prepare": "msw init public --save"
2829
},
2930
"dependencies": {
3031
"@hookform/resolvers": "5.2.2",
@@ -103,6 +104,6 @@
103104
]
104105
},
105106
"msw": {
106-
"workerDirectory": "./public"
107+
"workerDirectory": "public"
107108
}
108109
}

0 commit comments

Comments
 (0)