Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize output for production bundles #15

Closed
4 tasks
ivanhofer opened this issue Mar 14, 2021 · 0 comments
Closed
4 tasks

optimize output for production bundles #15

ivanhofer opened this issue Mar 14, 2021 · 0 comments
Labels
help wanted Extra attention is needed optimization Things that could reduce bundle-size or make it more efficient

Comments

@ivanhofer
Copy link
Owner

ivanhofer commented Mar 14, 2021

If you use keyed arguments inside your translations e.g. HI: Hello {name}!, the function to translate that message will also need to pass an object with the property name in it. It sure is more readable than passing index-based arguments, but it needs more characters. Depending of the amount and the length of the argument-property it will have a negative inpact on the generated bundle-size.

We could automatically rewrite arguments for production

if you have a translation like this:

export const en = {
   HI: 'Hello {name}!'
   // other translations
}

and use it inside your code like:

const message = LL.HI({ name: 'John' })

it could be optimize to the following code:

export const en = {
   HI: 'Hello {0}!'
   // other translations
}

const message = LL.HI('John')

Also the keys itself can be minified e.g. from 'HI' to 'a'

const message = LL.a('John')

What needs to be done:

  • write a rollup-plugin (using AST transforms)
    • rewrite all translations to use index-based arguments
    • rewrite all keys to use a shorter version (or an array with indices)
    • parse all translation calls and rewrite keyed arguments to index-based arguments
@ivanhofer ivanhofer added optimization Things that could reduce bundle-size or make it more efficient help wanted Extra attention is needed labels May 27, 2021
Repository owner locked and limited conversation to collaborators Oct 1, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
help wanted Extra attention is needed optimization Things that could reduce bundle-size or make it more efficient
Projects
None yet
Development

No branches or pull requests

1 participant