Skip to content

Commit

Permalink
Migrate Storybook to 6.4.0 and enable auto-detection of controls (woo…
Browse files Browse the repository at this point in the history
…commerce#5249) (woocommerce#5264)

* Migrate Storybook to 6.4.0 and enable auto-detection of controls (woocommerce#5249)

Previously our Babel configuration conflicted with the one provided by
default by Storybook, making us unable to leverage the automatic
detection of properties from both JS and TS components to create
controls (formerly known as knobs).

Upgrading to 6.4.0 fixes a bug that makes it easier to work with
Babel configurations. Also done here:

* Removed a few deprecated addons in favor of the replacement ones
bundled within Storybook Essentials.
* Add auto-detection of certain control types depending on the property names
* Add support for TS stories

More context: storybookjs/storybook#12292

* Use `react-docgen` only in development environments

This should reduce production bundle size dramatically. The only
problem here is that Storybook runs its `build` command with the
`NODE_ENV` set to `production`. For this reason, we change the
script to provide `BABEL_ENV` set to `development` to still make sure
the correct configuration is loaded, while trying to reduce any
side-effects on changing the whole `NODE_ENV`.
  • Loading branch information
sunyatasattva authored and jonny-bull committed Dec 16, 2021
1 parent b6b3ee8 commit 7a99147
Show file tree
Hide file tree
Showing 5 changed files with 2,017 additions and 1,629 deletions.
11 changes: 11 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
module.exports = {
env: {
development: {
plugins: [
[
'react-docgen',
{ DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES' },
],
[ '@babel/plugin-syntax-jsx' ],
],
},
},
presets: [
[
'@wordpress/babel-preset-default',
Expand Down
Loading

0 comments on commit 7a99147

Please sign in to comment.