-
Notifications
You must be signed in to change notification settings - Fork 39
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
Breaks on building Storybook #131
Comments
I am facing the same issue |
I am having the same issue, are there any workarounds? |
I faced the same problem msw-storybook-addon: |
for those using
|
npm i --save-dev msw@^1 |
Similar to the Vite specific fix above, this Webpack configuration is working for me (Angular / Storybook / Nx workspace): in .storybook/main.ts:
|
worked for me: import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { createRequire } from "node:module";
import path from "path";
const require = createRequire(import.meta.url);
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
"msw/native": require.resolve(
path.resolve(__dirname, "./node_modules/msw/lib/native/index.mjs")
),
},
},
}); |
Hey everyone! If you're using MSW 2.0.0, we just released a new beta version that should have fixed this issue: Would you please try it out and let us know? Thank you! |
For those who try it out, be very careful with your version specification in package.json. There's a "next" version of 2.0.0, |
Confirmed that the beta solves this issue for me 🎉 |
The types aren't correct for the |
I've followed the vite-specific instructions here but I'm now getting this error:
Is anyone having anything similar? viteFinal: (config) => {
config.resolve = {
...config.resolve,
alias: {
...config.resolve?.alias,
["msw/native"]: require.resolve("../node_modules/msw/lib/native/index.mjs"),
},
};
return mergeConfig(config, {
plugins: [tsconfigPaths()],
});
}, "msw": "^2.1.6",
"msw-storybook-addon": "^2.0.0-beta.1", |
@chapmanio i solved that because you're using "msw/node" in something that is client code only. You may need to swap to "msw/browser" (but this will prevent you from using server libraries like fs or path). |
Do you have a code example of how to do that? I'm not importing MSW in my code (I assume that is being done by |
I'm having the same issue. |
I'm having a similar issue: This works:
This does not work when importing from another lib in my monorepo.
I have proper vite/typescript aliases/paths set up for this mocks lib btw.
|
Fixed by fixing the dep version in package.json
|
Hey everyone! Finally the major version is out. Sorry for such a long wait, I had to make sure the addon aligned with Storybook 8 and worked correctly in the portable stories (using stories in Vitest,Jest) scenario. Please check the release notes, try it out and provide feedback in case issues arise: Thanks! |
I'm still getting this issue [vite] Internal server error: No known conditions for "./node" specifier in "msw" package "msw-storybook-addon": "2.0.3", even while following
what is the solution for this ? |
That's quite odd! Could this be your node version? Could you check whether you have multiple MSW versions installed in your project? e.g. |
While building the Storybook, the bundler (Vite) emits an error like this:
This is because of the code here. While it'll work without any problem when not built, this will break on browser builds because...
IS_REACT_NATIVE
is true or false at build time, therefore it should try to bundle both versions.browser
export condition, the entry resolves to null and it errors.This problem should be fixed by adding separate entries for each browser and native.
The text was updated successfully, but these errors were encountered: