From 9a9cba13eebd68aa616c528c144c356bc8a6dd43 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 24 Apr 2019 11:31:28 +0200 Subject: [PATCH] Add `wp-polyfill` dependency via webpack plugin Enable `injectPolyfill` option in the webpack plugin instead of manually injecting the dependency via PHP on script registration. This will enable the polyfill for consumers of wp-scripts default webpack config. --- lib/client-assets.php | 2 +- packages/scripts/config/webpack.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index 85304282358235..0fd61176e30238 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -211,7 +211,7 @@ function gutenberg_register_packages_scripts() { gutenberg_override_script( $handle, gutenberg_url( $gutenberg_path ), - array_merge( $dependencies, array( 'wp-polyfill' ) ), + $dependencies, filemtime( $path ), true ); diff --git a/packages/scripts/config/webpack.config.js b/packages/scripts/config/webpack.config.js index 44f173d958e0f9..5a3b30163a4325 100644 --- a/packages/scripts/config/webpack.config.js +++ b/packages/scripts/config/webpack.config.js @@ -67,7 +67,7 @@ const config = { // WP_LIVE_RELOAD_PORT global variable changes port on which live reload works // when running watch mode. ! isProduction && new LiveReloadPlugin( { port: process.env.WP_LIVE_RELOAD_PORT || 35729 } ), - new DependencyExtractionWebpackPlugin(), + new DependencyExtractionWebpackPlugin( { injectPolyfill: true } ), ].filter( Boolean ), stats: { children: false,