From 056e46120e35d2460e4276177ce50b6bbe5f9c6a Mon Sep 17 00:00:00 2001 From: Scott Cooper Date: Thu, 22 May 2025 12:42:31 -0700 Subject: [PATCH] build(rspack): Add back moment IgnorePlugin Was missing from the rspack config for some reason but is required to lazy load the locale/moment chunks we create. Added a comment that describes the purpose. --- rspack.config.ts | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/rspack.config.ts b/rspack.config.ts index 70e0dd14ad1408..cb8cafd84e319a 100644 --- a/rspack.config.ts +++ b/rspack.config.ts @@ -293,10 +293,32 @@ const appConfig: Configuration = { }, plugins: [ /** - * Adds build time measurement instrumentation, which will be reported back - * to sentry + * Without this, webpack will chunk the locales but attempt to load them all + * eagerly. */ - // new SentryInstrumentation(), + new rspack.IgnorePlugin({ + contextRegExp: /moment$/, + resourceRegExp: /^\.\/locale$/, + }), + + /** + * Restrict translation files that are pulled in through app/translations.jsx + * and through moment/locale/* to only those which we create bundles for via + * locale/catalogs.json. + * + * Without this, webpack will still output all of the unused locale files despite + * the application never loading any of them. + */ + new rspack.ContextReplacementPlugin( + /sentry-locale$/, + path.join(__dirname, 'src', 'sentry', 'locale', path.sep), + true, + new RegExp(`(${supportedLocales.join('|')})/.*\\.po$`) + ), + new rspack.ContextReplacementPlugin( + /moment\/locale/, + new RegExp(`(${supportedLanguages.join('|')})\\.js$`) + ), /** * TODO(epurkhiser): Figure out if we still need these @@ -332,25 +354,6 @@ const appConfig: Configuration = { ...(SHOULD_ADD_RSDOCTOR ? [new RsdoctorWebpackPlugin({})] : []), - /** - * Restrict translation files that are pulled in through app/translations.jsx - * and through moment/locale/* to only those which we create bundles for via - * locale/catalogs.json. - * - * Without this, webpack will still output all of the unused locale files despite - * the application never loading any of them. - */ - new rspack.ContextReplacementPlugin( - /sentry-locale$/, - path.join(__dirname, 'src', 'sentry', 'locale', path.sep), - true, - new RegExp(`(${supportedLocales.join('|')})/.*\\.po$`) - ), - new rspack.ContextReplacementPlugin( - /moment\/locale/, - new RegExp(`(${supportedLanguages.join('|')})\\.js$`) - ), - /** * Copies file logo-sentry.svg to the dist/entrypoints directory so that it can be accessed by * the backend