I'm working on an application that needs to use intl-relativetimeformat
, intl-listformat
and intl-pluralrules
. I think we only need to polyfill to continue supporting IE11 but it's blowing up my bundle size by almost 2MB
Is there a way to polyfill these without blowing up the bundle size? The code that polyfills this looks like this:
if (!('RelativeTimeFormat' in Intl)) {
require('@formatjs/intl-relativetimeformat/polyfill');
try {
require(`@formatjs/intl-relativetimeformat/locale-data/${language}`);
} catch (e) {
require('@formatjs/intl-relativetimeformat/locale-data/en');
}
}
I would think with that if
statement I wouldn't end up with the entire library in the bundle, but I do. On top of that all locale data is bundled (as opposed to just the locale that is needed):
I'm using webpack 4