From 0b9078ac288c5f6624a906b1640af3f92f2c44ce Mon Sep 17 00:00:00 2001 From: "Grigorii K. Shartsev" Date: Tue, 16 Jan 2024 01:01:06 +0100 Subject: [PATCH] fix: ignore ./locale import from moment/min/moment-with-locales @nextcloud/moment since v1.3.0 uses `moment/min/moment-with-locales.js`. Which works only in Node.js and is not compatible with Webpack bundling. It has an unused function `localLocale` that requires locales by invalid relative path `./locale`. Though it is not used, Webpack tries to resolve it with `require.context` and fails. Signed-off-by: Grigorii K. Shartsev --- webpack.config.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/webpack.config.js b/webpack.config.js index fdc42aa..6f34301 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -114,6 +114,15 @@ module.exports = { // Make appName & appVersion available as a constant new webpack.DefinePlugin({ appName: JSON.stringify(appName) }), new webpack.DefinePlugin({ appVersion: JSON.stringify(appVersion) }), + + // @nextcloud/moment since v1.3.0 uses `moment/min/moment-with-locales.js` + // Which works only in Node.js and is not compatible with Webpack bundling + // It has an unused function `localLocale` that requires locales by invalid relative path `./locale` + // Though it is not used, Webpack tries to resolve it with `require.context` and fails + new webpack.IgnorePlugin({ + resourceRegExp: /^\.\/locale$/, + contextRegExp: /moment\/min$/, + }), ], resolve: {