Skip to content
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

[SB-1175] Migration: Main.js/Preview default exports #20554

Closed
4 tasks
Tracked by #20674
shilman opened this issue Jan 10, 2023 · 5 comments
Closed
4 tasks
Tracked by #20674

[SB-1175] Migration: Main.js/Preview default exports #20554

shilman opened this issue Jan 10, 2023 · 5 comments
Assignees
Labels
core maintenance User-facing maintenance tasks

Comments

@shilman
Copy link
Member

shilman commented Jan 10, 2023

Is your feature request related to a problem? Please describe

We are moving to default exports for main.js and preview.js configuration. This is friendlier for TypeScript.

Before:

module.exports = { stories: [...] }
//OR
export const stories = [...]

After:

export default {
  stories: [...]
}

const config = {
  addons: ['docs']
} satisfies Config;

const preview = {
  
} satisfies Preview;

export default preview;

Describe the solution you'd like

Default exports are already supported in SB7, but now we need to get users upgraded:

  • Add deprecation warnings for any other format
  • Provide an automigration that upgrades users to default exports
    • JS users
    • TS users

Describe alternatives you've considered

No response

Are you able to assist to bring the feature to reality?

no

Additional context

No response

From SyncLinear.com | SB-1175

@shilman shilman added maintenance User-facing maintenance tasks core labels Jan 10, 2023
@vanessayuenn vanessayuenn changed the title Migration: Main.js/Preview default exports [SB-1175] Migration: Main.js/Preview default exports Jan 18, 2023
@vanessayuenn vanessayuenn moved this to Required for RC in Core Team Projects Jan 18, 2023
@yannbf
Copy link
Member

yannbf commented Jan 23, 2023

@shilman are we expecting users to use as or satisfies in export default? I believe the type-safest solution would be:

const config: StorybookConfig = {
  stories: [...]
}

export default config

Also, is this for preview.js as well? I don't believe we have a type for that

Copy link
Member Author

shilman commented Jan 23, 2023

I think what you wrote is correct. For preview.js, it's up for discussion. I think @kasperpeulen wanted it but maybe we can split this into two tickets & do the other one once he gets back

@yannbf
Copy link
Member

yannbf commented Jan 23, 2023

That sounds much better. We need a proper typing system that will also address addons, parameters, globalTypes, etc

@yannbf yannbf moved this from Required for RC to In Progress in Core Team Projects Jan 24, 2023
@IanVS
Copy link
Member

IanVS commented Jan 26, 2023

Have you considered using a helper like vite's defineConfig? https://vitejs.dev/config/#config-intellisense?

@vanessayuenn vanessayuenn added this to the Cycle 35 milestone Jan 31, 2023
@shilman
Copy link
Member Author

shilman commented Jan 31, 2023

ZOMG!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-beta.38 containing PR #20797 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb@next upgrade --prerelease

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Jan 31, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Core Team Projects Jan 31, 2023
@vanessayuenn vanessayuenn modified the milestones: Cycle 35, Cycle 36 Feb 14, 2023
@vanessayuenn vanessayuenn added this to the Cycle 37 milestone Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core maintenance User-facing maintenance tasks
Projects
Archived in project
Development

No branches or pull requests

4 participants