New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SIMPLE PATCH READY] Simple hack for compatibility with Turbopack (NextJS) #1854
Comments
Thanks for the patch. Do they have documentation about compatibility of turborepo with webpack loaders? As far as I understand from your patch when loader is executed by turborepo, there is no Just for context: condition: namespace: this._module.type === "json" ? "json" : "es", Made to overcome the issue with webpack. Webpack doesn't allow (at least with public methods) switching type of the module in the loader. It means if you're loading "*.json" module through loader webpack expects json output from this loader. When you load any unknown to webpack module such as So this poses a problem, lingui user may load and compile catalog using |
@thekip It does not break compat with webpack by chacking if we have It's just a quick&dirty hack to make sure this works, as turbopack makes compilation so much quicker. |
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
@lingui/[email protected]
for the project I'm working on.I've been trying to setup turbopack with my project due to enormous compilation times, and figured out why things do not work as expected - it's the loader expecting webpack environment, even though it's not really doing anything with the module definitions.
With a simple change, the loader is now turbopack-swc-compliant.
Maybe there's a better way to figure out
Just for documentation reason, I'm additionally including my
next.config.js
, so that documentation for NextJS+SWC loader+Turbopack can be improved in the future. :)The usage differs a little bit after using Turbopack, as it's going to be just direct imports like shown below.
You no longer need the prefix of
@lingui/loader!
before your imported.po
files!Package versions, but most likely any nextjs version with turbopack will have the same problem:
"next": "^14.1.0",
"@lingui/loader": "^4.6.0",
I might try to solve this with a proper PR, but adding a simple patch like this is definitely better than just leaving it be!
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
(I have decided to leave this template, as it's pretty slick and I think more people could use it. 😄 )
The text was updated successfully, but these errors were encountered: