-
Notifications
You must be signed in to change notification settings - Fork 106
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
Export name issue with jest-mock while running Storybook #242
Comments
Are you using |
not using |
I've had problems with |
same error from a fresh install. not a solution, but as a workaround disable
|
I think this is something that needs to be addressed in the interaction addon. Would y'all mind giving a 👍 or adding any missing information to storybookjs/storybook#17516? One other possible workaround (I don't really recommend it, and haven't tested it), could be to set |
I've opened storybookjs/storybook#17535 to address this issue, keep an eye on that if you'd like to know the current status. |
This should now be fixed in https://github.com/storybookjs/storybook/releases/tag/v6.5.0-alpha.43, if anyone would like to test it out. |
I tried Storybook v6.5.0-alpha.44 and now get the following error:
My dependencies are:
|
Can you try adding jest-mock to your optimizeDeps.include? |
@IanVS Just tried, but the I'm testing with a freshly scaffolded project, by the way. My Vite config is: // vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({
optimizeDeps: {
include: ["jest-mock"],
},
plugins: [react()],
}); Edit: I set up a reproduction here: https://github.com/pastelmind/vite-storybook-test/tree/sb-alpha |
Experiencing this as well in a fresh project. |
I need to make a change in storybook, but in the meantime, you should be able to add a
In the reproduction in #242 (comment), I also needed to update vite to 2.8.6, run |
I've opened storybookjs/storybook#17614 to address the need to set |
Just to add that I experience the above-mentioned issue on a fresh project, which I believe differs from pastelmind's reproduction only by being
npm create vite@latest epg-service --template react-ts
npx sb@next init --builder storybook-builder-vite I was unable to fix things by following IanVS's steps of:
Here's my final package.json after following all those steps: {
"name": "my-app",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"dependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@storybook/addon-actions": "^6.5.0-alpha.45",
"@storybook/addon-essentials": "^6.5.0-alpha.45",
"@storybook/addon-interactions": "^6.5.0-alpha.45",
"@storybook/addon-links": "^6.5.0-alpha.45",
"@storybook/react": "^6.5.0-alpha.45",
"@storybook/testing-library": "0.0.9",
"@types/react": "^17.0.33",
"@types/react-dom": "^17.0.10",
"@vitejs/plugin-react": "^1.0.7",
"babel-loader": "^8.2.3",
"storybook-builder-vite": "^0.1.17",
"typescript": "^4.5.4",
"vite": "^2.8.6"
}
} The only thing that I've found to improve the situation is kaminskypavel's suggestion to remove addon-interactions altogether (and I'm not sure what the consequences of that are): module.exports = {
"stories": [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
- "@storybook/addon-interactions"
],
"framework": "@storybook/react",
"core": {
"builder": "storybook-builder-vite"
}
} Thanks IanVS for your efforts on this so far, nonetheless! |
@shirakaba Do you happen to have a reproduction that I could take a look at? |
@IanVS I've made one now: https://github.com/shirakaba/storybook-jest-mock-issue-repro On the branch npm create vite@latest storybook-jest-mock-issue-repro --template react-ts
cd storybook-jest-mock-issue-repro
npx sb@next init --builder storybook-builder-vite
# Redundant, because although the package.json specified ^2.8.0,
# the template installed version 2.8.6 anyway:
npm install --save-dev [email protected] On the branch In both cases, they meet the same error:
|
Thanks @shirakaba that was helpful. There's one more piece you need in your
|
You should now be able to remove the explicit |
just tested with the following deps
im still getting
the error is still caused by |
This error is due to storybookjs/storybook#15391. Until we find a better way to solve it, you can create a <script>
window.global = window;
</script> |
Hello there,
When I install Vite then
storybook-builder-vite
withnpx sb@latest init --builder storybook-builder-vite
, the compilation works fine but then Storybook fails to start throwing this error:I have tried to add
jest-mock
to theoptimizeDeps
, install the dependency but nothing works.When I run
npx sb@next init --builder storybook-builder-vite
, I have a similar error withacorn-jxs
which has a missing export as well.I suspect that the issue is related to ESM and how the dependencies exports their methods.
Any clue or help to solve this issue?
Thanks!
The text was updated successfully, but these errors were encountered: