From 3af55637dce9d993c33167f80c6cbdac954d499e Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Thu, 10 Oct 2024 11:46:56 -0400 Subject: [PATCH] Use DEWP's new auto-wp-polyfill support (#39629) `@wordpress/dependency-extraction-webpack-plugin` has added the ability to detect a magic `/* wp:polyfill */` comment and only add `wp-polyfill` as a dependency if that is found. Since `wp-polyfill` is just a custom build of `core-js`, the intention is that `babel-plugin-polyfill-corejs3` (maybe via `@babel/preset-env`) would be used and then a custom Babel plugin would replace the `core-js` imports with the magic comment. This updates our Babel config to do just that, and removes the blanket addition of `wp-polyfill` via `injectPolyfill` or otherwise. --- pnpm-lock.yaml | 15 ++-- projects/js-packages/webpack-config/README.md | 18 +++- .../add-dependency-extraction-auto-polyfill | 4 + .../add-dependency-extraction-auto-polyfill#2 | 4 + .../add-dependency-extraction-auto-polyfill#3 | 4 + .../add-dependency-extraction-auto-polyfill#4 | 4 + .../js-packages/webpack-config/package.json | 2 + .../webpack-config/src/babel-preset.js | 82 ++++++++++++++----- .../src/babel/replace-polyfills.js | 74 +++++++++++++++++ .../add-dependency-extraction-auto-polyfill | 4 + projects/packages/backup/webpack.config.js | 6 +- .../add-dependency-extraction-auto-polyfill | 4 + projects/packages/blaze/webpack.config.js | 6 +- .../add-dependency-extraction-auto-polyfill#2 | 5 ++ .../classic-theme-helper/package.json | 1 - .../add-dependency-extraction-auto-polyfill | 4 + projects/packages/explat/webpack.config.js | 6 +- .../add-dependency-extraction-auto-polyfill | 4 + .../forms/tools/webpack.config.blocks.js | 6 +- .../add-dependency-extraction-auto-polyfill | 4 + .../jetpack-mu-wpcom/verbum.webpack.config.js | 7 +- .../add-dependency-extraction-auto-polyfill | 4 + projects/packages/jitm/webpack.config.js | 6 +- .../add-dependency-extraction-auto-polyfill#2 | 5 ++ projects/packages/masterbar/package.json | 1 - .../add-dependency-extraction-auto-polyfill | 4 + .../packages/my-jetpack/webpack.config.js | 6 +- .../add-dependency-extraction-auto-polyfill | 4 + .../plugin-deactivation/webpack.config.js | 6 +- .../add-dependency-extraction-auto-polyfill | 5 ++ .../packages/search/tools/babel.config.js | 1 + .../add-dependency-extraction-auto-polyfill | 4 + .../packages/videopress/webpack.config.js | 4 +- .../add-dependency-extraction-auto-polyfill | 5 ++ .../add-dependency-extraction-auto-polyfill#2 | 5 ++ projects/packages/wordads/package.json | 1 - .../packages/wordads/tools/babel.config.js | 1 + .../add-dependency-extraction-auto-polyfill | 4 + .../packages/yoast-promo/webpack.config.js | 6 +- .../add-dependency-extraction-auto-polyfill | 4 + .../webpack.config.js | 6 +- .../add-dependency-extraction-auto-polyfill | 4 + .../add-dependency-extraction-auto-polyfill | 4 + projects/plugins/boost/webpack.config.js | 5 +- .../add-dependency-extraction-auto-polyfill | 4 + .../webpack.config.js | 6 +- .../add-dependency-extraction-auto-polyfill | 4 + projects/plugins/crm/webpack.config.js | 4 +- .../add-dependency-extraction-auto-polyfill | 4 + .../jetpack/class.jetpack-gutenberg.php | 1 - projects/plugins/jetpack/class.jetpack.php | 8 +- .../tools/webpack.config.extensions.js | 1 - .../plugins/jetpack/tools/webpack.config.js | 2 +- .../tools/webpack.config.widget-visibility.js | 7 +- .../add-dependency-extraction-auto-polyfill | 4 + projects/plugins/migration/webpack.config.js | 6 +- .../add-dependency-extraction-auto-polyfill | 4 + .../add-dependency-extraction-auto-polyfill | 4 + projects/plugins/protect/webpack.config.js | 6 +- .../add-dependency-extraction-auto-polyfill | 4 + .../add-dependency-extraction-auto-polyfill | 4 + projects/plugins/social/webpack.config.js | 6 +- .../add-dependency-extraction-auto-polyfill | 4 + .../plugins/starter-plugin/webpack.config.js | 6 +- .../add-dependency-extraction-auto-polyfill | 4 + .../add-dependency-extraction-auto-polyfill | 4 + 66 files changed, 321 insertions(+), 135 deletions(-) create mode 100644 projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill#2 create mode 100644 projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill#3 create mode 100644 projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill#4 create mode 100644 projects/js-packages/webpack-config/src/babel/replace-polyfills.js create mode 100644 projects/packages/backup/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/packages/blaze/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/packages/classic-theme-helper/changelog/add-dependency-extraction-auto-polyfill#2 create mode 100644 projects/packages/explat/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/packages/forms/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/packages/jitm/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/packages/masterbar/changelog/add-dependency-extraction-auto-polyfill#2 create mode 100644 projects/packages/my-jetpack/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/packages/plugin-deactivation/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/packages/search/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/packages/videopress/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/packages/wordads/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/packages/wordads/changelog/add-dependency-extraction-auto-polyfill#2 create mode 100644 projects/packages/yoast-promo/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/plugins/automattic-for-agencies-client/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/plugins/backup/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/plugins/boost/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/plugins/classic-theme-helper-plugin/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/plugins/crm/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/plugins/jetpack/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/plugins/migration/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/plugins/mu-wpcom-plugin/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/plugins/protect/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/plugins/search/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/plugins/social/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/plugins/starter-plugin/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/plugins/videopress/changelog/add-dependency-extraction-auto-polyfill create mode 100644 projects/plugins/wpcomsh/changelog/add-dependency-extraction-auto-polyfill diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1d3174aff5090..b2a4ffe17c435 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1628,9 +1628,15 @@ importers: babel-loader: specifier: 9.1.2 version: 9.1.2(@babel/core@7.24.7)(webpack@5.94.0(webpack-cli@4.9.1)) + babel-plugin-polyfill-corejs3: + specifier: 0.10.6 + version: 0.10.6(@babel/core@7.24.7) browserslist: specifier: 4.23.1 version: 4.23.1 + core-js: + specifier: 3.38.1 + version: 3.38.1 css-loader: specifier: 6.5.1 version: 6.5.1(webpack@5.94.0(webpack-cli@4.9.1)) @@ -1906,9 +1912,6 @@ importers: '@wordpress/browserslist-config': specifier: 6.9.0 version: 6.9.0 - '@wordpress/dependency-extraction-webpack-plugin': - specifier: 6.9.0 - version: 6.9.0(webpack@5.94.0(webpack-cli@4.9.1)) autoprefixer: specifier: 10.4.14 version: 10.4.14(postcss@8.4.31) @@ -2394,9 +2397,6 @@ importers: '@wordpress/browserslist-config': specifier: 6.9.0 version: 6.9.0 - '@wordpress/dependency-extraction-webpack-plugin': - specifier: 6.9.0 - version: 6.9.0(webpack@5.94.0(webpack-cli@4.9.1)) autoprefixer: specifier: 10.4.14 version: 10.4.14(postcss@8.4.31) @@ -3105,9 +3105,6 @@ importers: '@wordpress/browserslist-config': specifier: 6.9.0 version: 6.9.0 - '@wordpress/dependency-extraction-webpack-plugin': - specifier: 6.9.0 - version: 6.9.0(webpack@5.94.0(webpack-cli@4.9.1)) babel-jest: specifier: 29.4.3 version: 29.4.3(@babel/core@7.24.7) diff --git a/projects/js-packages/webpack-config/README.md b/projects/js-packages/webpack-config/README.md index 16ed22829993b..1bd17535d1146 100644 --- a/projects/js-packages/webpack-config/README.md +++ b/projects/js-packages/webpack-config/README.md @@ -140,7 +140,7 @@ This provides all of the plugins listed below. The `options` object can be used plugins: { ...StandardPlugins( { DuplicatePackageCheckerPlugin: false, - DependencyExtractionPlugin: { injectPolyfill: true }, + DependencyExtractionPlugin: { requestMap: { foo: {} }, } ), } ``` @@ -162,6 +162,14 @@ You can pass any additional defines as the `defines` parameter. Note it is not n This provides an instance of [@wordpress/dependency-extraction-webpack-plugin](https://www.npmjs.com/package/@wordpress/dependency-extraction-webpack-plugin). The `options` are passed to the plugin. +By default, the following additional dependencies are extracted: +- `@automattic/jetpack-script-data`: Handle `jetpack-script-data` provided by PHP package [automattic/jetpack-assets](https://packagist.org/packages/automattic/jetpack-assets). +- `@automattic/jetpack-connection`: Handle `jetpack-connection` provided by PHP package [automattic/jetpack-connection](https://packagist.org/packages/automattic/jetpack-connection). + +One additional option is 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`. + ##### `DuplicatePackageCheckerPlugin( options )` This provides an instance of [@cerner/duplicate-package-checker-webpack-plugin](https://www.npmjs.com/package/@cerner/duplicate-package-checker-webpack-plugin). The `options` are passed to the plugin. @@ -284,11 +292,17 @@ The options passed to the preset allow you to exclude (by passing false) or amen The options and corresponding components are: +- `targets`: Set targets for various plugins. Default is your browserslist config if available, otherwise [@wordpress/browserslist-config](https://www.npmjs.com/package/@wordpress/browserslist-config). +- `autoWpPolyfill`: Set false to disable use of [babel-plugin-polyfill-corejs3](https://www.npmjs.com/package/babel-plugin-polyfill-corejs3) to produce magic `/* wp:polyfill */` comments that [@wordpress/dependency-extraction-webpack-plugin](https://www.npmjs.com/package/@wordpress/dependency-extraction-webpack-plugin) will use to add a dep on `wp-polyfill`. + + Options include: + - `exclude`: Core-js polyfills to ignore. Defaults to exclude 'es.array.push' and 'web.immediate'. + - `targets`: Override top-level `targets`. - `presetEnv`: Corresponds to [@babel/preset-env](https://www.npmjs.com/package/@babel/preset-env). Note the following options that are different from `@babel/preset-env`'s defaults: - `exclude`: Set to `[ 'transform-typeof-symbol' ]`, as that [apparently makes all code slower](https://github.com/facebook/create-react-app/pull/5278). - - `targets`: Set to your browserslist config if available, otherwise set to [@wordpress/browserslist-config](https://www.npmjs.com/package/@wordpress/browserslist-config). + - `targets`: Set based on top-level `targets`. - `presetReact`: Corresponds to [@babel/preset-react](https://www.npmjs.com/package/@babel/preset-react). - `presetTypescript`: Corresponds to [@babel/preset-typescript](https://www.npmjs.com/package/@babel/preset-typescript). - `pluginReplaceTextdomain`: Corresponds to [@automattic/babel-plugin-replace-textdomain](https://www.npmjs.com/package/@automattic/babel-plugin-replace-textdomain). diff --git a/projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill b/projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..0fa83915d6d58 --- /dev/null +++ b/projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Babel preset: Fix `pluginPreserveI18n` option. diff --git a/projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill#2 b/projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill#2 new file mode 100644 index 0000000000000..23be7808ea98a --- /dev/null +++ b/projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill#2 @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Babel preset: Add default for base `targets` option, replacing default `.presetEnv.targets`. diff --git a/projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill#3 b/projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill#3 new file mode 100644 index 0000000000000..d79f5888b9a34 --- /dev/null +++ b/projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill#3 @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Babel preset: Add `autoWpPolyfill` option. diff --git a/projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill#4 b/projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill#4 new file mode 100644 index 0000000000000..608cf4e38c846 --- /dev/null +++ b/projects/js-packages/webpack-config/changelog/add-dependency-extraction-auto-polyfill#4 @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Update documentation for `DependencyExtractionPlugin` after #38877 and #38430. diff --git a/projects/js-packages/webpack-config/package.json b/projects/js-packages/webpack-config/package.json index 3224423dd7038..7aefbf121f6d9 100644 --- a/projects/js-packages/webpack-config/package.json +++ b/projects/js-packages/webpack-config/package.json @@ -31,7 +31,9 @@ "@wordpress/browserslist-config": "6.9.0", "@wordpress/dependency-extraction-webpack-plugin": "6.9.0", "babel-loader": "9.1.2", + "babel-plugin-polyfill-corejs3": "0.10.6", "browserslist": "4.23.1", + "core-js": "3.38.1", "css-loader": "6.5.1", "css-minimizer-webpack-plugin": "5.0.1", "fork-ts-checker-webpack-plugin": "9.0.2", diff --git a/projects/js-packages/webpack-config/src/babel-preset.js b/projects/js-packages/webpack-config/src/babel-preset.js index ea14e0ad97062..43c2d9bb1cd7d 100644 --- a/projects/js-packages/webpack-config/src/babel-preset.js +++ b/projects/js-packages/webpack-config/src/babel-preset.js @@ -1,33 +1,70 @@ const path = require( 'path' ); -const PresetEnv = ( options = {} ) => { - if ( typeof options.targets === 'undefined' ) { +module.exports = ( api, opts = {} ) => { + const ret = { + sourceType: opts.sourceType || 'unambiguous', + presets: [], + plugins: [], + }; + + let targets = opts.targets; + if ( ! targets ) { const browserslist = require( 'browserslist' ); const localBrowserslistConfig = browserslist.findConfig( '.' ) || {}; - options.targets = browserslist( + targets = browserslist( localBrowserslistConfig.defaults || require( '@wordpress/browserslist-config' ) ); } - return [ - require.resolve( '@babel/preset-env' ), - { - // Exclude transforms that make all code slower, see https://github.com/facebook/create-react-app/pull/5278 - exclude: [ 'transform-typeof-symbol' ], - ...options, - }, - ]; -}; + if ( opts.autoWpPolyfill !== false ) { + if ( opts.presetEnv?.useBuiltIns ) { + throw new Error( 'Cannot use autoWpPolyfill along with presetEnv.useBuiltIns' ); + } + if ( opts.pluginTransformRuntime?.corejs ) { + throw new Error( 'Cannot use autoWpPolyfill along with pluginTransformRuntime.corejs' ); + } -module.exports = ( api, opts = {} ) => { - const ret = { - sourceType: opts.sourceType || 'unambiguous', - presets: [], - plugins: [], - }; + const importDir = opts.autoWpPolyfill?.absoluteImports ?? path.dirname( __dirname ); + ret.plugins.push( + [ + require.resolve( 'babel-plugin-polyfill-corejs3' ), + { + method: 'usage-global', + version: require( 'core-js/package.json' ).version, + absoluteImports: importDir, + targets: opts.autoWpPolyfill?.targets ?? targets, + exclude: opts.autoWpPolyfill?.exclude ?? [ + // Ignore excessively strict polyfilling of `Array.prototype.push` to work + // around an obscure bug involving non-writable arrays. + // See https://issues.chromium.org/issues/42202623 for the details of the + // bug that leads to the polyfilling, and which we are choosing to ignore. + 'es.array.push', + + // This is an IE-only feature which we don't use, and don't want to polyfill. + // @see https://github.com/WordPress/gutenberg/pull/49234 + 'web.immediate', + ], + }, + ], + [ + require.resolve( './babel/replace-polyfills.js' ), + { + absoluteImports: importDir, + }, + ] + ); + } if ( opts.presetEnv !== false ) { - ret.presets.push( PresetEnv( opts.presetEnv ) ); + ret.presets.push( [ + require.resolve( '@babel/preset-env' ), + { + targets, + // Exclude transforms that make all code slower, see https://github.com/facebook/create-react-app/pull/5278 + exclude: [ 'transform-typeof-symbol' ], + ...opts.presetEnv, + }, + ] ); } if ( opts.presetReact !== false ) { ret.presets.push( [ require.resolve( '@babel/preset-react' ), opts.presetReact ] ); @@ -43,6 +80,10 @@ module.exports = ( api, opts = {} ) => { ] ); } if ( opts.pluginTransformRuntime !== false ) { + // babel-plugin-polyfill-corejs3 from autoWpPolyfill otherwise makes it want @babel/runtime-corejs3 + const optModuleName = + opts.autoWpPolyfill !== false ? { moduleName: '@babel/runtime' } : undefined; + ret.plugins.push( [ require.resolve( '@babel/plugin-transform-runtime' ), { @@ -50,11 +91,12 @@ module.exports = ( api, opts = {} ) => { regenerator: false, absoluteRuntime: path.dirname( __dirname ), // Required when workspace projects are symlinked. version: require( '@babel/runtime/package.json' )?.version, + ...optModuleName, ...opts.pluginTransformRuntime, }, ] ); } - if ( opts.pluginCalypsoOptimizeI18n !== false ) { + if ( opts.pluginPreserveI18n !== false ) { ret.plugins.push( [ require.resolve( '@automattic/babel-plugin-preserve-i18n' ), opts.pluginPreserveI18n, diff --git a/projects/js-packages/webpack-config/src/babel/replace-polyfills.js b/projects/js-packages/webpack-config/src/babel/replace-polyfills.js new file mode 100644 index 0000000000000..e8dcc3966a956 --- /dev/null +++ b/projects/js-packages/webpack-config/src/babel/replace-polyfills.js @@ -0,0 +1,74 @@ +const npath = require( 'path' ); + +/** + * Babel plugin that looks for `core-js` imports (or requires) + * and replaces them with magic comments to mark the file as + * depending on wp-polyfill. + * + * Based on https://github.com/WordPress/gutenberg/blob/28f1b5b308a62098f0e1e253cb734c83b2fa1356/packages/babel-preset-default/replace-polyfills.js + * + * @param {object} babel - Babel object. + * @param {object} opts - Options from Babel config. + * @return {object} Babel plugin. + */ +module.exports = ( babel, opts ) => { + const { types: t } = babel; + const coreJsPrefix = opts.absoluteImports + ? npath.dirname( + require.resolve( 'core-js/package.json', { paths: [ opts.absoluteImports ] } ) + ) + '/' + : 'core-js/'; + + return { + name: 'replacePolyfills', + pre() { + this.hasAddedPolyfills = false; + }, + visitor: { + Program: { + exit( path ) { + if ( this.hasAddedPolyfills ) { + // Add magic comment to top of file. + path.addComment( 'leading', ' wp:polyfill ' ); + } + }, + }, + + // Handle `import` syntax. + ImportDeclaration( path ) { + const source = path.node.source; + const name = source.value || ''; + + // Look for imports from `core-js`. + if ( name.startsWith( coreJsPrefix ) ) { + // Replace import. + path.replaceWith( t.noop() ); + path.addComment( 'leading', ` wp:polyfill ${ npath.basename( name, '.js' ) } ` ); + this.hasAddedPolyfills = true; + } + }, + + // Handle `require` syntax. + ExpressionStatement( path ) { + const expression = path.node.expression; + if ( ! t.isCallExpression( expression ) ) { + return; + } + + const callee = expression.callee; + const arg = expression.arguments[ 0 ]; + if ( + t.isIdentifier( callee ) && + callee.name === 'require' && + t.isStringLiteral( arg ) && + arg.value.startsWith( coreJsPrefix ) + ) { + // Replace require. + path.replaceWith( t.noop() ); + path.addComment( 'leading', ` wp:polyfill ${ npath.basename( arg.value, '.js' ) } ` ); + this.hasAddedPolyfills = true; + } + }, + }, + }; +}; diff --git a/projects/packages/backup/changelog/add-dependency-extraction-auto-polyfill b/projects/packages/backup/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/packages/backup/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/packages/backup/webpack.config.js b/projects/packages/backup/webpack.config.js index 80a656b1118cd..49518ef2fbf7a 100644 --- a/projects/packages/backup/webpack.config.js +++ b/projects/packages/backup/webpack.config.js @@ -19,11 +19,7 @@ module.exports = [ ...jetpackWebpackConfig.resolve, }, node: false, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], module: { strictExportPresence: true, rules: [ diff --git a/projects/packages/blaze/changelog/add-dependency-extraction-auto-polyfill b/projects/packages/blaze/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/packages/blaze/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/packages/blaze/webpack.config.js b/projects/packages/blaze/webpack.config.js index 939a3b9c220cc..8bf34233e0bfa 100644 --- a/projects/packages/blaze/webpack.config.js +++ b/projects/packages/blaze/webpack.config.js @@ -45,11 +45,7 @@ module.exports = [ optimization: { ...jetpackWebpackConfig.optimization, }, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], resolve: { ...jetpackWebpackConfig.resolve, }, diff --git a/projects/packages/classic-theme-helper/changelog/add-dependency-extraction-auto-polyfill#2 b/projects/packages/classic-theme-helper/changelog/add-dependency-extraction-auto-polyfill#2 new file mode 100644 index 0000000000000..9e8ffe1ab8734 --- /dev/null +++ b/projects/packages/classic-theme-helper/changelog/add-dependency-extraction-auto-polyfill#2 @@ -0,0 +1,5 @@ +Significance: patch +Type: removed +Comment: Remove unnecessary JS dep on `@wordpress/dependency-extraction-webpack-plugin` + + diff --git a/projects/packages/classic-theme-helper/package.json b/projects/packages/classic-theme-helper/package.json index b9004f89d8dc8..ba926cdf342a4 100644 --- a/projects/packages/classic-theme-helper/package.json +++ b/projects/packages/classic-theme-helper/package.json @@ -29,7 +29,6 @@ "@babel/core": "7.24.7", "@csstools/postcss-global-data": "2.1.1", "@wordpress/browserslist-config": "6.9.0", - "@wordpress/dependency-extraction-webpack-plugin": "6.9.0", "autoprefixer": "10.4.14", "glob": "10.4.1", "postcss": "8.4.31", diff --git a/projects/packages/explat/changelog/add-dependency-extraction-auto-polyfill b/projects/packages/explat/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/packages/explat/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/packages/explat/webpack.config.js b/projects/packages/explat/webpack.config.js index 1515cf4b87533..5009637d7f9f0 100644 --- a/projects/packages/explat/webpack.config.js +++ b/projects/packages/explat/webpack.config.js @@ -19,11 +19,7 @@ module.exports = [ ...jetpackWebpackConfig.resolve, }, node: false, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], module: { strictExportPresence: true, rules: [ diff --git a/projects/packages/forms/changelog/add-dependency-extraction-auto-polyfill b/projects/packages/forms/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/packages/forms/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/packages/forms/tools/webpack.config.blocks.js b/projects/packages/forms/tools/webpack.config.blocks.js index 1919e8a3bb89b..2e1a05947eb06 100644 --- a/projects/packages/forms/tools/webpack.config.blocks.js +++ b/projects/packages/forms/tools/webpack.config.blocks.js @@ -27,11 +27,7 @@ const sharedWebpackConfig = { ...jetpackWebpackConfig.resolve, }, node: {}, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], externals: { ...jetpackWebpackConfig.externals, jetpackConfig: JSON.stringify( { diff --git a/projects/packages/jetpack-mu-wpcom/changelog/add-dependency-extraction-auto-polyfill b/projects/packages/jetpack-mu-wpcom/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/packages/jetpack-mu-wpcom/verbum.webpack.config.js b/projects/packages/jetpack-mu-wpcom/verbum.webpack.config.js index 31efa366b856f..612ee1168ee19 100644 --- a/projects/packages/jetpack-mu-wpcom/verbum.webpack.config.js +++ b/projects/packages/jetpack-mu-wpcom/verbum.webpack.config.js @@ -42,7 +42,6 @@ module.exports = [ node: false, plugins: [ ...jetpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: false }, MiniCssExtractPlugin: { filename: '[name]/[name].css' }, } ), new webpack.ProvidePlugin( { @@ -103,11 +102,7 @@ module.exports = [ ...jetpackConfig.resolve, }, node: false, - plugins: [ - ...jetpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: false }, - } ), - ], + plugins: [ ...jetpackConfig.StandardPlugins() ], module: { strictExportPresence: true, rules: [ diff --git a/projects/packages/jitm/changelog/add-dependency-extraction-auto-polyfill b/projects/packages/jitm/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/packages/jitm/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/packages/jitm/webpack.config.js b/projects/packages/jitm/webpack.config.js index 72ee825e29130..11ab24a435f4e 100644 --- a/projects/packages/jitm/webpack.config.js +++ b/projects/packages/jitm/webpack.config.js @@ -19,11 +19,7 @@ module.exports = [ ...jetpackWebpackConfig.resolve, }, node: false, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], module: { strictExportPresence: true, rules: [ diff --git a/projects/packages/masterbar/changelog/add-dependency-extraction-auto-polyfill#2 b/projects/packages/masterbar/changelog/add-dependency-extraction-auto-polyfill#2 new file mode 100644 index 0000000000000..9e8ffe1ab8734 --- /dev/null +++ b/projects/packages/masterbar/changelog/add-dependency-extraction-auto-polyfill#2 @@ -0,0 +1,5 @@ +Significance: patch +Type: removed +Comment: Remove unnecessary JS dep on `@wordpress/dependency-extraction-webpack-plugin` + + diff --git a/projects/packages/masterbar/package.json b/projects/packages/masterbar/package.json index b8d4d31bd969f..33efaa34045dc 100644 --- a/projects/packages/masterbar/package.json +++ b/projects/packages/masterbar/package.json @@ -34,7 +34,6 @@ "@babel/core": "7.24.7", "@csstools/postcss-global-data": "2.1.1", "@wordpress/browserslist-config": "6.9.0", - "@wordpress/dependency-extraction-webpack-plugin": "6.9.0", "autoprefixer": "10.4.14", "glob": "10.4.1", "postcss": "8.4.31", diff --git a/projects/packages/my-jetpack/changelog/add-dependency-extraction-auto-polyfill b/projects/packages/my-jetpack/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/packages/my-jetpack/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/packages/my-jetpack/webpack.config.js b/projects/packages/my-jetpack/webpack.config.js index f2d2ba865f3af..36fc920c8f668 100644 --- a/projects/packages/my-jetpack/webpack.config.js +++ b/projects/packages/my-jetpack/webpack.config.js @@ -19,11 +19,7 @@ module.exports = [ ...jetpackWebpackConfig.resolve, }, node: false, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], module: { strictExportPresence: true, rules: [ diff --git a/projects/packages/plugin-deactivation/changelog/add-dependency-extraction-auto-polyfill b/projects/packages/plugin-deactivation/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/packages/plugin-deactivation/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/packages/plugin-deactivation/webpack.config.js b/projects/packages/plugin-deactivation/webpack.config.js index 7e7deb963848b..2d0f579c01460 100644 --- a/projects/packages/plugin-deactivation/webpack.config.js +++ b/projects/packages/plugin-deactivation/webpack.config.js @@ -19,11 +19,7 @@ module.exports = [ ...jetpackWebpackConfig.resolve, }, node: false, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], module: { strictExportPresence: true, rules: [ diff --git a/projects/packages/search/changelog/add-dependency-extraction-auto-polyfill b/projects/packages/search/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..20df2e785f6c5 --- /dev/null +++ b/projects/packages/search/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Update Babel config to disable new `autoWpPolyfill` option. + + diff --git a/projects/packages/search/tools/babel.config.js b/projects/packages/search/tools/babel.config.js index bc3f60e706111..dc870e4b77eb7 100644 --- a/projects/packages/search/tools/babel.config.js +++ b/projects/packages/search/tools/babel.config.js @@ -5,6 +5,7 @@ module.exports = api => { [ '@automattic/jetpack-webpack-config/babel/preset', { + autoWpPolyfill: false, presetEnv: { corejs: require( 'core-js/package.json' ).version, modules: false, diff --git a/projects/packages/videopress/changelog/add-dependency-extraction-auto-polyfill b/projects/packages/videopress/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/packages/videopress/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/packages/videopress/webpack.config.js b/projects/packages/videopress/webpack.config.js index 1edf3bb3450b3..a2239e396d698 100644 --- a/projects/packages/videopress/webpack.config.js +++ b/projects/packages/videopress/webpack.config.js @@ -36,9 +36,7 @@ module.exports = [ }, node: false, plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), + ...jetpackWebpackConfig.StandardPlugins(), new CopyWebpackPlugin( { patterns: [ { diff --git a/projects/packages/wordads/changelog/add-dependency-extraction-auto-polyfill b/projects/packages/wordads/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..20df2e785f6c5 --- /dev/null +++ b/projects/packages/wordads/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Update Babel config to disable new `autoWpPolyfill` option. + + diff --git a/projects/packages/wordads/changelog/add-dependency-extraction-auto-polyfill#2 b/projects/packages/wordads/changelog/add-dependency-extraction-auto-polyfill#2 new file mode 100644 index 0000000000000..9e8ffe1ab8734 --- /dev/null +++ b/projects/packages/wordads/changelog/add-dependency-extraction-auto-polyfill#2 @@ -0,0 +1,5 @@ +Significance: patch +Type: removed +Comment: Remove unnecessary JS dep on `@wordpress/dependency-extraction-webpack-plugin` + + diff --git a/projects/packages/wordads/package.json b/projects/packages/wordads/package.json index 6a9b13b66ac9c..099cc9ebdedc6 100644 --- a/projects/packages/wordads/package.json +++ b/projects/packages/wordads/package.json @@ -71,7 +71,6 @@ "@testing-library/react": "16.0.1", "@wordpress/babel-plugin-import-jsx-pragma": "5.9.0", "@wordpress/browserslist-config": "6.9.0", - "@wordpress/dependency-extraction-webpack-plugin": "6.9.0", "babel-jest": "29.4.3", "concurrently": "7.6.0", "core-js": "3.38.1", diff --git a/projects/packages/wordads/tools/babel.config.js b/projects/packages/wordads/tools/babel.config.js index 81edb414bb051..a75a595cd2d1a 100644 --- a/projects/packages/wordads/tools/babel.config.js +++ b/projects/packages/wordads/tools/babel.config.js @@ -5,6 +5,7 @@ module.exports = api => { [ '@automattic/jetpack-webpack-config/babel/preset', { + autoWpPolyfill: false, presetEnv: { corejs: require( 'core-js/package.json' ).version, modules: false, diff --git a/projects/packages/yoast-promo/changelog/add-dependency-extraction-auto-polyfill b/projects/packages/yoast-promo/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/packages/yoast-promo/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/packages/yoast-promo/webpack.config.js b/projects/packages/yoast-promo/webpack.config.js index 2b01e463ae2fe..46d9c81d148df 100644 --- a/projects/packages/yoast-promo/webpack.config.js +++ b/projects/packages/yoast-promo/webpack.config.js @@ -45,11 +45,7 @@ module.exports = [ optimization: { ...jetpackWebpackConfig.optimization, }, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], resolve: { ...jetpackWebpackConfig.resolve, }, diff --git a/projects/plugins/automattic-for-agencies-client/changelog/add-dependency-extraction-auto-polyfill b/projects/plugins/automattic-for-agencies-client/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/plugins/automattic-for-agencies-client/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/plugins/automattic-for-agencies-client/webpack.config.js b/projects/plugins/automattic-for-agencies-client/webpack.config.js index 68e5568c14b8d..b91ff5ec8de20 100644 --- a/projects/plugins/automattic-for-agencies-client/webpack.config.js +++ b/projects/plugins/automattic-for-agencies-client/webpack.config.js @@ -19,11 +19,7 @@ module.exports = [ ...jetpackWebpackConfig.resolve, }, node: false, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], module: { strictExportPresence: true, rules: [ diff --git a/projects/plugins/backup/changelog/add-dependency-extraction-auto-polyfill b/projects/plugins/backup/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/plugins/backup/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/plugins/boost/changelog/add-dependency-extraction-auto-polyfill b/projects/plugins/boost/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/plugins/boost/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/plugins/boost/webpack.config.js b/projects/plugins/boost/webpack.config.js index fd012c1c81f65..2e191ed66e8e5 100644 --- a/projects/plugins/boost/webpack.config.js +++ b/projects/plugins/boost/webpack.config.js @@ -67,7 +67,6 @@ module.exports = [ MiniCssExtractPlugin: { filename: 'jetpack-boost.css', }, - DependencyExtractionPlugin: { injectPolyfill: true }, } ), new webpack.ProvidePlugin( { process: require.resolve( 'process/browser' ), @@ -129,9 +128,7 @@ module.exports = [ }, node: false, plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), + ...jetpackWebpackConfig.StandardPlugins(), new CopyPlugin( { patterns: imageGuideCopyPatterns } ), ], module: { diff --git a/projects/plugins/classic-theme-helper-plugin/changelog/add-dependency-extraction-auto-polyfill b/projects/plugins/classic-theme-helper-plugin/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/plugins/classic-theme-helper-plugin/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/plugins/classic-theme-helper-plugin/webpack.config.js b/projects/plugins/classic-theme-helper-plugin/webpack.config.js index 3e081aa7d1f90..2b9a523c9ed2d 100644 --- a/projects/plugins/classic-theme-helper-plugin/webpack.config.js +++ b/projects/plugins/classic-theme-helper-plugin/webpack.config.js @@ -19,11 +19,7 @@ module.exports = [ ...jetpackWebpackConfig.resolve, }, node: false, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], module: { strictExportPresence: true, rules: [ diff --git a/projects/plugins/crm/changelog/add-dependency-extraction-auto-polyfill b/projects/plugins/crm/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/plugins/crm/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/plugins/crm/webpack.config.js b/projects/plugins/crm/webpack.config.js index 5c78a67e10e79..9272532b6fdf1 100644 --- a/projects/plugins/crm/webpack.config.js +++ b/projects/plugins/crm/webpack.config.js @@ -283,9 +283,7 @@ module.exports = [ path: path.resolve( './build' ), }, plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), + ...jetpackWebpackConfig.StandardPlugins(), ], module: { ...crmWebpackConfig.module, diff --git a/projects/plugins/jetpack/changelog/add-dependency-extraction-auto-polyfill b/projects/plugins/jetpack/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..236a792005a69 --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +General: Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/plugins/jetpack/class.jetpack-gutenberg.php b/projects/plugins/jetpack/class.jetpack-gutenberg.php index 6fa4dd4ed04cf..59aff9e9f95a4 100644 --- a/projects/plugins/jetpack/class.jetpack-gutenberg.php +++ b/projects/plugins/jetpack/class.jetpack-gutenberg.php @@ -562,7 +562,6 @@ public static function load_scripts_as_required( $type, $script_dependencies = a // Enqueue script. $script_relative_path = self::get_blocks_directory() . $type . '/view.js'; $script_deps_path = JETPACK__PLUGIN_DIR . self::get_blocks_directory() . $type . '/view.asset.php'; - $script_dependencies[] = 'wp-polyfill'; $script_dependencies[] = 'jetpack-blocks-assets-base-url'; if ( file_exists( $script_deps_path ) ) { $asset_manifest = include $script_deps_path; diff --git a/projects/plugins/jetpack/class.jetpack.php b/projects/plugins/jetpack/class.jetpack.php index 8cf17c78fa1a0..4f9a306cd26b9 100644 --- a/projects/plugins/jetpack/class.jetpack.php +++ b/projects/plugins/jetpack/class.jetpack.php @@ -3538,12 +3538,8 @@ public function deactivate_dialog( $hook ) { '_inc/build/plugins-page.js', JETPACK__PLUGIN_FILE, array( - 'in_footer' => true, - 'textdomain' => 'jetpack', - 'dependencies' => array( - 'wp-polyfill', - 'wp-components', - ), + 'in_footer' => true, + 'textdomain' => 'jetpack', ) ); Assets::enqueue_script( 'jetpack-plugins-page-js' ); diff --git a/projects/plugins/jetpack/tools/webpack.config.extensions.js b/projects/plugins/jetpack/tools/webpack.config.extensions.js index 96702610931d0..f04795eb054a0 100644 --- a/projects/plugins/jetpack/tools/webpack.config.extensions.js +++ b/projects/plugins/jetpack/tools/webpack.config.extensions.js @@ -111,7 +111,6 @@ const sharedWebpackConfig = { node: {}, plugins: [ ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, MiniCssExtractPlugin: { // This is a bit of a hack to handle simple cases of `import( './file.css' )` in block editor scripts. // If we're ever able to get rid of the monolithic editor.js files, this should go away in favor diff --git a/projects/plugins/jetpack/tools/webpack.config.js b/projects/plugins/jetpack/tools/webpack.config.js index c56a9968a4f44..d68fd10df5c68 100644 --- a/projects/plugins/jetpack/tools/webpack.config.js +++ b/projects/plugins/jetpack/tools/webpack.config.js @@ -147,7 +147,7 @@ module.exports = [ }, plugins: [ ...sharedWebpackConfig.plugins, - ...jetpackWebpackConfig.DependencyExtractionPlugin( { injectPolyfill: true } ), + ...jetpackWebpackConfig.DependencyExtractionPlugin(), ], externals: { ...sharedWebpackConfig.externals, diff --git a/projects/plugins/jetpack/tools/webpack.config.widget-visibility.js b/projects/plugins/jetpack/tools/webpack.config.widget-visibility.js index d9b3cd4757694..94d0e8dcdf141 100644 --- a/projects/plugins/jetpack/tools/webpack.config.widget-visibility.js +++ b/projects/plugins/jetpack/tools/webpack.config.widget-visibility.js @@ -30,12 +30,7 @@ module.exports = { fs: false, }, }, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - definePaletteColorsAsStaticVariables(), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins(), definePaletteColorsAsStaticVariables() ], externals: { ...jetpackWebpackConfig.externals, jetpackConfig: JSON.stringify( { diff --git a/projects/plugins/migration/changelog/add-dependency-extraction-auto-polyfill b/projects/plugins/migration/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/plugins/migration/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/plugins/migration/webpack.config.js b/projects/plugins/migration/webpack.config.js index 276164bf502f4..a2d2a2267e5a3 100644 --- a/projects/plugins/migration/webpack.config.js +++ b/projects/plugins/migration/webpack.config.js @@ -19,11 +19,7 @@ module.exports = [ ...jetpackWebpackConfig.resolve, }, node: false, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], module: { strictExportPresence: true, rules: [ diff --git a/projects/plugins/mu-wpcom-plugin/changelog/add-dependency-extraction-auto-polyfill b/projects/plugins/mu-wpcom-plugin/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/plugins/mu-wpcom-plugin/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/plugins/protect/changelog/add-dependency-extraction-auto-polyfill b/projects/plugins/protect/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/plugins/protect/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/plugins/protect/webpack.config.js b/projects/plugins/protect/webpack.config.js index f0883c9b9a4ed..2f6a45721b100 100644 --- a/projects/plugins/protect/webpack.config.js +++ b/projects/plugins/protect/webpack.config.js @@ -19,11 +19,7 @@ module.exports = [ ...jetpackWebpackConfig.resolve, }, node: false, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], module: { strictExportPresence: true, rules: [ diff --git a/projects/plugins/search/changelog/add-dependency-extraction-auto-polyfill b/projects/plugins/search/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/plugins/search/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/plugins/social/changelog/add-dependency-extraction-auto-polyfill b/projects/plugins/social/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/plugins/social/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/plugins/social/webpack.config.js b/projects/plugins/social/webpack.config.js index a86334fca5478..30ce24491fd8e 100644 --- a/projects/plugins/social/webpack.config.js +++ b/projects/plugins/social/webpack.config.js @@ -14,11 +14,7 @@ const socialWebpackConfig = { ...jetpackWebpackConfig.resolve, }, node: false, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], module: { strictExportPresence: true, rules: [ diff --git a/projects/plugins/starter-plugin/changelog/add-dependency-extraction-auto-polyfill b/projects/plugins/starter-plugin/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/plugins/starter-plugin/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/plugins/starter-plugin/webpack.config.js b/projects/plugins/starter-plugin/webpack.config.js index 0522603771465..cc11eaf1d1b84 100644 --- a/projects/plugins/starter-plugin/webpack.config.js +++ b/projects/plugins/starter-plugin/webpack.config.js @@ -19,11 +19,7 @@ module.exports = [ ...jetpackWebpackConfig.resolve, }, node: false, - plugins: [ - ...jetpackWebpackConfig.StandardPlugins( { - DependencyExtractionPlugin: { injectPolyfill: true }, - } ), - ], + plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], module: { strictExportPresence: true, rules: [ diff --git a/projects/plugins/videopress/changelog/add-dependency-extraction-auto-polyfill b/projects/plugins/videopress/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/plugins/videopress/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed. diff --git a/projects/plugins/wpcomsh/changelog/add-dependency-extraction-auto-polyfill b/projects/plugins/wpcomsh/changelog/add-dependency-extraction-auto-polyfill new file mode 100644 index 0000000000000..f4cd286e166af --- /dev/null +++ b/projects/plugins/wpcomsh/changelog/add-dependency-extraction-auto-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Only include `wp-polyfill` as a script dependency when needed.