Commit 59e89488cf8 for woocommerce
commit 59e89488cf87b6efa4ce640e2ddfb378eec814ee
Author: louwie17 <lourensschep@gmail.com>
Date: Fri Apr 17 13:48:11 2026 +0200
Fix moment-timezone console errors by externalising to WordPress core (#64201)
* Fix moment-timezone errors by using WordPress core's bundled version
Replace the bundled (pre-2000-stripped) copy of moment-timezone in the
admin webpack build with an external pointing to window.moment, which is
WordPress core's own moment-timezone bundle with full timezone data.
Also removes the now-redundant MomentTimezoneDataPlugin, drops its dev
dependency, and adds defensive suppressions in the blocks E2E test
fixture for any residual moment-timezone console errors.
* Add changelog entry for moment-timezone fix
* Revert moment-timezone suppressions from E2E test fixture
* Update pnpm-lock
diff --git a/plugins/woocommerce/changelog/fix-wooa7s-1355-moment-timezone-warnings b/plugins/woocommerce/changelog/fix-wooa7s-1355-moment-timezone-warnings
new file mode 100644
index 00000000000..5218c125734
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-wooa7s-1355-moment-timezone-warnings
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix moment-timezone console errors in WooCommerce Admin by using WordPress core's bundled moment-timezone instead of a stripped copy
diff --git a/plugins/woocommerce/client/admin/package.json b/plugins/woocommerce/client/admin/package.json
index cfd1f2a8b3b..4ac24f5ed84 100644
--- a/plugins/woocommerce/client/admin/package.json
+++ b/plugins/woocommerce/client/admin/package.json
@@ -197,7 +197,6 @@
"mini-css-extract-plugin": "2.9.x",
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
- "moment-timezone-data-webpack-plugin": "1.5.x",
"node-watch": "^0.7.4",
"postcss": "8.4.x",
"postcss-color-function": "^4.1.0",
diff --git a/plugins/woocommerce/client/admin/webpack.config.js b/plugins/woocommerce/client/admin/webpack.config.js
index 3d82dc5bf62..d6db96d8eef 100644
--- a/plugins/woocommerce/client/admin/webpack.config.js
+++ b/plugins/woocommerce/client/admin/webpack.config.js
@@ -6,7 +6,6 @@ const path = require( 'path' );
const fs = require( 'fs' );
const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
const { BundleAnalyzerPlugin } = require( 'webpack-bundle-analyzer' );
-const MomentTimezoneDataPlugin = require( 'moment-timezone-data-webpack-plugin' );
const ForkTsCheckerWebpackPlugin = require( 'fork-ts-checker-webpack-plugin' );
const ReactRefreshWebpackPlugin = require( '@pmmmwh/react-refresh-webpack-plugin' );
@@ -240,6 +239,10 @@ const webpackConfig = {
new WooCommerceDependencyExtractionWebpackPlugin( {
requestToExternal( request ) {
switch ( request ) {
+ case 'moment-timezone':
+ // Use WordPress core's window.moment (which includes moment-timezone)
+ // instead of bundling a stripped copy.
+ return 'moment';
case 'react/jsx-runtime':
case 'react/jsx-dev-runtime':
// @wordpress/dependency-extraction-webpack-plugin version bump related, which added 'react-jsx-runtime' dependency.
@@ -272,12 +275,12 @@ const webpackConfig = {
return null;
}
},
+ requestToHandle( request ) {
+ if ( request === 'moment-timezone' ) {
+ return 'moment';
+ }
+ },
} ),
- // Reduces data for moment-timezone.
- new MomentTimezoneDataPlugin( {
- // This strips out timezone data before the year 2000 to make a smaller file.
- startYear: 2000,
- } ),
process.env.ANALYZE && new BundleAnalyzerPlugin(),
// We only want to generate unminified files in the development phase.
WC_ADMIN_PHASE === 'development' &&
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 718713cf5ad..21ccab3c585 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -3840,9 +3840,6 @@ importers:
moment-timezone:
specifier: ^0.5.43
version: 0.5.48
- moment-timezone-data-webpack-plugin:
- specifier: 1.5.x
- version: 1.5.1(moment-timezone@0.5.48)(webpack@5.97.1)
node-watch:
specifier: ^0.7.4
version: 0.7.4
@@ -18841,12 +18838,6 @@ packages:
module-details-from-path@1.0.4:
resolution: {integrity: sha512-EGWKgxALGMgzvxYF1UyGTy0HXX/2vHLkw6+NvDKW2jypWbHpjQuj4UMcqQWXHERJhVGKikolT06G3bcKe4fi7w==}
- moment-timezone-data-webpack-plugin@1.5.1:
- resolution: {integrity: sha512-1le6a35GgYdWMVYFzrfpE/F6Pk4bj0M3QKD6Iv6ba9LqWGoVqHQRHyCTLvLis5E1J98Sz40ET6yhZzMVakwpjg==}
- peerDependencies:
- moment-timezone: '>= 0.1.0'
- webpack: 4.x.x || 5.x.x
-
moment-timezone@0.5.48:
resolution: {integrity: sha512-f22b8LV1gbTO2ms2j2z13MuPogNoh5UzxL3nzNAYKGraILnbGc9NEE6dyiiiLv46DGRb8A4kg8UKWLjPthxBHw==}
@@ -47205,13 +47196,6 @@ snapshots:
module-details-from-path@1.0.4: {}
- moment-timezone-data-webpack-plugin@1.5.1(moment-timezone@0.5.48)(webpack@5.97.1):
- dependencies:
- find-cache-dir: 3.3.2
- make-dir: 3.1.0
- moment-timezone: 0.5.48
- webpack: 5.97.1(@swc/core@1.15.24)(webpack-cli@5.1.4)
-
moment-timezone@0.5.48:
dependencies:
moment: 2.30.1