Skip to content

Add Babel migration note to addon migration guide#25660

Merged
vanessayuenn merged 1 commit into
vy/addon-migration-guide-8from
shilman/addon-guide
Jan 19, 2024
Merged

Add Babel migration note to addon migration guide#25660
vanessayuenn merged 1 commit into
vy/addon-migration-guide-8from
shilman/addon-guide

Conversation

@shilman
Copy link
Copy Markdown
Member

@shilman shilman commented Jan 19, 2024

No description provided.

@shilman shilman added api: addons documentation ci:docs Run the CI jobs for documentation checks only. labels Jan 19, 2024
Copy link
Copy Markdown
Contributor

@jonniebigodes jonniebigodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shilman, just a couple of minor tweaks, and this should be good to go, appreciate you taking the time to add this to the addon migration guide. Appreciate it 🙏


### Babel-loader removed from Webpack

Storybook 8 [removes babel-loader from the webpack5 builder](https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#removed-babelcore-and-babel-loader-from-storybookbuilder-webpack5). If your addon's preset overrides the `babel()` method, it will break if your users are using SWC to compile their files (which is the new default in SB8).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shilman are you ok with adjusting this to be:

"Storybook 8 removes babel-loader from the webpack5 builder. If your addon's preset overrides the babel() method, it will break if your users are using SWC to compile their files (which is the new default for Webpack 5-based Storybook projects)."

Comment on lines +55 to +59
As a workaround, your update your documentation to tell users to opt-in to Babel support. This should fix your addon in their project, at the cost of performance:

```sh
npx storybook@latest add @storybook/addon-webpack-compiler-babel
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shilman minor typo here; there is an extra your, turning this into:
"As a workaround, update your documentation to tell users to opt-in to Babel support. This should fix your addon in their project, at the cost of performance:
"
Also, the package's name is incorrect, it should be @storybook/addon-webpack5-compiler-babel


Storybook 8 [removes babel-loader from the webpack5 builder](https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#removed-babelcore-and-babel-loader-from-storybookbuilder-webpack5). If your addon's preset overrides the `babel()` method, it will break if your users are using SWC to compile their files (which is the new default in SB8).

To solve for both Babel and SWC, the most robust approach is to create an [unplugin](https://github.com/unjs/unplugin) that will work with both Webpack and Vite builders. That will give you full control to run babel (or whatever you want) on stories and components as they are loaded.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shilman capitalize Babel here if you wouldn't mind, turning this into :
"To solve for both Babel and SWC, the most robust approach is to create an unplugin that will work with both Webpack and Vite builders. That will give you full control to run Babel (or whatever you want) on stories and components as they are loaded."

@vanessayuenn vanessayuenn merged commit 05969e2 into vy/addon-migration-guide-8 Jan 19, 2024
@vanessayuenn vanessayuenn deleted the shilman/addon-guide branch January 19, 2024 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: addons ci:docs Run the CI jobs for documentation checks only. documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants