storybookjs/storybook

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

开放

#21,662 创建于 2023年3月17日

 (5 条评论) (18 个反应) (0 位负责人)TypeScript (10,058 个派生)batch import
bugbuilder-vitehelp wanted

仓库指标

星标
 (89,909 个星标)
PR 合并指标
 (平均合并 7天 22小时) (30 天内合并 184 个 PR)

描述

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

贡献者指南