storybookjs/storybook
View on GitHub[Bug]: Bad error message when trying to use JSX in .js file
Open
#21,662 opened on Mar 17, 2023
bugbuilder-vitehelp wanted
Description
Describe the bug
[storybook:inject-export-order-plugin] Parse error @:22:29
file: ........./src/stories/ApiDocumentation.stories.js
ERR! Error: Parse error @:22:29
ERR! at parse ........./node_modules/es-module-lexer/dist/lexer.cjs:1:402)
ERR! at Object.transform (........./node_modules/@storybook/builder-vite/dist/index.js:1:3217)
ERR! at file:///.........//node_modules/rollup/dist/es/shared/node-entry.js:24343:40
The above error will happen if your .stories.js file contains any JSX. Renaming the file to .jsx fixes the issue. I spent hours trying to figure out the problem. Some better error messaging would be nice here.
To Reproduce
Happens in sandbox project with React and Vite.
System
No response
Additional context
No response