Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use MSW.js #27289

Closed
vladjerca opened this issue Dec 9, 2024 · 3 comments · Fixed by #27294
Closed

Cannot use MSW.js #27289

vladjerca opened this issue Dec 9, 2024 · 3 comments · Fixed by #27294
Labels
bug Something isn't working correctly node compat

Comments

@vladjerca
Copy link

vladjerca commented Dec 9, 2024

Version: Deno 2.1.3

TypeError: Could not find package '_http_common' from referrer '.../node_modules/.deno/@[email protected]/node_modules/@mswjs/interceptors/lib/node/chunk-3A47UESP.mjs'.
 ❯ src/mocks/server.ts:1:1
      1| import { setupServer } from 'msw/node';
       | ^
      2| import { handlers } from './handlers.ts';
      3| 
 ❯ vitest-setup.ts:5:1

Easily reproducible by following the basic setup guide:

https://mswjs.io/docs/getting-started

Works with: bun and node. I know that _http_common is exposed by node but I would expect deno to have some polyfill for it since it's supposed to offer backwards compatibility? 🤔

LE: Link with repro https://github.com/vladjerca/deno-msw-repro

@vladjerca
Copy link
Author

I've tried using the canary build, indeed the first issue is fixed. A new one seems to have materialized though:

ReferenceError: BroadcastChannel is not defined
 ❯ ../../node_modules/.deno/[email protected]/node_modules/msw/src/core/ws.ts:20:26

@petamoriken
Copy link
Contributor

petamoriken commented Dec 10, 2024

Please try to use --unstable-broadcast-channel flag or to add "unstable": ["broadcast-channel"] to deno.json
https://docs.deno.com/runtime/reference/cli/unstable_flags/#--unstable-broadcast-channel

@vladjerca
Copy link
Author

Yep, that was the missing piece! Thanks, you guys rock! 😀

bartlomieju pushed a commit that referenced this issue Dec 11, 2024
… _http_common (#27294)

Fixes #27289

We exported these but forgot to add them to the list of builtins used by
the resolver, so we weren't resolving bare imports of some modules (e.g.
`"_http_common"`)

Also adds a missing export of `HTTPParser` from `_http_common`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants