-
-
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
CLI: generate main config with default exports #20797
Conversation
@kasperpeulen I'm curious about your opinion regarding the import { StorybookConfig } from '@storybook/react-webpack5';
const config: StorybookConfig = {
"stories": [
"../src/**/*.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
};
export default config; Instead of: import { StorybookConfig } from '@storybook/react-webpack5';
export default {
"stories": [
"../src/**/*.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
} as StorybookConfig; or: import { StorybookConfig } from '@storybook/react-webpack5';
export default {
"stories": [
"../src/**/*.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
} satisfies StorybookConfig; |
- additionally, generate in typescript format if applicable
- We don't have to use this workaround anymore 🎉
b6d7fcc
to
07bb9b9
Compare
I commented in the issue, but maybe that got lost. Have you considered using a helper like vite's defineConfig? vitejs.dev/config/#config-intellisense? I think it's a bit easier to ensure that everyone gets good types if we take that approach. The helper only exists to provide types. |
Thanks for bringing this up! We've had discussions about factory functions quite a few times, and I think that would require its own RFC so we can discuss about that in detail. IMO for now we can't do such a big change given how late we're in the 7.0 release! If we do something like that, we probably need to think overall how we deal with main.js/preview.js/stories format altogether. |
@yannbf I think satisfies would be the ideal option. The concern would be if people aren't on typescript >= v4.9. |
Issue: #20554
What I did
The format of
main.js
coming from Storybook'sinit
command changes from:to
Additionally, it will generate
main.ts
andpreview.ts
in typescript projects, always importing from the framework which the CLI generates the project with:How to test
yarn task
before-storybook
directories here: https://github.com/storybookjs/sandboxessb init
using the built library from this branch, in the directory of that project:<path-to-storybook>/code/lib/cli/bin/index.js init
main
andpreview
files got generated correctlySpecial scenarios, apart from the basic ones:
tsconfig
file under.storybook
dirmain.cjs
for compatibility purposes. I removed that logic and it should behave like any other project.Checklist
MIGRATION.MD
Maintainers
make sure to add the
ci:merged
orci:daily
GH label to it.["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]