Hi, I could use some help with getting lazy-loading of locale files to work when running my application in production. I bootstrapped the project with create-react-app and it works in development but running the production build yields the following error, originating in the webpack function webpackAsyncContext
Uncaught (in promise) TypeError: undefined is not a function
but the previous step in the stack trace was the await import in my I18nLoader component's loadCatalog function which looks like this:
loadCatalog = async language => {
// prettier-ignore
const catalog = await import(
/* webpackMode: "lazy", webpackChunkName: "i18n-[index]" */
`../../locale/${language}/messages.js`);
this.setState(state => ({
catalogs: {
...state.catalogs,
[language]: unpackCatalog(catalog),
},
}));
};
I'm guessing there's some configuration I'm missing but I can't figure it out and would appreciate some help!
Is it possible to share the bare minimum of your project? It would make debugging much easier. Otherwise I'll try what you said during weekend (bootstrap CRA, eject, setup lingui, add async loader).
I'm sorry, it's not possible for me to share the project I'm working on at the moment. I'll be working on it more on Tuesday if you can't find anything during the weekend.
I've not been able to figure out what's causing the error. Have you found anything that could cause something like this?
Disregard, it was me being a doofus! I had put babel-polyfill in devDependencies which means the await import broke when running in production.
Glad you figured it out! 馃憤 I'm sorry for lack of communication from my side, but I'm a bit overwhelmed last few weeks...
It's all good dude, js-lingui is amazing so thanks for doing what you do!
Most helpful comment
It's all good dude,
js-linguiis amazing so thanks for doing what you do!