Add @babel/plugin-proposal-class-properties to run storybook (#35867)

* Add @babel/plugin-proposal-class-properties to run storybook

* Add @babel/plugin-proposal-class-properties to webpack config and remove storybook env from babel config

* Add changelog
This commit is contained in:
Chi-Hsuan Huang 2022-12-07 22:26:02 +08:00 committed by GitHub
parent 0b3a0516d0
commit 1fbe5d330d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 25 deletions

View File

@ -23,28 +23,6 @@ module.exports = function ( api ) {
ignore: [ 'packages/**/node_modules' ], ignore: [ 'packages/**/node_modules' ],
env: { env: {
production: {}, production: {},
storybook: {
plugins: [
/**
* We need to set loose mode here because the storybook's default babel config enables the loose mode.
* The 'loose' mode configuration must be the same for those babel plugins.
*
*/
[
'@babel/plugin-proposal-class-properties',
{ loose: true },
],
[
'@babel/plugin-proposal-private-methods',
{ loose: true },
],
[
'@babel/plugin-proposal-private-property-in-object',
{ loose: true },
],
],
},
}, },
}; };
}; };

View File

@ -124,6 +124,7 @@ const webpackConfig = {
], ],
[ '@babel/preset-typescript' ], [ '@babel/preset-typescript' ],
], ],
plugins: [ '@babel/plugin-proposal-class-properties' ],
}, },
}, },
}, },

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Remove storybook env from babel config and add babel class-properties to webpack

View File

@ -2018,6 +2018,7 @@ importers:
tools/storybook: tools/storybook:
specifiers: specifiers:
'@babel/plugin-proposal-class-properties': ^7.16.7
'@babel/preset-env': ^7.16.11 '@babel/preset-env': ^7.16.11
'@babel/preset-typescript': ^7.16.7 '@babel/preset-typescript': ^7.16.7
'@babel/runtime': ^7.17.2 '@babel/runtime': ^7.17.2
@ -2046,6 +2047,7 @@ importers:
dependencies: dependencies:
'@babel/preset-typescript': 7.16.7_@babel+core@7.17.8 '@babel/preset-typescript': 7.16.7_@babel+core@7.17.8
devDependencies: devDependencies:
'@babel/plugin-proposal-class-properties': 7.18.6_@babel+core@7.17.8
'@babel/preset-env': 7.16.11_@babel+core@7.17.8 '@babel/preset-env': 7.16.11_@babel+core@7.17.8
'@babel/runtime': 7.17.7 '@babel/runtime': 7.17.7
'@storybook/addon-a11y': 6.4.19_sfoxds7t5ydpegc3knd667wn6m '@storybook/addon-a11y': 6.4.19_sfoxds7t5ydpegc3knd667wn6m

View File

@ -24,6 +24,7 @@
"storybook-rtl": "USE_RTL_STYLE=true pnpm run storybook" "storybook-rtl": "USE_RTL_STYLE=true pnpm run storybook"
}, },
"devDependencies": { "devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/preset-env": "^7.16.11", "@babel/preset-env": "^7.16.11",
"@babel/runtime": "^7.17.2", "@babel/runtime": "^7.17.2",
"@storybook/addon-a11y": "^6.4.19", "@storybook/addon-a11y": "^6.4.19",

View File

@ -30,9 +30,8 @@ module.exports = ( storybookConfig ) => {
storybookConfig.resolve.alias = wcAdminWebpackConfig.resolve.alias; storybookConfig.resolve.alias = wcAdminWebpackConfig.resolve.alias;
wcAdminPackages.forEach( ( name ) => { wcAdminPackages.forEach( ( name ) => {
storybookConfig.resolve.alias[ storybookConfig.resolve.alias[ `@woocommerce/${ name }` ] =
`@woocommerce/${ name }` path.resolve( __dirname, `../../packages/js/${ name }/src` );
] = path.resolve( __dirname, `../../packages/js/${ name }/src` );
} ); } );
storybookConfig.resolve.alias[ '@woocommerce/settings' ] = path.resolve( storybookConfig.resolve.alias[ '@woocommerce/settings' ] = path.resolve(