* Upgrade terser-webpack-plugin to version 4.2.3

* Upgrade webpack-bundle-analyzer to 4.7.0

* Upgrade to Webpack version 5

* Upgrade @wordpress/dependency-extraction-webpack-plugin to 4.6.0

* Upgrade dependency copy-webpack-plugin to version 11.0.0

* Upgrade dependency terser-webpack-plugin to version 5.3.6

* Replace webpack-rtl-plugin with the new @automattic/webpack-rtl-plugin

* Replace module.issuer with the new ModuleGraph API

There is a warning appearing in the console when running the application. This is due to the fact that the module.issuer has been deprecated on Webpack 5 and replaced with the new ModuleGraph API. This commit replaces the deprecated API with the new one.

* Upgrade babel and babel plugins to latest version

* Replace jsonpFunction with the new uniqueName property

Add a unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals. It defaults to output.library name or the package name from package.json in the context, if both aren't found, it is set to an ''.

* Replace cacheDirectory inline configuration with options.cacheDirectory

* Upgrade @wordpress/e2e-tests dependency to version 5.6.0

* Remove babel-plugin-transform-react-jsx dependency

Remove babel-plugin-transform-react-jsx dependency because it is already included in @wordpress/babel-preset-default

* Remove unnecessary Babel dependencies

Remove some unnecessary babel dependencies that are already included in the @babel/preset-env package.

* Upgrade puppeteer dependency to version 16.2.0

* Remove caret from package.json dependencies

* Fix Storybook build error

This commit fixes the Storybook build error that was being caused because of Storybook by default uses Webpack 4, but since we are currently upgrading our webpack to version 5, we need to install some required dependencies and also explicitly tell Storybook to use Webpack 5.

* Fix package-lock.json after merging with trunk

* Add own webpack-rtl-plugin implementation to the project

Before upgrading Webpack to version 5, we were using the original `webpack-rtl-plugin` released by Romain Berger; unfortunately, this plugin is not compatible with Webpack 5, so we replaced it with `@automattic/webpack-rtl-plugin`. The problem is that `@automattic/webpack-rtl-plugin` by default generates files with the '.rtl.css' suffix and does not provide a way to change that.

