question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Locale lazy-loading breaks for me when running production build

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ludwigbacklundcommented, Dec 14, 2017

It’s all good dude, js-lingui is amazing so thanks for doing what you do!

1reaction
ludwigbacklundcommented, Dec 14, 2017

Disregard, it was me being a doofus! I had put babel-polyfill in devDependencies which means the await import broke when running in production.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found