diff --git a/news/5207.bugfix b/news/5207.bugfix new file mode 100644 index 0000000000..3b232b0b74 --- /dev/null +++ b/news/5207.bugfix @@ -0,0 +1 @@ +restrict moment.js locales to supported languages @mamico diff --git a/package.json b/package.json index 04e53f270c..43b2a701b5 100644 --- a/package.json +++ b/package.json @@ -422,6 +422,7 @@ "jest": "26.6.3", "jest-environment-jsdom": "^26", "jsonwebtoken": "9.0.0", + "moment-locales-webpack-plugin": "1.2.0", "react-error-overlay": "6.0.9", "react-is": "^16.13.1", "release-it": "^16.1.3", diff --git a/razzle.config.js b/razzle.config.js index e004de5a34..d7dafc57f3 100644 --- a/razzle.config.js +++ b/razzle.config.js @@ -13,6 +13,7 @@ const AddonConfigurationRegistry = require('./addon-registry'); const CircularDependencyPlugin = require('circular-dependency-plugin'); const TerserPlugin = require('terser-webpack-plugin'); const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); +const MomentLocalesPlugin = require('moment-locales-webpack-plugin'); const fileLoaderFinder = makeLoaderFinder('file-loader'); @@ -133,12 +134,9 @@ const defaultModify = ({ } config.plugins.unshift( - // restrict moment.js locales to en/de - // see https://github.com/jmblog/how-to-optimize-momentjs-with-webpack for details - new webpack.ContextReplacementPlugin( - /moment[/\\]locale$/, - new RegExp(Object.keys(languages).join('|')), - ), + // restrict moment.js locales to supported languages + // see https://momentjs.com/docs/#/use-it/webpack/ for details + new MomentLocalesPlugin({ localesToKeep: Object.keys(languages) }), new LodashModuleReplacementPlugin({ shorthands: true, cloning: true, diff --git a/yarn.lock b/yarn.lock index a0db202cfc..a2ba724770 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3327,6 +3327,7 @@ __metadata: lodash-webpack-plugin: 0.11.6 mini-css-extract-plugin: 2.7.2 moment: 2.29.4 + moment-locales-webpack-plugin: 1.2.0 object-assign: 4.1.1 pofile: 1.0.10 postcss: 8.4.13 @@ -16985,6 +16986,13 @@ __metadata: languageName: node linkType: hard +"lodash.difference@npm:^4.5.0": + version: 4.5.0 + resolution: "lodash.difference@npm:4.5.0" + checksum: ecee276aa578f300e79350805a14a51be8d1f12b3c1389a19996d8ab516f814211a5f65c68331571ecdad96522b863ccc484b55504ce8c9947212a29f8857d5a + languageName: node + linkType: hard + "lodash.escaperegexp@npm:^4.1.2": version: 4.1.2 resolution: "lodash.escaperegexp@npm:4.1.2" @@ -17837,6 +17845,18 @@ __metadata: languageName: node linkType: hard +"moment-locales-webpack-plugin@npm:1.2.0": + version: 1.2.0 + resolution: "moment-locales-webpack-plugin@npm:1.2.0" + dependencies: + lodash.difference: ^4.5.0 + peerDependencies: + moment: ^2.8.0 + webpack: ^1 || ^2 || ^3 || ^4 || ^5 + checksum: bb5daebfc2f2bd0c003b9d576893531edc6ac3c884c77fc4c3a7c8d228340c9a26a5c7676c8e4505922eebb1309f2defbcf619a1706d7d7e579039690df2487b + languageName: node + linkType: hard + "moment@npm:2.29.4, moment@npm:2.x, moment@npm:>=1.6.0": version: 2.29.4 resolution: "moment@npm:2.29.4"