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

Core: Add Babel mode v7 #15928

Merged
merged 14 commits into from
Aug 31, 2021
Merged

Core: Add Babel mode v7 #15928

merged 14 commits into from
Aug 31, 2021

Conversation

shilman
Copy link
Member

@shilman shilman commented Aug 27, 2021

Issue: #14425 #2758 #12745 #15502 #12292

This PR overhauls Storybook's babel handling in preparation for v7.0.

Before:

  • Storybook provides a baseline config
  • User config is inconsistently respected (sometimes respected and sometimes not!)
  • Addons and frameworks add incremental modifications to config
  • Users recommended to override babel in main.js
  • NO debugging methodology

After (when features.babelModeV7 flag is activated):

  • Storybook provides NO baseline config
  • Users can ask Storybook to generate a baseline config file (.babelrc.json)
  • User config is respected
  • Addons and frameworks add incremental modifications to config
  • Users recommended to edit their project babel config, can worst-case override it in main.js webpackFinal
  • Debugging methodology in docs

What I did

  • Add features.babelModeV7
  • Update webpack4/5 builder/manager changes
    • DON'T load storybook babel defaults in the new mode
    • DO configure babel loader to look for the project babelrc/babel config
  • Fix web-components babel handling for consistency
  • Automatically generate babelrc on empty project sb init
  • CLI command for force-generating babelrc
  • Open question: do incremental modifications to babel config actually work??
  • Migration instructions
  • Documentation w/ debug instructions

Potential improvements

  • Fix CLI dependency structure
  • Automatically set V7 feature flag on empty projects

How to test

  • Is this testable with Jest or Chromatic screenshots?
  • Does this need a new example in the kitchen sink apps?
  • Does this need an update to the documentation?

The easiest way to test this is to modify the .babelrc of examples/react-ts, which has babelModeV7 enabled. You can:

  • Manually edit the babelrc
  • Remove the babelrc and generate one using ../../lib/cli/bin/index.js
  • De-activate the babelModeV7 flag
  • Activate the babelModeV7 flag in examples/cra-kitchen-sink

You can also do all of this with BABEL_SHOW_CONFIG_FOR enabled to see what's going on under the hood. But you can't actually run the Storybooks this way -- see the documentation.

If your answer is yes to any of these, please make sure to include it in your PR.

@shilman shilman added configuration babel / webpack maintenance User-facing maintenance tasks labels Aug 27, 2021
@nx-cloud
Copy link

nx-cloud bot commented Aug 27, 2021

Nx Cloud Report

CI ran the following commands for commit e3e0248. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch

Status Command
#000000 nx run-many --target=prepare --all --parallel --max-parallel=15

Sent with 💌 from NxCloud.

@shilman shilman added this to the 6.4 PRs milestone Aug 28, 2021
@shilman shilman marked this pull request as ready for review August 30, 2021 11:35
@shilman shilman changed the title Babel Mode v7 Core: Add Babel mode v7 Aug 30, 2021
@shilman
Copy link
Member Author

shilman commented Aug 31, 2021

self-merging @tmeasday @ndelangen

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.

2 participants