Closed nartc closed 1 month ago
Unfortunately, using more specific exports doesn't always seem to be possible. For example, unless I am mistaken, delay
is only exported via the main export.
Similarly, HttpResponse
also is not exported from msw/core/http
. Probably applies to quite a few more things.
If msw/core/http
is really intended as the "don't need graphql" entrypoint, the exports should probably be identical to those of msw
, except from the graphql related stuff.
@ghost91- or msw
entry point should be cleared of anything that requires optional peer dependencies so things like main utilities can still be exported from the main entry point.
@ghost91-, good point. The explicit import would be better once we drop graphql
export from the root module. So you import graphl from msw/core/graphql
only.
For now, I think the safest way to fix this and now force developers to install graphql is to make that import dynamic. Need to give this a try.
I will close this one in favor of #2248 (has a more searchable error message). Please keep track of the updates there. Thanks.
This has been released in v2.4.1!
Make sure to always update to the latest version (npm i msw@latest
) to get the newest features and bug fixes.
Predictable release automation by @ossjs/release.
Prerequisites
Environment check
msw
versionNode.js version
20.14.0
Reproduction repository
https://github.com/nartc/msw-entry-point-bug
Reproduction steps
npm install
npm test
Script fails with
Cannot find module "graphql"
Current behavior
Thank you for your effort on
msw
.Before I say anything, I believe our issue is our own "user error". However, I also believe this issue can still be an overlook as current code would break at runtime with 2.4.0 and the release note does not mention anything about the new secondary entry points available in 2.4.0
This works in pre 2.4.0 but will break in 2.4.0 for projects that don't have
graphql
installed. This is due tomsw
core entry point still exports the handlers which makesgraphql
NOT an optional peer dependency.The proper fix would be to import from
msw/core/http
but it seems likemsw/core/http
does not exportHttpHandler
either.Once again, our project runs into this due to many errors/mistakes on our part but I want to raise this issue in case others run into the same thing (or have the same user errors/mistakes)
Expected behavior
This import should at least break at compilation time (type checking time) with something like: msw does not export
http
. And release note should mention migrating tomsw/core/http
(or respective entry point for the handlers).