How to iterate over an array of locales to have a webpack async chunking code

196
May 08, 2018, at 01:16 AM
import { addLocaleData } from 'react-intl';
import { translation } from '../package.json';
import englishMessages from './i18n/en';
translation.locales.forEach((locale) => {
  addLocaleData(require(`react-intl/locale-data/${locale}`).default);
});
const messages = {
  en: () => import('./i18n/en').then((messages) => messages.default),
  fr: () => import('./i18n/fr').then((messages) => messages.default),
};
export default (locale) => {
  if (locale !== 'en') {
    return messages[locale]();
  }
  return englishMessages;
};

I want to iterate over an array of locales to have a web pack async chunking code.

How can I turn it in a loop so chunking is not broken?

(basically: doing the same as in my translation.locales.forEach but for the code that use import(), is that possible?).

Rent Charter Buses Company
READ ALSO
Vue router : TypeError: Cannot read property '$createElement' of undefined

Vue router : TypeError: Cannot read property '$createElement' of undefined

So, I am pretty new to vuejs and it might very well be as stupid mistake from me, but alas, Google doesn't seem to be my friend today as I've been searching for a bit more than 2 hours and found nothing

479
Can't add google map to phonegap

Can't add google map to phonegap

I'm trying to add google map js to my phonegap project

195
Target container is not a DOM element in ReactJS

Target container is not a DOM element in ReactJS

I just started to learn ReactJS and I wrote my first code successfullyWhen the same pattern came to the component thing I am getting a error mentioning _Invariant Violation: registerComponent(

334
“TypeError: _vm.$refs.dialog.save is not a function” in VuetifyJS

“TypeError: _vm.$refs.dialog.save is not a function” in VuetifyJS

I'm using VueJS with VuetifyJS and I get this error as soon as I try to save the time by clicking the OK button:

1159