You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This one is confusing me. I'm trying to import from msw/browser (using msw@next), but getting this error when I try to build using tsup:
ESM Build start
✘ [ERROR] Could not resolve "msw/browser"
lib/msw-config.ts:2:46:
2 │ import { setupWorker, type SetupWorker } from 'msw/browser';
╵ ~~~~~~~~~~~~~
The path "./browser" is not exported by package "msw":
node_modules/msw/package.json:8:13:
8 │ "exports": {
╵ ^
The file "./lib/browser/index.mjs" is exported at path "./browser":
node_modules/msw/package.json:19:16:
19 │ "import": "./lib/browser/index.mjs",
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~
Import from "msw/browser" to get the file "node_modules/msw/lib/browser/index.mjs":
lib/msw-config.ts:2:46:
2 │ import { setupWorker, type SetupWorker } from 'msw/browser';
│ ~~~~~~~~~~~~~
╵ "msw/browser"
You can mark the path "msw/browser" as external to exclude it from the bundle, which will remove
this error.
ESM Build failed
Error: Build failed with 1 error:
lib/msw-config.ts:2:46: ERROR: Could not resolve "msw/browser"
I'm using the latest tsup version, and you can see where this is happening here in this PR: miragejs/mirage-msw#12.
Alright, passing --platform browser solves it. I didn't realize TSUP by default sends platform: node to esbuild, which causes it to consider the node export condition.
This one is confusing me. I'm trying to import from
msw/browser
(using msw@next), but getting this error when I try to build using tsup:I'm using the latest tsup version, and you can see where this is happening here in this PR: miragejs/mirage-msw#12.
And, here is the
package.json
of msw, which shows the./browser
export: https://github.com/mswjs/msw/blob/bb02e57568e052206ed8bc55b800cad5fc4c8c78/package.json#L16C8-L22Upvote & Fund
The text was updated successfully, but these errors were encountered: