js-lingui: `lingui extract-experimental` bugs
Describe the bug
- Extracted message id incorrect when
Transchildren has plain text follow JSX element, space is losted
- Dependency tree related files (AboutText.tsx/Developers.tsx) do not extracted in reproduction, but Switcher.tsx did
To Reproduce
https://github.com/yunsii/lingui-examples-nextjs-swc-1797
Expected behavior
- Extract correct message id
- Extract full dependency tree related files
- jsLingui version
v4.5.0 - Macro support:
- I’m using SWC with
@lingui/swc-plugin - I’m using Babel with
babel-macro-plugin - I’m not using macro
About this issue
- Original URL
- State: open
- Created 8 months ago
- Reactions: 1
- Comments: 48 (13 by maintainers)
Commits related to this issue
- refactor(macro): add tests for #1797 issue — committed to thekip/js-lingui by thekip 4 months ago
- refactor(macro): add tests for #1797 issue — committed to thekip/js-lingui by thekip 4 months ago
- Revert "refactor(macro): add tests for #1797 issue" This reverts commit 797fe4eea007454adeda86dfb162205d8e373e76. — committed to thekip/js-lingui by thekip 4 months ago
An update here:
I created a separate discussion, please add your ideas there.
This one is fixed in https://github.com/lingui/js-lingui/pull/1867 separate test case was added
On 4.7.1
On Next
So yeah, you could call that an improvement 😅
Hi @semoal i see following tasks:
/*i18n*/comments which are required by extractor.scssfile, I don’t remember how it is implemented now, but i suppose we should mark as “external” every non js/js-like file for simplicity.I think this 3 is essential to at least unblock following adoption of the extractor.
From my side, i can help with SWC Rust plugin, and can explain how extractor works now.
After basic functionality become stable we can do performance optimizations:
Because it doesn’t take any preprocess step (esbuild) and consume sources directly.
Interesting, thanks for report, that probably related to useLingui and this refactoring I will take a look.
Fixed: https://github.com/lingui/js-lingui/pull/1882
How far @thekip are we of converting this feature in something stable? Probably if you detail which tasks are pending I can help on my free time 😃 We noticed that our catalogs are getting large and this splitting by page would be amazing
I considered that solution in the beginning, even look into that exact library. Solution with esbuild i like more because:
I still think we need to continue with esbuild. The problems mentioned in this issue are fixable, i just don’t have a time for that currently.
Actually, some spaces are deleted intentionally. You can read unit-tests to understand the cases. The issue would be if the final line would be different between what left by macro in the code and what was extracted to catalog.
Yes, it was created as PoC, and actually there not match attention to it, so i could not get enough feedback to make it production ready.
I didn’t investigate it, but i think the problem is similar, when code is processed by esbuild it gets reprinted and space might be dropped.