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

Webpack5: Remove babel and SWC compiler from builder #25379

Merged
merged 58 commits into from
Jan 10, 2024

Conversation

valentinpalkovic
Copy link
Contributor

@valentinpalkovic valentinpalkovic commented Dec 29, 2023

Closes #25172

What I did

This PR removes Babel and SWC from the Webpack5 builder and will add @storybook/addon-webpack5-compiler-swc per default to Webpack5 projects during initialization where possible.

Webpack users have to choose between one of the two add-ons:

to set up SWC or Babel as a loader for Webpack5. The SWC addon will be set up and installed per default for the user during sb init for all Webpack5-based projects.

The following frameworks don't need a particular compiler addon since the compiler is built-in:

  • CRA
  • Angular
  • Next.js
  • Ember

Additionally:

  • Next.js: Add automatic SWC mode detection (see migration note)
  • Next.js: Add custom babel-loader setup to support Babel mode
  • Next.js: Integrated fast-refresh "natively" (see migration notes about fast-refresh)
  • Preact: Remove Preact < 10 support
  • Preact: No longer adds default babel plugins (see migration note)
  • WebComponents: No longer adds default babel plugins (see migration note)
  • WebComponents: Removed @storybook/preset-web-components-webpack and integrated the code directly into @storybook/web-components-webpack5
  • Ember: Add custom babel-loader setup
  • Framework: Removes framework.options.builder.useSWC (see migration note)
  • Framework: Removes framework.options.fastRefresh (see migration note)
  • Typescript: Removes deprecated typescript.skipBabel option
  • @babel/core: Removed as peer dependency where possible
  • Removed the CLI command to generate a default babel config (npx sb babelrc)
  • Configured sb init to install @storybook/addon-webpack5-compiler-<babel|swc> for frameworks, which need an additional compiler

Out of scope

Automigrations are not written yet and will be added in a follow-up step.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

The sandboxes are already covering a lot of use cases. It might be beneficial, though, to test some Webpack5-based projects. Remember that we currently don't have any auto migrations to automatically setup the necessary addons for users to add a compiler. You have to manually either install @storybook/addon-webpack5-compiler-swc or @storybook/addon-webpack5-compiler-babel and add it to the addons in `.storybook/main.<js|ts>.

The following frameworks don't need a compiler addon for webpack5 at all since the compiler is integrated:

  • CRA
  • Next.js
  • Angular
  • Ember

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This pull request has been released as version 0.0.0-pr-25379-sha-d343aef0. Install it by pinning all your Storybook dependencies to that version.

More information
Published version 0.0.0-pr-25379-sha-d343aef0
Triggered by @valentinpalkovic
Repository storybookjs/storybook
Branch valentin/remove-babel-from-webpack5-builder
Commit d343aef0
Datetime Mon Jan 8 12:09:43 UTC 2024 (1704715783)
Workflow run 7447197299

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=25379

Copy link
Contributor

github-actions bot commented Dec 29, 2023

Fails
🚫 PR is marked with "BREAKING CHANGE" label.

Generated by 🚫 dangerJS against 618d45c

Copy link

socket-security bot commented Dec 29, 2023

New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
@types/babel-plugin-react-docgen 4.2.3 None +0 4.23 kB types
@types/react-refresh 0.14.5 None +0 5.63 kB types
@vue/compiler-core 3.4.7 None +0 600 kB
@storybook/theming 7.5.0 None +0 724 kB shilman
@storybook/client-logger 7.5.0 None +0 7.45 kB shilman
axe-core 4.8.2 None +0 2.43 MB npmdeque
giget 1.1.3 environment +2 289 kB pi0
ws 8.15.0 None +0 140 kB lpinca
webpack-hot-middleware 2.25.4 None +0 32.8 kB evilebottnawi
terser-webpack-plugin 5.3.9 None +8 7.16 MB evilebottnawi
unplugin 1.5.1 None +1 698 kB sxzz
html-webpack-plugin 5.5.4 None +10 7.77 MB evilebottnawi
chai 4.3.10 None +0 752 kB keithamus
@digitak/esrun 3.2.26...3.2.25 None +0/-0 32.8 kB gin-quin
@analogjs/vite-plugin-angular 0.2.29...0.2.28 None +64/-23 88.4 MB brandonroberts
@angular/cli 17.0.9...17.0.5 None +14/-9 10.7 MB google-wombot
@emotion/react 11.11.3...11.11.1 None +1/-1 586 kB emotion-release-bot
@angular-devkit/build-angular 17.0.9...17.0.5 network +63/-22 88.3 MB google-wombot
@angular/compiler-cli 17.0.8...17.0.5 None +7/-3 38.9 MB google-wombot
@angular/platform-browser-dynamic 17.0.8...17.0.5 None +5/-5 46.9 MB google-wombot
@angular/core 17.0.8...17.0.5 None +0/-0 23.7 MB google-wombot
@storybook/addon-designs 7.0.9...7.0.7 None +13/-3 3.48 MB yannbf
@angular/platform-browser 17.0.8...17.0.5 None +3/-3 37.3 MB google-wombot
@angular/common 17.0.8...17.0.5 None +1/-1 34.9 MB google-wombot
@angular/animations 17.0.8...17.0.5 None +1/-1 25.4 MB google-wombot
@angular/forms 17.0.8...17.0.5 None +4/-4 39.3 MB google-wombot
@angular/compiler 17.0.8...17.0.5 None +1/-1 33.2 MB google-wombot
jsdom 23.2.0...23.0.1 None +3/-3 3.49 MB domenic
svelte-preprocess 5.1.3...5.1.1 None +12/-6 6.04 MB dummdidumm
vue 3.4.5...3.3.11 None +22/-8 14.1 MB yyx990803
image-size 1.1.1...1.0.2 None +0/-0 45.5 kB netroy
@vitejs/plugin-vue 4.6.2...4.5.2 None +28/-7 43.5 MB vitebot

