-
Notifications
You must be signed in to change notification settings - Fork 590
Description
PR #436
Goal
On client side, performance is also about how fast our page loads. So, size matters. How to get the smallest/leanest bundle for production?
Suppose we need a plural function for English. That is what we need: a function that given a number, outputs the plural form. But, in order to get that, we need the English plural rules (from CLDR) and the library code to parse that rules in order to generate this simple function function( count ) { return count == 1 ? "one" : "other"; }. In the end, this tiny thing is what matters. What if we could precompile that at build time and deploy only this tiny function.
Our goal is to allow our formatters/parsers to output the precompiled function. So, by managing that at build time, we can remove the need for most of the library at runtime.
General ideas
- All formatters/parsers should expose a
.toString()function to output itself as a clean string representation. Below, I'm referring to this function as runtime-formatters/runtime-parsers. - runtime-formatters/runtime-parsers should not depend on CLDR data. But, it should depend on pre-processed properties only.
- runtime-formatters/runtime-parsers can reference other functions. Those functions should be packed and distributed as the runtime library for each module. For example,
globalize/date.runtime.js,globalize/number.runtime.js, etc.
References