Closed belaczek closed 1 year ago
Would be fixed by https://github.com/lingui/js-lingui/pull/1349
@belaczek what exactly wrong with current extractor and typescript experimental decorators? I will try to take this into account in new version of extractor.
Hi and thanks for reaching back. Our project is somehow specific and full of dependency injections and we have to use ts-loader
along with babel-loader
since babel
alone fails on circular dependencies while ts-loader
can handle it well.
When I run lingui extract
with the default extractor, it fails with the following error:
Cannot process file xxx.tsx: Duplicate declaration "Trans"
I tried to solve this by playing around with our babel
rules and some other tips mentioned [here](https://github.com/lingui/js-lingui/issues/952), but with not much luck. In the end, the only working solution was following:
typescript
extractor in lingui.config.ts
:extractors: [
require.resolve('@lingui/cli/api/extractors/typescript'),
] as any,
babel
preset for lingui
:{
"env": {
"production": {
"presets": ["@nrwl/react/babel"]
},
"development": {
"presets": ["@nrwl/react/babel"],
"plugins": ["react-refresh/babel", "macros"]
},
// We want an empty babel config for lingui extract and compile scripts.
// It uses babel internally and the @nrwl/react/babel preset makes the compilation fail for some reason.
// The lingui script already injects its own needed plugins anyway.
"locales": {
"presets": [],
"plugins": []
}
}
}
BABEL_ENV=locales lingui extract --config lingui.config.ts
.Hi @belaczek we just merged into next
branch https://github.com/lingui/js-lingui/pull/1367
This should resolve issues described in the message above. This is not released yet and would be included in next major v4 release. But i want to ask you to try a development build on your project and share your feedback. Did it fix the issues or not.
You need to follow contribution guide to be able to use it in your project.
Thanks in advance.
Hi, I just tested v4 and the issue is fixed. No explicit extractor is needed now. Thank you very much for resolution 👍
Describe the bug After updating lingui to version 3.16.0, the typescript extractor is no longer exposed by package.json and cannot be imported. Our project relies on it, as the default babel exporter alone has problems with experimental decorators.
To Reproduce Steps to reproduce the behavior, possibly with minimal code sample, e.g:
Expected behavior
lingui extract
scripts works with imported typescript exporter.Additional context Add any other context about the problem here.