Locale lazy-loading breaks for me when running production build
See original GitHub issueHi, 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!
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
vite breaks in production, but works fine in dev mode. #7335
I have tried to remove all the lazy loading as well. And that changed the error from "r" to "_" but it's still...
Read more >Lazy Loading | webpack
Lazy, or "on demand", loading is a great way to optimize your site or application. This practice essentially involves splitting your code at...
Read more >Lazy loading broken on prod build Angular 8 - Stack Overflow
I'm trying to get my lazy loaded routes to work in production. Currently, everything works fine in development mode but when I switch...
Read more >React localization with i18next - LogRocket Blog
With this simple React project to work with, let's run the following command in our ... Lazy loading the translation file from the...
Read more >Dynamic Import of Locales in Angular | by Michael Karén
Lazy load your locale when changing countries. ... We are trying to import too many files, some of which break the build. If...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s all good dude,
js-lingui
is amazing so thanks for doing what you do!Disregard, it was me being a doofus! I had put
babel-polyfill
indevDependencies
which means theawait import
broke when running in production.