-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
.storybook/main.ts no longer parses correctly, gets SyntaxError: Unexpected token error (@storybook/*@6.5.0-alpha.42) #17589
Comments
I just found the fix via this issue, looks like I just needed to add
It looks like the updated docs aren't live yet - this info about using Also recommend adding the info to this page: https://storybook.js.org/docs/react/configure/typescript Might also be handy to see this in the |
I was still getting an syntax error in my own project even after adding // tsconfig.json
{
"compilerOptions": {
...
- "module": "esnext",
+ "module": "commonjs",
}
} |
@davidcalhoun, a bit of a necro, but you could try adding the following entry in
|
@Gregorein Woot, thank you! Just tried it and it worked here as well. I didn't know you could scope TS config to packages like that, that's a way nicer solution! |
Try to add {
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript"
]
} |
@chioio tnx adding @babel/preset-typescript solved my case |
But why is this issue closed if one still needs to encounter the error, perform a Google search with error contents, come across this bug report, and then scroll through and attempt the various suggestions in order to resolve the issue? |
This issue is relevant again in storybook 8.0.4
|
EDIT: found the fix below
Describe the bug
Using imports/exports in
.storybook/main.ts
seems to no longer parse correctly, resulting in a build errorSyntaxError: Unexpected token
when runningstart-storybook
.I've reproduced this in a simple repro that uses Webpack 4 (the default).
Strangely, initially I ran into this error with my original repo running
@storybook/*@6.4.19
when trying to opt in to using Webpack 5 with these migration instructions. Though it's worth noting that with the minimal repro on Webpack 4, I got these errors even when forcing package resolutions from@storybook/*@6.5.0-alpha.42
down to@storybook/*@6.4.19
.Doesn't build (using suggested formatting from Storybook's react-ts example base.ts):
Builds successfully:
To Reproduce
Reproduction repo: https://github.com/davidcalhoun/storybook-react-typescript-repro
Steps to recreate from scratch: https://github.com/davidcalhoun/storybook-react-typescript-repro#steps-to-recreate-from-scratch
System
Additional context
Full error output is included in the repro's readme, I'm also pasting it in here for searchability:
Error from the simple repro
Error from a yarn monorepo which has an
export * from...
as the first line of its.storybook/main.ts
fileThe text was updated successfully, but these errors were encountered: