In its current implementation typesafe-i18n needs to parse each translation the first time it gets called. The parsing part is taking about half of the bundle size. The whole library could be trimmed to < 0.5 bytes if the parsing would take place compile-time.
Instead of this:
const en: Translation = {
'HELLO': 'Hi {name:string}!'
}
export default en
the production bundle output could be:
const en: Translation = {
'HELLO': ['Hi ', { k: 'name' }, '!']
}
export default en
This would mean slightly larger output for each translation file, but this should compress (gzip) better because of its repetitive pattern. If the parsing is not needed run-time, the library should be even faster (mostly nanoseconds).
What needs to be done:
In its current implementation
typesafe-i18nneeds to parse each translation the first time it gets called. The parsing part is taking about half of the bundle size. The whole library could be trimmed to < 0.5 bytes if the parsing would take place compile-time.Instead of this:
the production bundle output could be:
This would mean slightly larger output for each translation file, but this should compress (
gzip) better because of its repetitive pattern. If the parsing is not needed run-time, the library should be even faster (mostly nanoseconds).What needs to be done: