Using Lingui in monorepo over several projects #908
-
We are trying to set up some sort of robust architecture that should be about composing different projects from other small pieces - modules within a single monorepo. It's all configured based on TypeScript path aliases instead of packages that would need to be published to NPM. It works nicely so far. It looks roughly like this. "baseUrl": "src",
"paths": {
"~tools/*": ["../../tools/src/*"]
}, Reusable I18n moduleIdeally, there should be a separate module (still within monorepo) that consolidates all i18n logic including a single version of Lingui. All other modules will simply use this module. The problem I am currently solving is with macros. When I do simply this. export { t } from '@lingui/macro'
// then import in the module code
import { t } from '~tools/lingui'
// tried also relative path in case aliasing is an issue
import { t } from '../../tools/src/lingui' It works syntactically, but the extraction process silently ignores it and nothing is extracted. No output is even generated to the temp folder as I tried to debug it. It's a bit strange why Babel compiler stays silent there. When I change it to direct I expect this is one of many problems for this approach (ie path aliases), but let's start with basics. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You can't use macros from modules with invalid names. See official Second, even if you solved it, you would have to update |
Beta Was this translation helpful? Give feedback.
You can't use macros from modules with invalid names. See official
babel-plugin-macros
documentation for a list of valid macro names.Second, even if you solved it, you would have to update
@lingui/babel-plugin-extract-messages
plugin to actually see your module as well. right now it only looks for@lingui/macro
and@lingui/react
.