(webpack) dont bundle @formatjs locale data

refs FOO-2835
flag = none

apply the same treatment we did in FOO-2801 for canvas's locale data
files but this time for @formatjs ones... i arrived at the list of those
4 files/folders through the webpack analyzer: you see them very big and
taking up most of the bundle space

this does NOT implement cache busting, like we do for most static
assets, and we probably should in case we ever update the @formatjs
packages

~ test plan ~

polyfills are still installed where applicable

Change-Id: I42892000d05cac408f9366b204ed77939210c908
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/294596
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Charley Kline <ckline@instructure.com>
Product-Review: Charley Kline <ckline@instructure.com>
QA-Review: Charley Kline <ckline@instructure.com>
This commit is contained in:
Ahmad Amireh 2022-06-23 13:29:13 +03:00
parent 5cb2850b67
commit 7a52d3e1ef
3 changed files with 16 additions and 5 deletions

View File

@ -79,6 +79,17 @@ gulp.task('rev', () => {
.pipe(jsFilter.restore)
}
stream = stream.pipe(
gulp.src([
'./node_modules/@formatjs/intl-datetimeformat/add-all-tz.js',
'./node_modules/@formatjs/intl-datetimeformat/locale-data/*.js',
'./node_modules/@formatjs/intl-numberformat/locale-data/*.js',
'./node_modules/@formatjs/intl-relativetimeformat/locale-data/*.js',
], {
base: './node_modules'
})
)
return stream
.pipe(gulp.dest(DIST))
.pipe(gulpPlugins.rev.manifest())

View File

@ -42,16 +42,16 @@ const shouldPolyfill = {
const polyfillImports = {
DateTimeFormat: async () => {
await import('@formatjs/intl-datetimeformat/polyfill-force')
return import('@formatjs/intl-datetimeformat/add-all-tz')
return import(/* webpackIgnore: true */ '/dist/@formatjs/intl-datetimeformat/add-all-tz.js')
},
NumberFormat: () => import('@formatjs/intl-numberformat/polyfill-force'),
RelativeTimeFormat: () => import('@formatjs/intl-relativetimeformat/polyfill-force')
}
const localeImports = {
DateTimeFormat: l => import(`@formatjs/intl-datetimeformat/locale-data/${l}`),
NumberFormat: l => import(`@formatjs/intl-numberformat/locale-data/${l}`),
RelativeTimeFormat: l => import(`@formatjs/intl-relativetimeformat/locale-data/${l}`)
DateTimeFormat: l => import(/* webpackIgnore: true */ `/dist/@formatjs/intl-datetimeformat/locale-data/${l}.js` ),
NumberFormat: l => import(/* webpackIgnore: true */ `/dist/@formatjs/intl-numberformat/locale-data/${l}.js`),
RelativeTimeFormat: l => import(/* webpackIgnore: true */ `/dist/@formatjs/intl-relativetimeformat/locale-data/${l}.js`),
}
// Check to see if there is native support in the specified Intl subsystem for

View File

@ -489,4 +489,4 @@ function globPlugins(pattern) {
absolute: true,
cwd: canvasDir
})
}
}