-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
React: _jsx is not defined
error
#12952
Comments
@NandoSangenetto i think this is unrelated to #12881, or only tangentially related. i copied i did, however, see something very troubling, which is:
in the end deleting |
I cannot recall anything special. I'll copy the Let me ask you, what node and npm version are you using? |
@shilman, Although it's building, I cannot switch between stories/templates. Is it working for you? I recorded a video showing it, the only way I could change the component was by refreshing the page, since it was changing the URL but not the canvas. Video: https://youtu.be/nqQvtZNo6Yc |
Try building with --no-dll |
Thank you @shilman! It worked! 🎉 Just to recap, the solution was to copy the |
@shilman Yes, It worked. But I don't understand why it worked. My .babelrc {
"presets": ["next/babel"],
"env": {
"development": {
"plugins": ["@babel/plugin-transform-react-display-name"]
}
}
} Edit I tried to build with this .babelrc 😅: {} But this didn't work - the build finished successfully, but the components weren't in the storybook. Apparently the next/babel preset includes some of the plugins needed to build the storybook Edit |
I removed .babelrc from .storybook and changed main.js. It worked: const { TsconfigPathsPlugin } = require('tsconfig-paths-webpack-plugin');
module.exports = {
stories: ['../src/components/**/*.stories.tsx'],
addons: ['@storybook/addon-docs'],
babel: async (options) => ({
...options,
plugins: [
...options.plugins,
'@babel/plugin-transform-react-jsx'
]
}),
webpackFinal: (config) => {
config.resolve.plugins.push(new TsconfigPathsPlugin());
return config;
}
}; @shilman @NandoSangenetto Can you try please? Edit But routing still doesn't work without the --no-dll flag |
@DiFuks great point. perhaps there's a bug where dev mode picks up the project babelrc and production does not? if so, that's pretty bad! can you confirm? PS proper |
@shilman I replaced the content of .babelrc in root path with I posted a project that has the discussed issue: https://github.com/DiFuks/react-next-nest-boilerplate master branch include this fix: #12952 (comment) |
@shilman @DiFuks Copying
Storybook version is ============ |
@Carduelis This solution didn't help? #12952 (comment) |
@Carduelis Please upgrade to the latest beta |
fixed for us on v6.1.0-rc.0 |
@sibelius Unfortunately, the problem has not been resolved. |
Can reproduce on Vulcan Next, only during build VulcanJS/vulcan-next#78 Dev is not affected at all, only static build. I've deactivated React 17 automatic runtime in favour to classic also to make Next work ok (downstream plugins can have issues with it). Edit: copying
My root babel config for the record:
|
After upgrading to v6.0.1 my storybook production build got broken with the same error. I use the proposed fix of @DiFuks and it fix my build |
Try upgrading to 6.1?
|
I have the same issue. The solution for me - just to copy the BTW, I have tried to upgrade a storybook version via |
I resorted to patching the babel config like so (in ...
babel: (options) => {
options.presets = options.presets.map((preset) => {
if (Array.isArray(preset) && preset[0].includes('@babel/preset-react')) {
return [require.resolve('@babel/preset-react'), {runtime: 'classic'}]
}
return preset
})
return options
},
... |
React: `_jsx is not defined` error #12952 storybookjs/storybook#12952 (comment)
React: `_jsx is not defined` error #12952 storybookjs/storybook#12952 (comment)
Does anybody have a repro they can share with Here's what I think is going on:
I think the logic of those two is somehow inconsistent. With a simple repro it should hopefully be easy to fix. |
@shilman here: https://github.com/prisma-cms/component-boilerplate/tree/76d2516757491068c3cfc1df5dc143ef69437b73 |
@Fi1osof thanks for this. When I do |
@shilman I have tried to upgrade via The better solution is just to copy .babelrc into .storybook folder and that might work for now.. |
@shilman i try UPD: in last one i remove "baseUrl": "." from tsconfig.json and all links in project relative, not abs. |
@shilman I still have the error with |
I'm experiencing this with I used @DiFuks's example, and also needed a workaround from Chakra's own repo. Below is my const path = require('path')
const toPath = (_path) => path.join(process.cwd(), _path)
module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'storybook-addon-playroom',
'@storybook/addon-a11y',
'@storybook/addon-storysource',
'storybook-addon-designs',
'@storybook/addon-actions',
],
// ! Taken from Storybook issue workaround
// ! See: https://github.com/storybookjs/storybook/issues/12952#issuecomment-719871776
babel: async (options) => ({
...options,
plugins: [...options.plugins, '@babel/plugin-transform-react-jsx'],
}),
// ! Taken from Chakra's Storybook + Emotion 11 workaround
// ! See: https://github.com/chakra-ui/chakra-ui/pull/2466/files#diff-cafe2123a72c4ce3a9f7e9ee4b0e188256eb02d7ec1e54fa2cadfac99b22f92b
webpackFinal: async (config) => {
return {
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve.alias,
'@emotion/core': toPath('node_modules/@emotion/react'),
'emotion-theming': toPath('node_modules/@emotion/react'),
},
},
}
},
} |
@Fi1osof I'm seeing a slightly different error which is |
[email protected] |
@rhatfield-bushel this helps me. And @babel/plugin-transform-react-jsx already exists in SB.
I do not know why this not works nativly. |
I'm in the process of refactoring our component library and I had this piece of commented out code from the old component:
We used to need that first line but since we no longer use EmotionJS, removing that line resolved the error for me. Silly mistake |
Adding this minimal
|
Same solution for me, but with a less duplicated configuration:
|
Add local .babelrc for React Storybook storybookjs/storybook#12952 (comment)
This is fixed in storybook 7.0 beta by not providing a default babel config. |
Originally posted by @NandoSangenetto in #12881 (comment)
I'm getting the same error that @DiFuks is getting,
_jsx is not defined
.I've created a small repo where you can reproduce this bug: https://github.com/nandosangenetto/storybook-bug-repro
I've tried to remove all addons, as @DiFuks did, but it didn't work.
What is odd is that it works when I run
npm run storybook
(start-storybook -p 6006
), but fails when I try to build it withnpm run build-storybook
(build-storybook
).The text was updated successfully, but these errors were encountered: