Monorepo: rework deps patching in admin plugin for better Webpack performance. (#49703)

* Monorepo: rework deps patching in admin plugin.

* Monorepo: changelog entry.
This commit is contained in:
Vladimir Reznichenko 2024-07-23 21:27:42 +02:00 committed by GitHub
parent efa506afdb
commit 4ae9dee2e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 10 deletions

View File

@ -3,6 +3,11 @@
*/
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
// Workaround for Gutenberg private API consent string differences between WP 6.3 and 6.4+
// The modified version checks for the WP version and replaces the consent string with the correct one.
// This can be removed once we drop support for WP 6.3 in the "Customize Your Store" task.
// See this PR for details: https://github.com/woocommerce/woocommerce/pull/40884
const wordPressConsentString = {
6.4: 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',
6.5: 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',

View File

@ -16,6 +16,7 @@
"build": "pnpm --if-present --workspace-concurrency=Infinity --stream --filter=\"$npm_package_name...\" '/^build:project:.*$/'",
"build:project": "pnpm --if-present '/^build:project:.*$/'",
"build:project:bundle": "wireit",
"build:project:patch-dependecies": "cp ./bin/modified-editsite-lock-unlock.js ./node_modules/@wordpress/edit-site/build-module/lock-unlock.js",
"build:project:feature-config": "php ../woocommerce/bin/generate-feature-config.php",
"changelog": "XDEBUG_MODE=off composer install --quiet && composer exec -- changelogger",
"example": "webpack --config docs/examples/extensions/examples.config.js",
@ -29,6 +30,7 @@
"watch:build": "pnpm --if-present --workspace-concurrency=Infinity --filter=\"$npm_package_name...\" --parallel '/^watch:build:project:.*$/'",
"watch:build:project": "pnpm --if-present run '/^watch:build:project:.*$/'",
"watch:build:project:bundle": "wireit",
"watch:build:project:patch-dependecies": "cp ./bin/modified-editsite-lock-unlock.js ./node_modules/@wordpress/edit-site/build-module/lock-unlock.js",
"watch:build:project:feature-config": "WC_ADMIN_PHASE=development php ../woocommerce/bin/generate-feature-config.php",
"postinstall": "node ./bin/xstate5-react-script.js"
},

View File

@ -10,8 +10,6 @@ const BundleAnalyzerPlugin =
const MomentTimezoneDataPlugin = require( 'moment-timezone-data-webpack-plugin' );
const ForkTsCheckerWebpackPlugin = require( 'fork-ts-checker-webpack-plugin' );
const ReactRefreshWebpackPlugin = require( '@pmmmwh/react-refresh-webpack-plugin' );
const NormalModuleReplacementPlugin =
require( 'webpack' ).NormalModuleReplacementPlugin;
/**
* Internal dependencies
@ -184,14 +182,6 @@ const webpackConfig = {
},
},
plugins: [
// Workaround for Gutenberg private API consent string differences between WP 6.3 and 6.4+
// The modified version checks for the WP version and replaces the consent string with the correct one.
// This can be removed once we drop support for WP 6.3 in the "Customize Your Store" task.
// See this PR for details: https://github.com/woocommerce/woocommerce/pull/40884
new NormalModuleReplacementPlugin(
/@wordpress\/edit-site\/build-module\/lock-unlock\.js/,
path.resolve( __dirname, 'bin/modified-editsite-lock-unlock.js' )
),
...styleConfig.plugins,
// Runs TypeScript type checker on a separate process.
! process.env.STORYBOOK && new ForkTsCheckerWebpackPlugin(),

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Monorepo: tweak patching dependencies for better Webpack perfromance.