diff --git a/bin/patches/@wordpress__edit-site@5.15.0.patch b/bin/patches/@wordpress__edit-site@5.15.0.patch new file mode 100644 index 00000000000..ca97ce333e0 --- /dev/null +++ b/bin/patches/@wordpress__edit-site@5.15.0.patch @@ -0,0 +1,44 @@ +diff --git a/build-module/lock-unlock.js b/build-module/lock-unlock.js +index 2265f933ceec19f65ca6776c24c3f88b368d713f..e9e10980bfd1b584ab0a037c3b72edae29a2a26e 100644 +--- a/build-module/lock-unlock.js ++++ b/build-module/lock-unlock.js +@@ -1,9 +1,34 @@ + /** +- * WordPress dependencies ++ * External dependencies + */ + import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis'; +-export const { +- lock, +- unlock +-} = __dangerousOptInToUnstableAPIsOnlyForCoreModules('I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', '@wordpress/edit-site'); ++ ++// 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.', ++ 6.6: 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', ++}; ++ ++function optInToUnstableAPIs() { ++ let error; ++ for ( const optInString of Object.values( wordPressConsentString ) ) { ++ try { ++ return __dangerousOptInToUnstableAPIsOnlyForCoreModules( ++ optInString, ++ '@wordpress/edit-site' ++ ); ++ } catch ( anError ) { ++ error = anError; ++ } ++ } ++ ++ throw error; ++} ++ ++export const { lock, unlock } = optInToUnstableAPIs(); + //# sourceMappingURL=lock-unlock.js.map diff --git a/package.json b/package.json index 8d605e64f3b..dc8abb9f7ee 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,9 @@ "@types/react": "^17.0.71", "react-resize-aware": "3.1.1", "@automattic/tour-kit>@wordpress/element": "4.4.1" + }, + "patchedDependencies": { + "@wordpress/edit-site@5.15.0": "bin/patches/@wordpress__edit-site@5.15.0.patch" } } } diff --git a/plugins/woocommerce-admin/bin/modified-editsite-lock-unlock.js b/plugins/woocommerce-admin/bin/modified-editsite-lock-unlock.js deleted file mode 100644 index e9e10980bfd..00000000000 --- a/plugins/woocommerce-admin/bin/modified-editsite-lock-unlock.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * External dependencies - */ -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.', - 6.6: 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', -}; - -function optInToUnstableAPIs() { - let error; - for ( const optInString of Object.values( wordPressConsentString ) ) { - try { - return __dangerousOptInToUnstableAPIsOnlyForCoreModules( - optInString, - '@wordpress/edit-site' - ); - } catch ( anError ) { - error = anError; - } - } - - throw error; -} - -export const { lock, unlock } = optInToUnstableAPIs(); -//# sourceMappingURL=lock-unlock.js.map diff --git a/plugins/woocommerce-admin/package.json b/plugins/woocommerce-admin/package.json index 6b4cc1fb7f2..dbceeeb74d5 100644 --- a/plugins/woocommerce-admin/package.json +++ b/plugins/woocommerce-admin/package.json @@ -16,7 +16,6 @@ "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", @@ -30,7 +29,6 @@ "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" }, diff --git a/plugins/woocommerce/changelog/dev-webpack-resources-copy-tweaks-2 b/plugins/woocommerce/changelog/dev-webpack-resources-copy-tweaks-2 new file mode 100644 index 00000000000..cdde411c61d --- /dev/null +++ b/plugins/woocommerce/changelog/dev-webpack-resources-copy-tweaks-2 @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Monorepo: refine approach to patching dependecies in favour of built-in pnpm functionality. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 824d2131d0c..08c894afee2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,11 @@ overrides: pnpmfileChecksum: y3ex4x7shfdnqpcpdnu67kmuvu +patchedDependencies: + '@wordpress/edit-site@5.15.0': + hash: 6y3l6gxu33zybfmvbjd23dtqda + path: bin/patches/@wordpress__edit-site@5.15.0.patch + importers: .: