diff --git a/src/libs/IntlPolyfill/index.js b/src/libs/IntlPolyfill/index.js index 4b6a964645d8..17d07f32cfce 100644 --- a/src/libs/IntlPolyfill/index.js +++ b/src/libs/IntlPolyfill/index.js @@ -1,4 +1,5 @@ import shouldPolyfill from './shouldPolyfill'; +import polyfillNumberFormat from './polyfillNumberFormat'; /** * Polyfill the Intl API if the ICU version is old. @@ -10,9 +11,5 @@ export default function intlPolyfill() { } // Just need to polyfill Intl.NumberFormat for web based platforms - require('@formatjs/intl-numberformat/polyfill-force'); - - // Load en & es Locale data - require('@formatjs/intl-numberformat/locale-data/en'); - require('@formatjs/intl-numberformat/locale-data/es'); + polyfillNumberFormat(); } diff --git a/src/libs/IntlPolyfill/index.native.js b/src/libs/IntlPolyfill/index.native.js index 8deafb2280a2..b104d490e091 100644 --- a/src/libs/IntlPolyfill/index.native.js +++ b/src/libs/IntlPolyfill/index.native.js @@ -1,4 +1,5 @@ import shouldPolyfill from './shouldPolyfill'; +import polyfillNumberFormat from './polyfillNumberFormat'; /** * Polyfill the Intl API, always performed for native devices. @@ -12,9 +13,5 @@ export default function polyfill() { require('@formatjs/intl-getcanonicallocales/polyfill'); require('@formatjs/intl-locale/polyfill'); require('@formatjs/intl-pluralrules/polyfill'); - require('@formatjs/intl-numberformat/polyfill-force'); - - // Load en & es Locale data - require('@formatjs/intl-numberformat/locale-data/en'); - require('@formatjs/intl-numberformat/locale-data/es'); + polyfillNumberFormat(); } diff --git a/src/libs/IntlPolyfill/polyfillNumberFormat.js b/src/libs/IntlPolyfill/polyfillNumberFormat.js new file mode 100644 index 000000000000..91bda9d6c368 --- /dev/null +++ b/src/libs/IntlPolyfill/polyfillNumberFormat.js @@ -0,0 +1,13 @@ +/** + * Common imports that are required for all platforms + */ + +function polyfillNumberFormat() { + require('@formatjs/intl-numberformat/polyfill-force'); + + // Load en & es Locale data + require('@formatjs/intl-numberformat/locale-data/en'); + require('@formatjs/intl-numberformat/locale-data/es'); +} + +export default polyfillNumberFormat;