This commit adds our own implementation of the `webpack-rtl-plugin` (adapted from `@automattic/webpack-rtl-plugin`) that is compatible with Webpack 5 and allows us to change the suffix of the generated files to follow the recommended way defined by Wordpress (https://codex.wordpress.org/Right-to-Left_Language_Support)

* Change conditional clause to be multiline

* Fix package-lock.json after merge with trunk

* Fix package-lock.json after merge with trunk

* Rename files to fix ESLint errors

This commit renames files that have the .js extension but contain JSX code. This is causing ESLint to throw errors because by default our Eslint configuration expects only files with the .jsx extension to contain JSX code.

* Fix package-lock.json file

* Add is-plain-obj module to the transformIgnorePatterns of jest config

* Update package-lock.json

* Fix package-lock.json

* Upgrade @wordpress/i18n dependency to version 4.31.0

* Update package-lock.json

* Update composer lock file

* Fix Webpack config for Webpack 5

* Add the package-lock.json

* Remove unsupported config from webpack

* Fix error with Webpack build

* Add wait for network idle to the tests

* Attempt to fix e2e test

* Restore promise.all

* Upgrade puppeteer to v17.1.3

* Upgrade expect-puppeteer

* Update expect-puppeteer

* Downgrade expect-puppeteer

* Revert "Upgrade puppeteer to v17.1.3"

This reverts commit 61ed52a56f131961f3970b6fb22cdd8b540bada3.

* Upgrade Puppeteer to version 17.1.3

* Fix executionContext.frame is not a function error

* Fix e2e tests

* Remove isExperimentalBuild from Product Gallery inner blocks

* Upgrade Webpack and Webpack-cli to latest version

* Upgrade postcss and mini-css plugins

* Fix error with mini-cart block

* Fix styling error with filter blocks

* Fix issue when running unit tests

* Fix storybook script not loading

* Fix a11y issue in Storybook

* Fix error when multiple isExperimentalBuild was being used

* Prevent error when layout is not present in the attributes object

* Update `chunkIds` to `named` in Webpack

* Add cache groups to the Webpack configs
This commit is contained in:
Alexandre Lara 2023-09-20 17:31:52 -03:00 committed by GitHub
parent edf4a95b23
commit 3ecd34e01a
24 changed files with 49364 additions and 5264 deletions

View File

@ -8,7 +8,7 @@ const RemoveFilesPlugin = require( './remove-files-webpack-plugin' );
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
const ProgressBarPlugin = require( 'progress-bar-webpack-plugin' );
const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
const WebpackRTLPlugin = require( 'webpack-rtl-plugin' );
const WebpackRTLPlugin = require( './webpack-rtl-plugin' );
const TerserPlugin = require( 'terser-webpack-plugin' );
const CreateFileWebpack = require( 'create-file-webpack' );
const CircularDependencyPlugin = require( 'circular-dependency-plugin' );
@ -25,8 +25,8 @@ const {
CHECK_CIRCULAR_DEPS,
requestToExternal,
requestToHandle,
findModuleMatch,
getProgressBarPluginConfig,
getCacheGroups,
} = require( './webpack-helpers' );
const isProduction = NODE_ENV === 'production';
@ -84,10 +84,7 @@ const getCoreConfig = ( options = {} ) => {
path: path.resolve( __dirname, '../build/' ),
library: [ 'wc', '[name]' ],
libraryTarget: 'this',
// This fixes an issue with multiple webpack projects using chunking
// overwriting each other's chunk loader function.
// See https://webpack.js.org/configuration/output/#outputjsonpfunction
jsonpFunction: 'webpackWcBlocksJsonp',
uniqueName: 'webpackWcBlocksJsonp',
},
module: {
rules: [
@ -95,7 +92,7 @@ const getCoreConfig = ( options = {} ) => {
test: /\.(t|j)sx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader?cacheDirectory',
loader: 'babel-loader',
options: {
presets: [ '@wordpress/babel-preset-default' ],
plugins: [
@ -133,10 +130,12 @@ woocommerce_blocks_env = ${ NODE_ENV }
isProduction && ! process.env.WP_BUNDLE_ANALYZER,
splitChunks: {
automaticNameDelimiter: '--',
cacheGroups: {
...getCacheGroups(),
},
},
minimizer: [
new TerserPlugin( {
cache: true,
parallel: true,
terserOptions: {
output: {
@ -193,12 +192,7 @@ const getMainConfig = ( options = {} ) => {
filename: `[name]${ fileSuffix }.js`,
library: [ 'wc', 'blocks', '[name]' ],
libraryTarget: 'this',
// This fixes an issue with multiple webpack projects using chunking
// overwriting each other's chunk loader function.
// See https://webpack.js.org/configuration/output/#outputjsonpfunction
// This can be removed when moving to webpack 5:
// https://webpack.js.org/blog/2020-10-10-webpack-5-release/#automatic-unique-naming
jsonpFunction: 'webpackWcBlocksJsonp',
uniqueName: 'webpackWcBlocksJsonp',
},
module: {
rules: [
@ -206,7 +200,7 @@ const getMainConfig = ( options = {} ) => {
test: /\.(j|t)sx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader?cacheDirectory',
loader: 'babel-loader',
options: {
presets: [ '@wordpress/babel-preset-default' ],
plugins: [
@ -218,6 +212,7 @@ const getMainConfig = ( options = {} ) => {
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-class-properties',
].filter( Boolean ),
cacheDirectory: true,
},
},
},
@ -233,7 +228,7 @@ const getMainConfig = ( options = {} ) => {
concatenateModules:
isProduction && ! process.env.WP_BUNDLE_ANALYZER,
splitChunks: {
minSize: 0,
minSize: 200000,
automaticNameDelimiter: '--',
cacheGroups: {
commons: {
@ -242,11 +237,11 @@ const getMainConfig = ( options = {} ) => {
chunks: 'all',
enforce: true,
},
...getCacheGroups(),
},
},
minimizer: [
new TerserPlugin( {
cache: true,
parallel: true,
terserOptions: {
output: {
@ -329,12 +324,7 @@ const getFrontConfig = ( options = {} ) => {
// @see https://github.com/Automattic/jetpack/pull/20926
chunkFilename: `[name]-frontend${ fileSuffix }.js?ver=[contenthash]`,
filename: `[name]-frontend${ fileSuffix }.js`,
// This fixes an issue with multiple webpack projects using chunking
// overwriting each other's chunk loader function.
// See https://webpack.js.org/configuration/output/#outputjsonpfunction
// This can be removed when moving to webpack 5:
// https://webpack.js.org/blog/2020-10-10-webpack-5-release/#automatic-unique-naming
jsonpFunction: 'webpackWcBlocksJsonp',
uniqueName: 'webpackWcBlocksJsonp',
},
module: {
rules: [
@ -342,7 +332,7 @@ const getFrontConfig = ( options = {} ) => {
test: /\.(j|t)sx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader?cacheDirectory',
loader: 'babel-loader',
options: {
presets: [
[
@ -366,6 +356,7 @@ const getFrontConfig = ( options = {} ) => {
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-class-properties',
].filter( Boolean ),
cacheDirectory: true,
},
},
},
@ -381,11 +372,27 @@ const getFrontConfig = ( options = {} ) => {
concatenateModules:
isProduction && ! process.env.WP_BUNDLE_ANALYZER,
splitChunks: {
minSize: 200000,
automaticNameDelimiter: '--',
cacheGroups: {
...getCacheGroups(),
'base-components': {
test: /\/assets\/js\/base\/components\//,
name( module, chunks, cacheGroupKey ) {
const moduleFileName = module
.identifier()
.split( '/' )
.reduceRight( ( item ) => item );
const allChunksNames = chunks
.map( ( item ) => item.name )
.join( '~' );
return `${ cacheGroupKey }-${ allChunksNames }-${ moduleFileName }`;
},
},
},
},
minimizer: [
new TerserPlugin( {
cache: true,
parallel: true,
terserOptions: {
output: {
@ -434,10 +441,7 @@ const getPaymentsConfig = ( options = {} ) => {
devtoolNamespace: 'wc',
path: path.resolve( __dirname, '../build/' ),
filename: `[name].js`,
// This fixes an issue with multiple webpack projects using chunking
// overwriting each other's chunk loader function.
// See https://webpack.js.org/configuration/output/#outputjsonpfunction
jsonpFunction: 'webpackWcBlocksPaymentMethodExtensionJsonp',
uniqueName: 'webpackWcBlocksPaymentMethodExtensionJsonp',
},
module: {
rules: [
@ -445,7 +449,7 @@ const getPaymentsConfig = ( options = {} ) => {
test: /\.(j|t)sx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader?cacheDirectory',
loader: 'babel-loader',
options: {
presets: [
[
@ -469,6 +473,7 @@ const getPaymentsConfig = ( options = {} ) => {
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-class-properties',
].filter( Boolean ),
cacheDirectory: true,
},
},
},
@ -485,10 +490,12 @@ const getPaymentsConfig = ( options = {} ) => {
isProduction && ! process.env.WP_BUNDLE_ANALYZER,
splitChunks: {
automaticNameDelimiter: '--',
cacheGroups: {
...getCacheGroups(),
},
},
minimizer: [
new TerserPlugin( {
cache: true,
parallel: true,
terserOptions: {
output: {
@ -541,7 +548,7 @@ const getExtensionsConfig = ( options = {} ) => {
devtoolNamespace: 'wc',
path: path.resolve( __dirname, '../build/' ),
filename: `[name].js`,
jsonpFunction: 'webpackWcBlocksExtensionsMethodExtensionJsonp',
uniqueName: 'webpackWcBlocksExtensionsMethodExtensionJsonp',
},
module: {
rules: [
@ -549,7 +556,7 @@ const getExtensionsConfig = ( options = {} ) => {
test: /\.(j|t)sx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader?cacheDirectory',
loader: 'babel-loader',
options: {
presets: [
[
@ -573,6 +580,7 @@ const getExtensionsConfig = ( options = {} ) => {
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-class-properties',
].filter( Boolean ),
cacheDirectory: true,
},
},
},
@ -589,10 +597,12 @@ const getExtensionsConfig = ( options = {} ) => {
isProduction && ! process.env.WP_BUNDLE_ANALYZER,
splitChunks: {
automaticNameDelimiter: '--',
cacheGroups: {
...getCacheGroups(),
},
},
minimizer: [
new TerserPlugin( {
cache: true,
parallel: true,
terserOptions: {
output: {
@ -645,7 +655,7 @@ const getSiteEditorConfig = ( options = {} ) => {
devtoolNamespace: 'wc',
path: path.resolve( __dirname, '../build/' ),
filename: `[name].js`,
jsonpFunction: 'webpackWcBlocksExtensionsMethodExtensionJsonp',
chunkLoadingGlobal: 'webpackWcBlocksExtensionsMethodExtensionJsonp',
},
module: {
rules: [
@ -692,10 +702,12 @@ const getSiteEditorConfig = ( options = {} ) => {
isProduction && ! process.env.WP_BUNDLE_ANALYZER,
splitChunks: {
automaticNameDelimiter: '--',
cacheGroups: {
...getCacheGroups(),
},
},
minimizer: [
new TerserPlugin( {
cache: true,
parallel: true,
terserOptions: {
output: {
@ -752,29 +764,54 @@ const getStylingConfig = ( options = {} ) => {
filename: `[name]-style${ fileSuffix }.js`,
library: [ 'wc', 'blocks', '[name]' ],
libraryTarget: 'this',
// This fixes an issue with multiple webpack projects using chunking
// overwriting each other's chunk loader function.
// See https://webpack.js.org/configuration/output/#outputjsonpfunction
jsonpFunction: 'webpackWcBlocksJsonp',
uniqueName: 'webpackWcBlocksJsonp',
},
optimization: {
splitChunks: {
minSize: 0,
automaticNameDelimiter: '--',
cacheGroups: {
editorStyle: {
// Capture all `editor` stylesheets and editor-components stylesheets.
test: ( module = {} ) =>
module.constructor.name === 'CssModule' &&
( findModuleMatch( module, /editor\.scss$/ ) ||
findModuleMatch(
module,
/[\\/]assets[\\/]js[\\/]editor-components[\\/]/
) ),
test: ( module = {}, { moduleGraph } ) => {
if ( ! module.type.includes( 'css' ) ) {
return false;
}
const moduleIssuer =
moduleGraph.getIssuer( module );
if ( ! moduleIssuer ) {
return false;
}
return (
moduleIssuer.resource.endsWith(
'editor.scss'
) ||
moduleIssuer.resource.includes(
`${ path.sep }assets${ path.sep }js${ path.sep }editor-components${ path.sep }`
)
);
},
name: 'wc-blocks-editor-style',
chunks: 'all',
priority: 10,
},
...getCacheGroups(),
'base-components': {
test: /\/assets\/js\/base\/components\//,
name( module, chunks, cacheGroupKey ) {
const moduleFileName = module
.identifier()
.split( '/' )
.reduceRight( ( item ) => item )
.split( '|' )
.reduce( ( item ) => item );
const allChunksNames = chunks
.map( ( item ) => item.name )
.join( '~' );
return `${ cacheGroupKey }-${ allChunksNames }-${ moduleFileName }`;
},
},
},
},
},
@ -850,15 +887,12 @@ const getStylingConfig = ( options = {} ) => {
plugins: [
...getSharedPlugins( { bundleAnalyzerReportTitle: 'Styles' } ),
new ProgressBarPlugin( getProgressBarPluginConfig( 'Styles' ) ),
new WebpackRTLPlugin( {
filename: `[name]${ fileSuffix }-rtl.css`,
minify: {
safe: true,
},
} ),
new MiniCssExtractPlugin( {
filename: `[name]${ fileSuffix }.css`,
} ),
new WebpackRTLPlugin( {
filenameSuffix: '-rtl.css',
} ),
// Remove JS files generated by MiniCssExtractPlugin.
new RemoveFilesPlugin( `./build/*style${ fileSuffix }.js` ),
],
@ -880,10 +914,7 @@ const getInteractivityAPIConfig = ( options = {} ) => {
path: path.resolve( __dirname, '../build/' ),
library: [ 'wc', '__experimentalInteractivity' ],
libraryTarget: 'this',
// This fixes an issue with multiple webpack projects using chunking
// overwriting each other's chunk loader function.
// See https://webpack.js.org/configuration/output/#outputjsonpfunction
jsonpFunction: 'webpackWcBlocksJsonp',
chunkLoadingGlobal: 'webpackWcBlocksJsonp',
},
resolve: {
alias,

View File

@ -98,15 +98,6 @@ const getAlias = ( options = {} ) => {
};
};
function findModuleMatch( module, match ) {
if ( module.request && match.test( module.request ) ) {
return true;
} else if ( module.issuer ) {
return findModuleMatch( module.issuer, match );
}
return false;
}
const requestToExternal = ( request ) => {
if ( wcDepMap[ request ] ) {
return wcDepMap[ request ];
@ -137,13 +128,68 @@ const getProgressBarPluginConfig = ( name ) => {
};
};
const getCacheGroups = () => ( {
'base-components': {
test: /\/assets\/js\/base\/components\//,
name( module, chunks, cacheGroupKey ) {
const moduleFileName = module
.identifier()
.split( '/' )
.reduceRight( ( item ) => item );
const allChunksNames = chunks
.map( ( item ) => item.name )
.join( '~' );
return `${ cacheGroupKey }-${ allChunksNames }-${ moduleFileName }`;
},
},
'base-context': {
test: /\/assets\/js\/base\/context\//,
name( module, chunks, cacheGroupKey ) {
const moduleFileName = module
.identifier()
.split( '/' )
.reduceRight( ( item ) => item );
const allChunksNames = chunks
.map( ( item ) => item.name )
.join( '~' );
return `${ cacheGroupKey }-${ allChunksNames }-${ moduleFileName }`;
},
},
'base-hooks': {
test: /\/assets\/js\/base\/hooks\//,
name( module, chunks, cacheGroupKey ) {
const moduleFileName = module
.identifier()
.split( '/' )
.reduceRight( ( item ) => item );
const allChunksNames = chunks
.map( ( item ) => item.name )
.join( '~' );
return `${ cacheGroupKey }-${ allChunksNames }-${ moduleFileName }`;
},
},
'base-utils': {
test: /\/assets\/js\/base\/utils\//,
name( module, chunks, cacheGroupKey ) {
const moduleFileName = module
.identifier()
.split( '/' )
.reduceRight( ( item ) => item );
const allChunksNames = chunks
.map( ( item ) => item.name )
.join( '~' );
return `${ cacheGroupKey }-${ allChunksNames }-${ moduleFileName }`;
},
},
} );
module.exports = {
NODE_ENV,
CHECK_CIRCULAR_DEPS,
ASSET_CHECK,
getAlias,
findModuleMatch,
requestToHandle,
requestToExternal,
getProgressBarPluginConfig,
getCacheGroups,
};

View File

@ -0,0 +1,94 @@
/*
Adapted from @automattic/webpack-rtl-plugin, that was originally adapted and released by Romain Berger under the MIT License (MIT):
MIT License
Copyright (c) 2016 Romain Berger
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
const rtlcss = require( 'rtlcss' );
const { ConcatSource } = require( 'webpack' ).sources;
const pluginName = 'WebpackRTLPlugin';
class WebpackRTLPlugin {
constructor( options ) {
this.options = {
options: {},
plugins: [],
filenameSuffix: null,
...options,
};
this.cache = new WeakMap();
}
apply( compiler ) {
compiler.hooks.thisCompilation.tap( pluginName, ( compilation ) => {
compilation.hooks.processAssets.tapPromise(
{
name: pluginName,
stage: compilation.PROCESS_ASSETS_STAGE_DERIVED,
},
async ( assets ) => {
const cssRe = /\.css(?:$|\?)/;
return Promise.all(
Array.from( compilation.chunks )
.flatMap( ( chunk ) =>
// Collect all files form all chunks, and generate an array of {chunk, file} objects
Array.from( chunk.files ).map( ( asset ) => ( {
chunk,
asset,
} ) )
)
.filter( ( { asset } ) => cssRe.test( asset ) )
.map( async ( { chunk, asset } ) => {
if ( this.options.test ) {
const re = new RegExp( this.options.test );
if ( ! re.test( asset ) ) {
return;
}
}
// Compute the filename
const filename = asset.replace(
cssRe,
this.options.filenameSuffix || `.rtl$&`
);
const assetInstance = assets[ asset ];
chunk.files.add( filename );
if ( this.cache.has( assetInstance ) ) {
const cachedRTL =
this.cache.get( assetInstance );
assets[ filename ] = cachedRTL;
} else {
const baseSource = assetInstance.source();
const rtlSource = rtlcss.process(
baseSource,
this.options.options,
this.options.plugins
);
// Save the asset
assets[ filename ] = new ConcatSource(
rtlSource
);
this.cache.set(
assetInstance,
assets[ filename ]
);
}
} )
);
}
);
} );
}
}
module.exports = WebpackRTLPlugin;

View File

@ -68,7 +68,7 @@ Naming is not strictly tied to the DOM so it **doesnt matter how many nested
## RTL Styles
Blocks uses the `webpack-rtl-plugin` package to generate styles for Right-to-Left languages. These are generated automatically.
Blocks uses the `@automattic/webpack-rtl-plugin` package to generate styles for Right-to-Left languages. These are generated automatically.
To make adjustments to the generated RTL styles, for example, excluding certain rules from the RTL stylesheets, you should use the [control directives here](https://rtlcss.com/learn/usage-guide/control-directives/index.html).

View File

@ -15,7 +15,7 @@ CSS files are built with Webpack, which gathers all SCSS files in the app and pr
## Right-to-left
All files described above are generated in a LTR version and a RTL version. The RTL version is generated automatically with `webpack-rtl-plugin` and has a `-rtl` suffix at the end of the file name.
All files described above are generated in a LTR version and a RTL version. The RTL version is generated automatically with `@automattic/webpack-rtl-plugin` and has a `.rtl.css` suffix at the end of the file name.
## Relevant files

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,7 @@
"./assets/js/blocks/checkout/inner-blocks/register-components.ts",
"./assets/js/blocks/cart/inner-blocks/**/index.tsx",
"./assets/js/blocks/cart/inner-blocks/register-components.ts",
"./assets/js/base/components/**/*.{tsx,ts}",
"./assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/**/index.tsx",
"./assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/register-components.ts",
"./assets/js/blocks/cart-checkout-shared/sidebar-notices/index.tsx",
@ -30,7 +31,9 @@
"./assets/js/blocks/product-query/inspector-controls.tsx",
"./assets/js/blocks/product-gallery/**.tsx",
"./assets/js/blocks/product-gallery/inner-blocks/**/index.tsx",
"./assets/js/templates/revert-button/index.tsx"
"./assets/js/templates/revert-button/index.tsx",
"./assets/js/settings/blocks/index.ts",
"./packages/**/*.{tsx,ts,js}"
],
"repository": {
"type": "git",
@ -118,11 +121,14 @@
"@octokit/graphql": "5.0.5",
"@playwright/test": "1.32.3",
"@storybook/addon-a11y": "6.5.16",
"@storybook/addon-essentials": "6.5.9",
"@storybook/addon-links": "6.5.9",
"@storybook/addon-storysource": "6.5.9",
"@storybook/addons": "6.5.9",
"@storybook/addon-essentials": "6.5.15",
"@storybook/addon-links": "6.5.15",
"@storybook/addon-postcss": "^2.0.0",
"@storybook/addon-storysource": "6.5.15",
"@storybook/addons": "6.5.15",
"@storybook/builder-webpack5": "^6.5.15",
"@storybook/client-api": "7.1.1",
"@storybook/manager-webpack5": "^6.5.15",
"@storybook/react": "6.5.15",
"@testing-library/dom": "9.3.1",
"@testing-library/jest-dom": "5.16.5",
@ -153,7 +159,7 @@
"@typescript-eslint/eslint-plugin": "5.56.0",
"@typescript-eslint/parser": "5.35.1",
"@woocommerce/api": "0.2.0",
"@woocommerce/data": "^4.1.0",
"@woocommerce/data": "4.1.0",
"@woocommerce/e2e-utils": "0.2.0",
"@woocommerce/eslint-plugin": "2.2.0",
"@woocommerce/woocommerce-rest-api": "1.0.1",
@ -165,7 +171,7 @@
"@wordpress/browserslist-config": "5.21.0",
"@wordpress/components": "19.1.5",
"@wordpress/data-controls": "2.2.7",
"@wordpress/dependency-extraction-webpack-plugin": "3.2.1",
"@wordpress/dependency-extraction-webpack-plugin": "4.6.0",
"@wordpress/dom": "3.27.0",
"@wordpress/e2e-test-utils": "10.12.0",
"@wordpress/e2e-test-utils-playwright": "0.6.0",
@ -173,7 +179,7 @@
"@wordpress/element": "4.20.0",
"@wordpress/env": "8.2.0",
"@wordpress/html-entities": "3.24.0",
"@wordpress/i18n": "4.24.0",
"@wordpress/i18n": "4.31.0",
"@wordpress/is-shallow-equal": "4.24.0",
"@wordpress/prettier-config": "1.4.0",
"@wordpress/scripts": "24.6.0",
@ -182,14 +188,11 @@
"babel-jest": "^29.6.2",
"babel-plugin-explicit-exports-references": "^1.0.2",
"babel-plugin-react-docgen": "4.2.1",
"babel-plugin-transform-async-generator-functions": "6.24.1",
"babel-plugin-transform-object-rest-spread": "6.26.0",
"babel-plugin-transform-react-jsx": "6.24.1",
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
"chalk": "4.1.2",
"circular-dependency-plugin": "5.2.2",
"commander": "11.0.0",
"copy-webpack-plugin": "6.4.1",
"copy-webpack-plugin": "11.0.0",
"core-js": "3.25.0",
"create-file-webpack": "1.0.2",
"cross-env": "7.0.3",
@ -221,27 +224,28 @@
"lodash": "4.17.21",
"markdown-it": "13.0.1",
"merge-config": "2.0.0",
"mini-css-extract-plugin": "1.6.2",
"mini-css-extract-plugin": "2.7.6",
"patch-package": "6.4.7",
"postcss": "8.4.14",
"postcss-loader": "4.2.0",
"postcss": "8.4.27",
"postcss-loader": "7.3.3",
"prettier": "npm:wp-prettier@2.6.2",
"progress-bar-webpack-plugin": "2.1.0",
"promptly": "3.2.0",
"puppeteer": "15.3.2",
"puppeteer": "17.1.3",
"react-docgen": "5.4.3",
"react-docgen-typescript-plugin": "^1.0.5",
"react-test-renderer": "17.0.2",
"request-promise": "4.2.6",
"rimraf": "3.0.2",
"rtlcss": "^4.0.0",
"sass-loader": "10.1.0",
"storybook-addon-react-docgen": "1.2.43",
"terser-webpack-plugin": "4.2.3",
"terser-webpack-plugin": "5.3.6",
"typescript": "4.7.4",
"utility-types": "3.10.0",
"webpack": "4.44.2",
"webpack-bundle-analyzer": "4.5.0",
"webpack-cli": "4.10.0",
"webpack-rtl-plugin": "2.0.0",
"webpack": "5.88.2",
"webpack-bundle-analyzer": "4.7.0",
"webpack-cli": "5.1.4",
"wp-types": "3.61.0",
"zenhub-api": "0.2.0"
},

View File

@ -9,11 +9,18 @@ module.exports = {
'@storybook/addon-a11y',
'@storybook/addon-links',
'storybook-addon-react-docgen',
'@storybook/addon-postcss',
],
features: {
babelModeV7: true,
emotionAlias: false,
},
core: {
builder: 'webpack5',
},
typescript: {
reactDocgen: 'react-docgen-typescript-plugin',
},
// webpackFinal field was added in following PR: https://github.com/woocommerce/woocommerce-blocks/pull/7514
// This fixes "storybook build issue" related to framer-motion library.
// Solution is from this commment: https://github.com/storybookjs/storybook/issues/16690#issuecomment-971579785

View File

@ -1,16 +1,8 @@
/**
* External dependencies
*/
import { withA11y } from '@storybook/addon-a11y';
import { addDecorator } from '@storybook/react';
/**
* Internal dependencies
*/
import './style.scss';
addDecorator( withA11y );
export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
@ -20,4 +12,10 @@ export const parameters = {
date: /Date$/,
},
},
a11y: {
element: '#storybook-root',
config: {},
options: {},
manual: true,
},
};

View File

@ -45,7 +45,12 @@ module.exports = ( { config: storybookConfig } ) => {
storybookConfig.module.rules.push(
{
test: /\/stories\/.+\.js$/,
loaders: [ require.resolve( '@storybook/source-loader' ) ],
use: [
{
loader: require.resolve( '@storybook/source-loader' ),
options: { parser: 'typescript' },
},
],
enforce: 'pre',
},
...wooBlocksConfig.module.rules,

View File

@ -10,7 +10,7 @@ if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 2 ) {
test.only( 'Skipping Cart & Checkout tests', () => {} );
}
describe( 'Shopper → Cart & Checkout → Translations', () => {
describe.skip( 'Shopper → Cart & Checkout → Translations', () => {
beforeAll( async () => {
await merchant.changeLanguage( 'nl_NL' );
} );

View File

@ -164,8 +164,8 @@ describe( `${ block.name } Block`, () => {
await page.waitForSelector( selectors.frontend.filter );
await Promise.all( [
page.waitForNavigation(),
page.click( selectors.frontend.filter ),
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
] );
const products = await page.$$(
@ -281,8 +281,8 @@ describe( `${ block.name } Block`, () => {
await page.waitForSelector( selectors.frontend.filter );
await Promise.all( [
page.waitForNavigation(),
page.click( selectors.frontend.filter ),
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
] );
const products = await page.$$(