From c6199a1c20a1c19d27cf1e7c710672044c929352 Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Thu, 10 Sep 2026 16:56:47 -0300 Subject: [PATCH 1/3] Webpack config: move the @wordpress/theme bundling rule into the shared default Three webpack configs each carried the same `DependencyExtractionPlugin` override for `@wordpress/theme` and `@wordpress/private-apis`, with the rationale written out four times. The rule now lives once in `defaultRequestMap`, which merges under every caller's own `requestMap`. The Jetpack plugin's AI admin and email design editor entries opt `@wordpress/private-apis` back out with an empty entry: both unlock private APIs exposed by external WordPress packages, so their consent map has to stay external. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01SWVs5oUDimen1FeGJhJAkx --- .../update-webpack-config-default-request-map | 5 ++++ .../js-packages/webpack-config/src/webpack.js | 7 ++++++ .../update-webpack-config-default-request-map | 5 ++++ .../search/tools/webpack.dashboard.config.js | 9 ------- .../update-webpack-config-default-request-map | 5 ++++ projects/plugins/boost/webpack.config.js | 9 ------- .../update-webpack-config-default-request-map | 5 ++++ .../plugins/jetpack/tools/webpack.config.js | 25 ++++++------------- 8 files changed, 35 insertions(+), 35 deletions(-) create mode 100644 projects/js-packages/webpack-config/changelog/update-webpack-config-default-request-map create mode 100644 projects/packages/search/changelog/update-webpack-config-default-request-map create mode 100644 projects/plugins/boost/changelog/update-webpack-config-default-request-map create mode 100644 projects/plugins/jetpack/changelog/update-webpack-config-default-request-map diff --git a/projects/js-packages/webpack-config/changelog/update-webpack-config-default-request-map b/projects/js-packages/webpack-config/changelog/update-webpack-config-default-request-map new file mode 100644 index 000000000000..3df1d1a4b7cb --- /dev/null +++ b/projects/js-packages/webpack-config/changelog/update-webpack-config-default-request-map @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Move the @wordpress/theme + @wordpress/private-apis bundling rule into the shared webpack config default. + + diff --git a/projects/js-packages/webpack-config/src/webpack.js b/projects/js-packages/webpack-config/src/webpack.js index 5b7102e17310..87e3b224266d 100644 --- a/projects/js-packages/webpack-config/src/webpack.js +++ b/projects/js-packages/webpack-config/src/webpack.js @@ -144,9 +144,16 @@ const defaultRequestMap = { external: 'JetpackSharedStores', handle: 'jetpack-shared-stores', }, + // @wordpress/ui pulls both in transitively, and externalizing them targets script + // handles most admin pages never register, so the whole bundle fails to enqueue. + // Bundle them jointly: split, @wordpress/theme's module-scope lock() and + // @wordpress/private-apis' per-instance consent map diverge. See PR #48173. + '@wordpress/theme': { external: false }, + '@wordpress/private-apis': { external: false }, }; const DependencyExtractionPlugin = ( { requestMap, ...options } = {} ) => { + // A caller's entry wins over the default; an empty entry restores the plugin's own handling. const finalRequestMap = { ...defaultRequestMap, ...requestMap }; const requestToExternal = request => { diff --git a/projects/packages/search/changelog/update-webpack-config-default-request-map b/projects/packages/search/changelog/update-webpack-config-default-request-map new file mode 100644 index 000000000000..3df1d1a4b7cb --- /dev/null +++ b/projects/packages/search/changelog/update-webpack-config-default-request-map @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Move the @wordpress/theme + @wordpress/private-apis bundling rule into the shared webpack config default. + + diff --git a/projects/packages/search/tools/webpack.dashboard.config.js b/projects/packages/search/tools/webpack.dashboard.config.js index 00e03958c618..2c92aae95acf 100644 --- a/projects/packages/search/tools/webpack.dashboard.config.js +++ b/projects/packages/search/tools/webpack.dashboard.config.js @@ -36,15 +36,6 @@ module.exports = { ...jetpackWebpackConfig.StandardPlugins( { DependencyExtractionPlugin: { injectPolyfill: true, - // Match Boost / Jetpack AI admin: @wordpress/ui pulls these in transitively; - // they are not reliably registered as WP script handles in all contexts, so - // bundle them together instead of externalizing. Both must be bundled jointly - // so @wordpress/theme's module-init lock() lands on the same private-apis - // consent map. See PR #48173. - requestMap: { - '@wordpress/theme': { external: false }, - '@wordpress/private-apis': { external: false }, - }, }, } ), ], diff --git a/projects/plugins/boost/changelog/update-webpack-config-default-request-map b/projects/plugins/boost/changelog/update-webpack-config-default-request-map new file mode 100644 index 000000000000..3df1d1a4b7cb --- /dev/null +++ b/projects/plugins/boost/changelog/update-webpack-config-default-request-map @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Move the @wordpress/theme + @wordpress/private-apis bundling rule into the shared webpack config default. + + diff --git a/projects/plugins/boost/webpack.config.js b/projects/plugins/boost/webpack.config.js index 6aacb76dec6c..e471c07ddf08 100644 --- a/projects/plugins/boost/webpack.config.js +++ b/projects/plugins/boost/webpack.config.js @@ -82,15 +82,6 @@ module.exports = [ MiniCssExtractPlugin: { filename: 'jetpack-boost.css', }, - DependencyExtractionPlugin: { - requestMap: { - // Bundle @wordpress/theme and @wordpress/private-apis inline — - // they're transitive deps of @wordpress/ui but aren't registered - // as script handles in WP core, so externalizing them breaks enqueue. - '@wordpress/theme': { external: false }, - '@wordpress/private-apis': { external: false }, - }, - }, } ), new webpack.ProvidePlugin( { process: require.resolve( 'process/browser' ), diff --git a/projects/plugins/jetpack/changelog/update-webpack-config-default-request-map b/projects/plugins/jetpack/changelog/update-webpack-config-default-request-map new file mode 100644 index 000000000000..caf14927191d --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-webpack-config-default-request-map @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Move the @wordpress/theme + @wordpress/private-apis bundling rule into the shared webpack config default. + + diff --git a/projects/plugins/jetpack/tools/webpack.config.js b/projects/plugins/jetpack/tools/webpack.config.js index cbd6977ef13a..3df4242854aa 100644 --- a/projects/plugins/jetpack/tools/webpack.config.js +++ b/projects/plugins/jetpack/tools/webpack.config.js @@ -187,6 +187,9 @@ module.exports = [ // externalize to. Belongs in the dep-extraction plugin's // `BUNDLED_PACKAGES` but isn't there as of 6.54.0, so opt it out here. '@wordpress/global-styles-engine': { external: false }, + // Opts out of the shared default: the editor packages this entry unlocks + // private APIs from are external, so their consent map has to be too. + '@wordpress/private-apis': {}, }, } ), ], @@ -230,18 +233,7 @@ module.exports = [ }, plugins: [ ...sharedWebpackConfig.plugins, - ...jetpackWebpackConfig.DependencyExtractionPlugin( { - // Match the AI admin build: @wordpress/ui (pulled in via the licensing - // activation screen) drags in @wordpress/theme and @wordpress/private-apis. - // They are not registered as WP script handles on the main Jetpack admin - // path (WP < 7.0 has no core wp-theme, and this page does not load the - // wp-build-polyfills shim), so bundle them instead of externalizing to - // avoid the whole dashboard script failing to enqueue. - requestMap: { - '@wordpress/theme': { external: false }, - '@wordpress/private-apis': { external: false }, - }, - } ), + ...jetpackWebpackConfig.DependencyExtractionPlugin(), ], externals: { ...sharedWebpackConfig.externals, @@ -259,12 +251,11 @@ module.exports = [ plugins: [ ...sharedWebpackConfig.plugins, ...jetpackWebpackConfig.DependencyExtractionPlugin( { - // @wordpress/ui pulls in @wordpress/theme, which is not a reliable WP script - // handle in all contexts, so bundle it instead of externalizing it. Keep - // @wordpress/private-apis external so bundled DataViews can unlock private APIs - // exposed by external WordPress packages such as @wordpress/components. + // Opts out of the shared default: bundled DataViews unlocks private APIs + // exposed by external WordPress packages such as @wordpress/components, so + // @wordpress/private-apis has to stay on the shared external consent map. requestMap: { - '@wordpress/theme': { external: false }, + '@wordpress/private-apis': {}, }, } ), ], From b0827511634021abc592193a432cbfb59b451497 Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Thu, 10 Sep 2026 18:39:25 -0300 Subject: [PATCH 2/3] Webpack config: replace the default flip with an opt-in bundleWpUiDeps option The earlier approach added @wordpress/theme and @wordpress/private-apis to defaultRequestMap. That changed every consumer: it broke the packages/jetpack-mu-wpcom build, broke three packages/wp-build-polyfills tests, needed two opt-outs inside the Jetpack plugin config, and grew two bundles. DependencyExtractionPlugin now takes bundleWpUiDeps, off by default, so nothing changes unless a call site asks. The four call sites that carried the nine-line requestMap block verbatim now set the flag instead. jetpack-ai-admin keeps its own requestMap, because it bundles @wordpress/theme alone. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01SWVs5oUDimen1FeGJhJAkx --- projects/js-packages/webpack-config/README.md | 3 +- .../update-webpack-config-default-request-map | 2 +- .../js-packages/webpack-config/src/webpack.js | 30 ++++++++++++++----- .../update-webpack-config-default-request-map | 2 +- .../search/tools/webpack.dashboard.config.js | 1 + .../update-webpack-config-default-request-map | 2 +- projects/plugins/boost/webpack.config.js | 3 ++ .../update-webpack-config-default-request-map | 2 +- .../plugins/jetpack/tools/webpack.config.js | 19 +++++++----- .../update-webpack-config-default-request-map | 5 ++++ projects/plugins/protect/webpack.config.js | 6 +--- 11 files changed, 50 insertions(+), 25 deletions(-) create mode 100644 projects/plugins/protect/changelog/update-webpack-config-default-request-map diff --git a/projects/js-packages/webpack-config/README.md b/projects/js-packages/webpack-config/README.md index 3db2347aa2e6..6ea6e442c680 100644 --- a/projects/js-packages/webpack-config/README.md +++ b/projects/js-packages/webpack-config/README.md @@ -226,9 +226,10 @@ By default, the following additional dependencies are extracted: - `@automattic/jetpack-connection`: Handle `jetpack-connection` provided by PHP package [automattic/jetpack-connection](https://packagist.org/packages/automattic/jetpack-connection). - `@automattic/jetpack-shared-stores`: Handle `jetpack-shared-stores` provided by PHP package [automattic/jetpack-assets](https://packagist.org/packages/automattic/jetpack-assets). The shared data stores resolve to one externalized bundle so they register only once. -One additional option is recognized: +Two additional options are recognized: - `requestMap`: An easier way to specify additional dependencies to extract, rather than redefining `requestToHandle` and `requestToExternal`. Key is the dependency, value is an object with `handle` and `external` keys corresponding to the return values of `requestToHandle` and `requestToExternal`. +- `bundleWpUiDeps`: Bundle `@wordpress/theme` and `@wordpress/private-apis` instead of externalizing them to the `wp-theme` and `wp-private-apis` script handles. Defaults to `false`. Set it to `true` on an entry that renders `@wordpress/ui` on a page that registers neither handle, otherwise the whole bundle fails to enqueue. The pair is bundled jointly on purpose: see [#48173](https://github.com/Automattic/jetpack/pull/48173). Your own `requestMap` still wins over it. ##### `DuplicatePackageCheckerPlugin( options )` diff --git a/projects/js-packages/webpack-config/changelog/update-webpack-config-default-request-map b/projects/js-packages/webpack-config/changelog/update-webpack-config-default-request-map index 3df1d1a4b7cb..f262392c91bb 100644 --- a/projects/js-packages/webpack-config/changelog/update-webpack-config-default-request-map +++ b/projects/js-packages/webpack-config/changelog/update-webpack-config-default-request-map @@ -1,5 +1,5 @@ Significance: patch Type: changed -Comment: Move the @wordpress/theme + @wordpress/private-apis bundling rule into the shared webpack config default. +Comment: Replace the duplicated DependencyExtractionPlugin requestMap block with an opt-in bundleWpUiDeps option. No build output changes. diff --git a/projects/js-packages/webpack-config/src/webpack.js b/projects/js-packages/webpack-config/src/webpack.js index 87e3b224266d..b48242aa82ed 100644 --- a/projects/js-packages/webpack-config/src/webpack.js +++ b/projects/js-packages/webpack-config/src/webpack.js @@ -144,17 +144,33 @@ const defaultRequestMap = { external: 'JetpackSharedStores', handle: 'jetpack-shared-stores', }, - // @wordpress/ui pulls both in transitively, and externalizing them targets script - // handles most admin pages never register, so the whole bundle fails to enqueue. - // Bundle them jointly: split, @wordpress/theme's module-scope lock() and - // @wordpress/private-apis' per-instance consent map diverge. See PR #48173. +}; + +// @wordpress/ui pulls these in transitively; externalizing them targets script handles many pages +// never register, so the whole bundle fails to enqueue. Bundle the pair jointly — split, the +// module-scope lock() in @wordpress/theme and the per-instance consent map in +// @wordpress/private-apis diverge at runtime. See PR #48173. +const wpUiRequestMap = { '@wordpress/theme': { external: false }, '@wordpress/private-apis': { external: false }, }; -const DependencyExtractionPlugin = ( { requestMap, ...options } = {} ) => { - // A caller's entry wins over the default; an empty entry restores the plugin's own handling. - const finalRequestMap = { ...defaultRequestMap, ...requestMap }; +/** + * Build the DependencyExtractionWebpackPlugin. + * + * @param {object} options - Plugin options, passed through except for the two below. + * @param {object} options.requestMap - Per-request `{ external, handle }` overrides. Wins over every default. + * @param {boolean} options.bundleWpUiDeps - Bundle `@wordpress/theme` and `@wordpress/private-apis` instead of + * externalizing them. Off by default; set it on an entry that renders + * `@wordpress/ui` on a page that registers neither script handle. + * @return {object[]} The plugin. + */ +const DependencyExtractionPlugin = ( { requestMap, bundleWpUiDeps = false, ...options } = {} ) => { + const finalRequestMap = { + ...defaultRequestMap, + ...( bundleWpUiDeps ? wpUiRequestMap : {} ), + ...requestMap, + }; const requestToExternal = request => { return finalRequestMap[ request ]?.external; diff --git a/projects/packages/search/changelog/update-webpack-config-default-request-map b/projects/packages/search/changelog/update-webpack-config-default-request-map index 3df1d1a4b7cb..f262392c91bb 100644 --- a/projects/packages/search/changelog/update-webpack-config-default-request-map +++ b/projects/packages/search/changelog/update-webpack-config-default-request-map @@ -1,5 +1,5 @@ Significance: patch Type: changed -Comment: Move the @wordpress/theme + @wordpress/private-apis bundling rule into the shared webpack config default. +Comment: Replace the duplicated DependencyExtractionPlugin requestMap block with an opt-in bundleWpUiDeps option. No build output changes. diff --git a/projects/packages/search/tools/webpack.dashboard.config.js b/projects/packages/search/tools/webpack.dashboard.config.js index 2c92aae95acf..acdf27a4000b 100644 --- a/projects/packages/search/tools/webpack.dashboard.config.js +++ b/projects/packages/search/tools/webpack.dashboard.config.js @@ -36,6 +36,7 @@ module.exports = { ...jetpackWebpackConfig.StandardPlugins( { DependencyExtractionPlugin: { injectPolyfill: true, + bundleWpUiDeps: true, }, } ), ], diff --git a/projects/plugins/boost/changelog/update-webpack-config-default-request-map b/projects/plugins/boost/changelog/update-webpack-config-default-request-map index 3df1d1a4b7cb..f262392c91bb 100644 --- a/projects/plugins/boost/changelog/update-webpack-config-default-request-map +++ b/projects/plugins/boost/changelog/update-webpack-config-default-request-map @@ -1,5 +1,5 @@ Significance: patch Type: changed -Comment: Move the @wordpress/theme + @wordpress/private-apis bundling rule into the shared webpack config default. +Comment: Replace the duplicated DependencyExtractionPlugin requestMap block with an opt-in bundleWpUiDeps option. No build output changes. diff --git a/projects/plugins/boost/webpack.config.js b/projects/plugins/boost/webpack.config.js index e471c07ddf08..1c816a31cb0e 100644 --- a/projects/plugins/boost/webpack.config.js +++ b/projects/plugins/boost/webpack.config.js @@ -82,6 +82,9 @@ module.exports = [ MiniCssExtractPlugin: { filename: 'jetpack-boost.css', }, + DependencyExtractionPlugin: { + bundleWpUiDeps: true, + }, } ), new webpack.ProvidePlugin( { process: require.resolve( 'process/browser' ), diff --git a/projects/plugins/jetpack/changelog/update-webpack-config-default-request-map b/projects/plugins/jetpack/changelog/update-webpack-config-default-request-map index caf14927191d..cd7f9000fed9 100644 --- a/projects/plugins/jetpack/changelog/update-webpack-config-default-request-map +++ b/projects/plugins/jetpack/changelog/update-webpack-config-default-request-map @@ -1,5 +1,5 @@ Significance: patch Type: other -Comment: Move the @wordpress/theme + @wordpress/private-apis bundling rule into the shared webpack config default. +Comment: Replace the duplicated DependencyExtractionPlugin requestMap block with an opt-in bundleWpUiDeps option. No build output changes. diff --git a/projects/plugins/jetpack/tools/webpack.config.js b/projects/plugins/jetpack/tools/webpack.config.js index 3df4242854aa..50ce26c45c7f 100644 --- a/projects/plugins/jetpack/tools/webpack.config.js +++ b/projects/plugins/jetpack/tools/webpack.config.js @@ -187,9 +187,6 @@ module.exports = [ // externalize to. Belongs in the dep-extraction plugin's // `BUNDLED_PACKAGES` but isn't there as of 6.54.0, so opt it out here. '@wordpress/global-styles-engine': { external: false }, - // Opts out of the shared default: the editor packages this entry unlocks - // private APIs from are external, so their consent map has to be too. - '@wordpress/private-apis': {}, }, } ), ], @@ -233,7 +230,12 @@ module.exports = [ }, plugins: [ ...sharedWebpackConfig.plugins, - ...jetpackWebpackConfig.DependencyExtractionPlugin(), + ...jetpackWebpackConfig.DependencyExtractionPlugin( { + // The licensing activation screen pulls in @wordpress/ui, and this page + // registers neither handle: WP < 7.0 has no core wp-theme, and the + // wp-build-polyfills shim is not loaded here. + bundleWpUiDeps: true, + } ), ], externals: { ...sharedWebpackConfig.externals, @@ -251,11 +253,12 @@ module.exports = [ plugins: [ ...sharedWebpackConfig.plugins, ...jetpackWebpackConfig.DependencyExtractionPlugin( { - // Opts out of the shared default: bundled DataViews unlocks private APIs - // exposed by external WordPress packages such as @wordpress/components, so - // @wordpress/private-apis has to stay on the shared external consent map. + // @wordpress/ui pulls in @wordpress/theme, which is not a reliable WP script + // handle in all contexts, so bundle it instead of externalizing it. Keep + // @wordpress/private-apis external so bundled DataViews can unlock private APIs + // exposed by external WordPress packages such as @wordpress/components. requestMap: { - '@wordpress/private-apis': {}, + '@wordpress/theme': { external: false }, }, } ), ], diff --git a/projects/plugins/protect/changelog/update-webpack-config-default-request-map b/projects/plugins/protect/changelog/update-webpack-config-default-request-map new file mode 100644 index 000000000000..f262392c91bb --- /dev/null +++ b/projects/plugins/protect/changelog/update-webpack-config-default-request-map @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Replace the duplicated DependencyExtractionPlugin requestMap block with an opt-in bundleWpUiDeps option. No build output changes. + + diff --git a/projects/plugins/protect/webpack.config.js b/projects/plugins/protect/webpack.config.js index e236cfe34c7e..439b542c081a 100644 --- a/projects/plugins/protect/webpack.config.js +++ b/projects/plugins/protect/webpack.config.js @@ -22,11 +22,7 @@ module.exports = [ plugins: [ ...jetpackWebpackConfig.StandardPlugins( { DependencyExtractionPlugin: { - // Bundled, never one without the other — see #48173. - requestMap: { - '@wordpress/theme': { external: false }, - '@wordpress/private-apis': { external: false }, - }, + bundleWpUiDeps: true, }, } ), ], From e84a008f070a74b47e2086d46bbb271d281d3ee1 Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Mon, 14 Sep 2026 11:22:06 -0300 Subject: [PATCH 3/3] Webpack config: correct the bundleWpUiDeps rationale The comments, README and Jetpack call site said the wp-theme and wp-private-apis handles are missing on many pages, and cited #48173. Neither holds at the WP 7.0 minimum: core registers both handles, and #48173 merged no webpack change. State the lock rule instead: a bundled @wordpress/private-apis unlocks only what its own bundle locked. State the current reason to use the option: @wordpress/ui is built against a newer @wordpress/theme than core's wp-theme. Record the new option as an added changelog entry. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01RnmaaEamjHo2MmDpnrwiNa --- projects/js-packages/webpack-config/README.md | 2 +- .../update-webpack-config-default-request-map | 7 +++---- projects/js-packages/webpack-config/src/webpack.js | 11 +++++------ projects/plugins/jetpack/tools/webpack.config.js | 3 --- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/projects/js-packages/webpack-config/README.md b/projects/js-packages/webpack-config/README.md index 6ea6e442c680..5e901c2115f5 100644 --- a/projects/js-packages/webpack-config/README.md +++ b/projects/js-packages/webpack-config/README.md @@ -229,7 +229,7 @@ By default, the following additional dependencies are extracted: Two additional options are recognized: - `requestMap`: An easier way to specify additional dependencies to extract, rather than redefining `requestToHandle` and `requestToExternal`. Key is the dependency, value is an object with `handle` and `external` keys corresponding to the return values of `requestToHandle` and `requestToExternal`. -- `bundleWpUiDeps`: Bundle `@wordpress/theme` and `@wordpress/private-apis` instead of externalizing them to the `wp-theme` and `wp-private-apis` script handles. Defaults to `false`. Set it to `true` on an entry that renders `@wordpress/ui` on a page that registers neither handle, otherwise the whole bundle fails to enqueue. The pair is bundled jointly on purpose: see [#48173](https://github.com/Automattic/jetpack/pull/48173). Your own `requestMap` still wins over it. +- `bundleWpUiDeps`: Bundle `@wordpress/theme` and `@wordpress/private-apis` instead of externalizing them to the `wp-theme` and `wp-private-apis` script handles. Defaults to `false`. It is meant for entries that bundle `@wordpress/ui`, which is built against a newer `@wordpress/theme` than the one WordPress core registers. A bundled `@wordpress/private-apis` can only unlock private APIs that were locked inside the same bundle. So do not use this option on an entry that unlocks private APIs from an external `wp-*` script, for example bundled `@wordpress/dataviews` with an external `wp-components`. Your own `requestMap` still wins over it. ##### `DuplicatePackageCheckerPlugin( options )` diff --git a/projects/js-packages/webpack-config/changelog/update-webpack-config-default-request-map b/projects/js-packages/webpack-config/changelog/update-webpack-config-default-request-map index f262392c91bb..f2da20c85878 100644 --- a/projects/js-packages/webpack-config/changelog/update-webpack-config-default-request-map +++ b/projects/js-packages/webpack-config/changelog/update-webpack-config-default-request-map @@ -1,5 +1,4 @@ -Significance: patch -Type: changed -Comment: Replace the duplicated DependencyExtractionPlugin requestMap block with an opt-in bundleWpUiDeps option. No build output changes. - +Significance: minor +Type: added +DependencyExtractionPlugin: Add a `bundleWpUiDeps` option to bundle `@wordpress/theme` and `@wordpress/private-apis`. diff --git a/projects/js-packages/webpack-config/src/webpack.js b/projects/js-packages/webpack-config/src/webpack.js index b48242aa82ed..085f9788c533 100644 --- a/projects/js-packages/webpack-config/src/webpack.js +++ b/projects/js-packages/webpack-config/src/webpack.js @@ -146,10 +146,8 @@ const defaultRequestMap = { }, }; -// @wordpress/ui pulls these in transitively; externalizing them targets script handles many pages -// never register, so the whole bundle fails to enqueue. Bundle the pair jointly — split, the -// module-scope lock() in @wordpress/theme and the per-instance consent map in -// @wordpress/private-apis diverge at runtime. See PR #48173. +// A bundled @wordpress/private-apis unlocks only what its own bundle locked. So never bundle it +// without @wordpress/theme, or in an entry that unlocks private APIs of an external wp-* script. const wpUiRequestMap = { '@wordpress/theme': { external: false }, '@wordpress/private-apis': { external: false }, @@ -161,8 +159,9 @@ const wpUiRequestMap = { * @param {object} options - Plugin options, passed through except for the two below. * @param {object} options.requestMap - Per-request `{ external, handle }` overrides. Wins over every default. * @param {boolean} options.bundleWpUiDeps - Bundle `@wordpress/theme` and `@wordpress/private-apis` instead of - * externalizing them. Off by default; set it on an entry that renders - * `@wordpress/ui` on a page that registers neither script handle. + * externalizing them. Off by default. For an entry that bundles + * `@wordpress/ui`, which is built against a newer `@wordpress/theme` + * than core's `wp-theme`. * @return {object[]} The plugin. */ const DependencyExtractionPlugin = ( { requestMap, bundleWpUiDeps = false, ...options } = {} ) => { diff --git a/projects/plugins/jetpack/tools/webpack.config.js b/projects/plugins/jetpack/tools/webpack.config.js index 50ce26c45c7f..22aabdbde4d2 100644 --- a/projects/plugins/jetpack/tools/webpack.config.js +++ b/projects/plugins/jetpack/tools/webpack.config.js @@ -231,9 +231,6 @@ module.exports = [ plugins: [ ...sharedWebpackConfig.plugins, ...jetpackWebpackConfig.DependencyExtractionPlugin( { - // The licensing activation screen pulls in @wordpress/ui, and this page - // registers neither handle: WP < 7.0 has no core wp-theme, and the - // wp-build-polyfills shim is not loaded here. bundleWpUiDeps: true, } ), ],