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.

Webpack 5 Support

See original GitHub issue

Describe the bug I get a parser error when attempting to run a build with webpack 5

To Reproduce Running a build returns with the following error.

****/src/locale/fr-CA/messages.json
Module parse failed: Abstract method Parser.parse. Must be overridden.
File was processed with these loaders:
 * ./loaders/lingui.js

Expected behavior The build would pass.

Additional context I’m using the @latest version of lingui and babel 7.10 with “@lingui/macro”: “2.8.3”

I have tried implementing the following mentioned on this git issue but had other parsing errors.

https://github.com/webpack/webpack/issues/7057

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
semoalcommented, Apr 19, 2021

@marswong @colinaaa give it a try to 3.8.10, I’ve released a fix. I’ve tried with our next-js example which uses webpack 5 under the hook and worked nice

2reactions
semoalcommented, Apr 6, 2021

get in trouble again:

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Using webpack 5. Reason: future.webpack5 option enabled https://nextjs.org/docs/messages/webpack5
event - compiled successfully
event - build page: /
wait  - compiling...
error - ./locales/en/messages.po
Error: Could not retrieve module factory for type LoaderDependency

dependencies:

{
  "dependencies": {
    "@lingui/core": "3.8.3",
    "@lingui/detect-locale": "3.8.3",
    "@lingui/macro": "3.8.3",
    "@lingui/react": "3.8.3",
    "make-plural": "6.2.2",
    "next": "10.1.3",
    "react": "17.0.2",
    "react-dom": "17.0.2"
  },
  "devDependencies": {
    "@babel/core": "7.13.14",
    "@lingui/cli": "3.8.3",
    "@lingui/loader": "3.8.3",
    "babel-plugin-macros": "3.0.1",
    "webpack": "5.30.0"
  }
}

next.config.js:

module.exports = {
  future: {
    webpack5: true,
  },
  webpack: (config) => {
    config.module.rules.push({
      test: /\.po/,
      use: [
        {
          loader: '@lingui/loader',
        },
      ],
    })
    return config
  },
}

Let me create a reproducible repo and we’ll fix the issue asap 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack 5 release (2020-10-10)
Webpack 5 adds support for some CommonJs constructs, allows to eliminate unused CommonJs exports and track referenced export names from require ...
Read more >
facebook/create-react-app - Webpack 5 support overview
Overview of tasks needed for updating CRA to Webpack 5 - Some of the work will support both Webpack 4 + 5 but...
Read more >
What's New in Webpack 5 - Frontend Digest
What's new in Webpack 5 · Faster builds with persistent caching · Smaller bundle sizes · Better long term caching · Breaking changes...
Read more >
Upgrading Webpack 4 → 5 | Square Corner Blog
Webpack 5 Gains · Decreased bundle size by 27-28% · Decreased build time by 10% (2m 54s → 2m 36s) · Cached dev...
Read more >
Webpack 5 Adoption - Next.js
Improved Long Term Caching of Assets: Deterministic code output that is less likely to change between builds; Improved Tree Shaking; Support for assets...
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