-
-
Notifications
You must be signed in to change notification settings - Fork 87
transform bundle so no runtime parsing is needed #68
Copy link
Copy link
Closed
Labels
help wantedExtra attention is neededExtra attention is neededoptimizationThings that could reduce bundle-size or make it more efficientThings that could reduce bundle-size or make it more efficient
Description
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 enthe production bundle output could be:
const en: Translation = {
'HELLO': ['Hi ', { k: 'name' }, '!']
}
export default enThis 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:
- evaluate the impact regarding bundle size
- evaluate the time-savings if message parsing is not needed
- implement an AST-transform function that parses and replaces each message
- remove parsing part from output bundle
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is neededoptimizationThings that could reduce bundle-size or make it more efficientThings that could reduce bundle-size or make it more efficient