🚮 Removed packages: @storybook/[email protected], @swc/[email protected], [email protected]

@valentinpalkovic valentinpalkovic force-pushed the valentin/remove-babel-from-webpack5-builder branch from e6df8ee to ec5c571 Compare December 29, 2023 13:30
@valentinpalkovic valentinpalkovic removed the request for review from jonniebigodes January 5, 2024 12:11
@valentinpalkovic valentinpalkovic marked this pull request as ready for review January 5, 2024 13:28
Copy link
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.

@valentinpalkovic, thanks for taking the time to update the documentation with this pull request. Appreciate it 🙏 ! I left some items for you to look into when you can. Also, I was wondering if we could either update the Webpack documentation or the compiler page with a small section mentioning the new addons to give them some relevance and avoiding having them getting buried in the migration guide. Let me know, and we'll take it from there.

MIGRATION.md Outdated Show resolved Hide resolved
MIGRATION.md Outdated Show resolved Hide resolved
docs/addons/writing-presets.md Outdated Show resolved Hide resolved
docs/writing-tests/test-coverage.md Outdated Show resolved Hide resolved
MIGRATION.md Outdated Show resolved Hide resolved
MIGRATION.md Outdated Show resolved Hide resolved
MIGRATION.md Outdated Show resolved Hide resolved
MIGRATION.md Outdated Show resolved Hide resolved
MIGRATION.md Outdated Show resolved Hide resolved
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

Great job @valentinpalkovic !! I added some minor edits to make it slightly less wordy

MIGRATION.md Outdated Show resolved Hide resolved
MIGRATION.md Outdated Show resolved Hide resolved
MIGRATION.md Outdated Show resolved Hide resolved
MIGRATION.md Outdated Show resolved Hide resolved
MIGRATION.md Outdated Show resolved Hide resolved
MIGRATION.md Outdated Show resolved Hide resolved
MIGRATION.md Outdated Show resolved Hide resolved
valentinpalkovic and others added 8 commits January 9, 2024 13:31
Co-authored-by: Michael Shilman <[email protected]>
Co-authored-by: Michael Shilman <[email protected]>
Co-authored-by: Michael Shilman <[email protected]>
Co-authored-by: Michael Shilman <[email protected]>
Co-authored-by: Michael Shilman <[email protected]>
Co-authored-by: Michael Shilman <[email protected]>
Co-authored-by: Michael Shilman <[email protected]>
Copy link

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Issue Package Version Note Source
New author @storybook/addon-designs 7.0.7
New author json-parse-even-better-errors 3.0.0
New author ignore-walk 6.0.3
New author @npmcli/promise-spawn 7.0.0
New author json-stable-stringify 1.0.2
New author cssstyle 3.0.0
New author npm-packlist 8.0.0
New author flat-cache 3.1.0

Next steps

What is new author?

A new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.

Scrutinize new collaborator additions to packages because they now have the ability to publish code into your dependency tree. Packages should avoid frequent or unnecessary additions or changes to publishing rights.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore [email protected] bar@* or ignore all packages with @SocketSecurity ignore-all

@valentinpalkovic valentinpalkovic merged commit 4dc764f into next Jan 10, 2024
97 of 100 checks passed
@valentinpalkovic valentinpalkovic deleted the valentin/remove-babel-from-webpack5-builder branch January 10, 2024 07:52
@jonniebigodes jonniebigodes mentioned this pull request Jan 31, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decouple compilers from webpack5-builder
3 participants