js-lingui icon indicating copy to clipboard operation
js-lingui copied to clipboard

Consider providing a `unplugin` lingui-plugin

Open Jaakkonen opened this issue 9 months ago • 1 comments

Problem Description

I'm investigating moving to rsbuild from vite but the lingui plugin for automatically compiling the JS modules exists only in the vite plugin. Thus I need to write my custom module resolver utilizing the internal @lingui/conf package together with @lingui/cli/api to have hot-reloading when translations change.

Proposed Solution

Unplugin is a plugin adapter for buildtools that allows common things like transforming & making virtual modules (like done here) in a cross compatible manner for buildtools (currently supports vite, rspack, rollup, rolldown, farm etc).

There's a 3 years old community attempt at doing this at https://github.com/a1ooha/unplugin-lingui-loader. However having 1st party support for this would be superb!

Alternatives Considered

Writing my own private rsbuild plugin but then I need to use the @lingui/conf package that has been marked as internal.

Additional Context

No response

Jaakkonen avatar May 31 '25 12:05 Jaakkonen

The plugins for bundlers in lingui are not only loaders, they also overcoming issues with the specific ways how these bundlers work, especially with Vite. I'm not sure (although i didn't check unplugin) that it will be possible to achieve the same level of functionality and deep integration using generic abstraction.

Also i don't want to have the duplicating things which will bring even more confusion for consumers, like why i should use dedicated vite plugin if you also providing an unplugin version. Why unplugin version doesn't work same way as dedicated version and so on.

Regarding rspack/rsbuild, AFAIK they advertised that they support loaders from Webpack, so you can use @lingui/loader package for that bundler.

timofei-iatsenko avatar Jun 02 '25 07:06 timofei-iatsenko

@Jaakkonen hi, I created unplugin-lingui, maybe you can give it a try.

Debbl avatar Aug 10 '25 07:08 Debbl

Closing as wont do

timofei-iatsenko avatar Aug 19 '25 12:08 timofei-iatsenko