You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I want to extract configured locales and default locales to a separate file (i18n.config.ts) so it can be consumed by other parts of the app without duplicating configuration with full type support. But such a file cannot be imported inside the lingui.config.js file.
Furthermore, Typescript based config allows using ESM easily to have everything nicely typed.
Describe proposed solution
The cosmiconfig allows using custom loaders and to specify custom search paths. Specifically, there is official Typescript loader where you can see how the configuration looks like. It's pretty straightforward.
Describe alternatives you've considered
An alternative is to keep using untyped lingui.config.js and suffer from it :)
Additional context
There is a slight issue in the linked loader plugin which makes it work only with async code. Since the Lingui is using cosmiconfigSync() it doesn't work together. I already created the PR to address that, but the loader seems unmaintained.
However, if you look at its source code, it's like 15 LoC so I wouldn't hesitate much to just copy & paste it inside Lingui. Given it's for the CLI, it doesn't matter that much.
I am willing to make a PR if you would accept this approach.
The text was updated successfully, but these errors were encountered:
danielkcz
changed the title
Enabled TypeScript based config
Enable TypeScript based config
Jan 13, 2021
Is your feature request related to a problem? Please describe.
I want to extract configured locales and default locales to a separate file (
i18n.config.ts
) so it can be consumed by other parts of the app without duplicating configuration with full type support. But such a file cannot be imported inside thelingui.config.js
file.Furthermore, Typescript based config allows using ESM easily to have everything nicely typed.
Describe proposed solution
The
cosmiconfig
allows using custom loaders and to specify custom search paths. Specifically, there is official Typescript loader where you can see how the configuration looks like. It's pretty straightforward.https://github.com/EndemolShineGroup/cosmiconfig-typescript-loader
Describe alternatives you've considered
An alternative is to keep using untyped
lingui.config.js
and suffer from it :)Additional context
There is a slight issue in the linked loader plugin which makes it work only with async code. Since the Lingui is using
cosmiconfigSync()
it doesn't work together. I already created the PR to address that, but the loader seems unmaintained.However, if you look at its source code, it's like 15 LoC so I wouldn't hesitate much to just copy & paste it inside Lingui. Given it's for the CLI, it doesn't matter that much.
I am willing to make a PR if you would accept this approach.
The text was updated successfully, but these errors were encountered: