Namespace support using js module imports #3309
Unanswered
minht11
asked this question in
[Paraglide] General
Replies: 1 comment 4 replies
-
Hmmm, admittedly cool proposal. Question: Is this still relevant after supporting "nesting" via opral/inlang-paraglide-js#285? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I know I know namespace support has been discussed a lot. I understand your reasoning about not wanting to support it because of
namespace.key
access is not valid JS identifier, complexity and so on, but dealing with large amount of translations is really huge hit to DX.Currently it is possible to use plugin-inlang-json or plugin-inlang-i18next but then you lose on treeshaking benefits and vite/cli integrations of plugin-inlang-messageFormat.
So my proposal in addressing your concerns is to use JS module system, instead of merging namespaces into one object. For example let's say you have 3 namespaces
common
app
andsite
. It would looks something like this:Now namespaces are all separate and treeshaking does not suffer. If you wanted to merge them for some sort of upload functionality you can use non valid js identifier like
site@welcome
to know in which namespace it belongs.If user wants they can use path alias/auto imports to make it DX better but that is up to them.
I imagine implementing this in current plugin paraglide vite plugin would not be too hard, since you would just read more files and emit them, leaving heavy lifting to JS module imports.
Beta Was this translation helpful? Give feedback.
All reactions