You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now TSDX provides good defaults for terser / uglify-es.
Unfortunately fine tuning prop mangling is not supported right now.
Desired Behaviour
As a library author file size is important for me.
Using prop mangling on a project saved ~10% in size (after gzip).
For example given the following code:
conststate={count: 0};state.count++;
Minifying it with terser/uglify-es reduces the following outputs
without mangling
with mangling
vars={count:0};s.count++;
vars={c:0}s.c++;
This would allows me adding more features for the same file size.
As you can probably guess this will only work for internal library code as mangling public option names would not be a good idea:
E.g. Mangling if(options.verbose){..} to if(o.verbose){..} will still work however if(o.x){..} won't.
Therefore terser/uglify-es allows to limit propMangling using a regular expression.
So as a library author I can tell terser to mangle only props starting with a _:
This should be possible now by extending the Rollup config in tsdx.config.js that was added in #183 .
If that is too difficult or if this is a more common request we can think about more easily configuring it. I believe microbundle has a flag for this, but we want to avoid flag sprawl if possible through other means (and IMO config is better than flags generally)
Current Behaviour
Right now TSDX provides good defaults for
terser
/uglify-es
.Unfortunately fine tuning prop mangling is not supported right now.
Desired Behaviour
As a library author file size is important for me.
Using prop mangling on a project saved ~10% in size (after gzip).
For example given the following code:
Minifying it with
terser
/uglify-es
reduces the following outputsThis would allows me adding more features for the same file size.
As you can probably guess this will only work for internal library code as mangling public option names would not be a good idea:
E.g. Mangling
if(options.verbose){..}
toif(o.verbose){..}
will still work howeverif(o.x){..}
won't.Therefore
terser
/uglify-es
allows to limit propMangling using a regular expression.So as a library author I can tell
terser
to mangle only props starting with a_
:with a regular expression
/^_/
would produce the following:Try it out yourself: runkit live demo
Suggested Solution
Allow to set a
regex
for props mangling - if none is given don't mangle props at all.Who does this impact? Who is this for?
This helps library authors to provide smaller libraries.
Describe alternatives you've considered
For example
codekit
uses a prop whitelist instead of a regular expression: https://codekitapp.com/help/terser/Additional context
runkit live demo
terser docs
The text was updated successfully, but these errors were encountered: