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
I hit a snag when trying to bundle msw@next using tsup (which sets platform: node, apparently). It took me a while to figure out what was happening, because the error message was confusing:
✘ [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:9:13:
9 │ "exports": {
╵ ^
The file "./lib/browser/index.js" is exported at path "./browser":
node_modules/msw/package.json:21:17:
21 │ "default": "./lib/browser/index.js"
╵ ~~~~~~~~~~~~~~~~~~~~~~~~
Import from "msw/browser" to get the file "node_modules/msw/lib/browser/index.js":
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.
1 error
I realized eventually that this was happening because msw sets a condition of "node": null to prevent the import in node environments.
So I understand why this is happening now, but it took a while to figure it out. I think some more information in the error message would be really useful. Maybe just something simple like, The path "./browser" is not exported by package "msw", due to the "node": null condition.
The text was updated successfully, but these errors were encountered:
I hit a snag when trying to bundle msw@next using tsup (which sets
platform: node
, apparently). It took me a while to figure out what was happening, because the error message was confusing:I realized eventually that this was happening because msw sets a condition of
"node": null
to prevent the import in node environments.So I understand why this is happening now, but it took a while to figure it out. I think some more information in the error message would be really useful. Maybe just something simple like,
The path "./browser" is not exported by package "msw", due to the "node": null condition.
The text was updated successfully, but these errors were encountered: