For workerDirectory when using msw in workspace used within a certain npm workspaces. #2065
-
Suppose
And assume that // workspaceA/package.json
{
...,
"devDependencies": {
...,
"msw": "2.0.0",
...,
},
...,
"msw": {
"workerDirectory": "./public"
}
} Running msw/config/scripts/postinstall.js Line 8 in b3e47f7 How can I configure |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, @k35o. The Here's what you should do instead.
This will store the public path of your nested package for future MSW updates in the root-level // ./package.json
{
"msw": {
"workerDirectory": ["./packages/packageA/public"]
}
} You can also keep a list of values in case multiple packages in your monorepo need the worker script. Related materials |
Beta Was this translation helpful? Give feedback.
Hi, @k35o.
The
msw.workerDirectory
must always be specified in the root-levelpackage.json
. That's the CWD you have when you runnpm install
. MSW cannot and mustn't assume workspaces or-w
flags.Here's what you should do instead.
npm i msw@latest -D -w packageA
npx msw init ./packages/packageA --save
(from the root).This will store the public path of your nested package for future MSW updates in the root-level
package.json
:You can also keep a list of values in case multiple packages in your monorepo need the worker script.
Related materials