Open GalacticHypernova opened 5 months ago
@BobbieGoede I have an idea that could potentially make this work. How about handling the conversion of the message files to a JS file with certain exports, and then using them in the files? That way the bundler could take care of the code splitting, and since some exports won't be used, the will not be included.
Describe the feature
In an app with a lot of translatable content importing the whole language file, even if lazily, will introduce huge network overhead, and most of the time would even be unnecessary, as there will likely be a slight portion of the messages in use for every page. Furthermore, it could introduce data leaks, the most notable example being admin pages having their translation sent to the client. Tree shaking the messages will ensure there is minimal overhead and minimal data sent to the client, which will not compromise data integrity and still allow to use lazy loading as much as possible.
Additional information
Final checks