storybookjs/storybook

[Bug]: Bad error message when trying to use JSX in .js file

Open

#21,662 opened on 2023年3月17日

GitHub で見る
 (5 comments) (18 reactions) (0 assignees)TypeScript (89,909 stars) (10,058 forks)batch import
bugbuilder-vitehelp wanted

説明

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

コントリビューターガイド