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
I agree it's far too brittle with far too much overhead to track all function calls, however I think we can only cover some base, by restricting to functions that are exported and only used once. In this case, we can get all of its params. What's better, some params may be literal:
module.js:
exportdefaultfunctionfoo(a,b,enableSomeMode=true){if(enableSomeMode){// lots of code here}returna+b}
It's actually a common pattern for a library with many settings.
can also be removed! Actually only need to add enableSomeMode=false in function entry, the the current rollup can already remove a false condition.
I'm trying to use this strategy to reduce Vue component's size, in this repo, reduce a component size from 12.76kb to 9.22kb. I think it should work for many other librarys.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I have read #4466, #4498 and #4520 , to conclude, it is a try to remove unused default parameters like below:
module.js
app.js
:To produce:
I agree it's far too brittle with far too much overhead to track all function calls, however I think we can only cover some base, by restricting to functions that are exported and only used once. In this case, we can get all of its params. What's better, some params may be literal:
module.js
:It's actually a common pattern for a library with many settings.
However, if we only use it once:
app.js
:Then not only default param can be removed,
can also be removed! Actually only need to add
enableSomeMode=false
in function entry, the the current rollup can already remove afalse
condition.I'm trying to use this strategy to reduce Vue component's size, in this repo, reduce a component size from 12.76kb to 9.22kb. I think it should work for many other librarys.
Beta Was this translation helpful? Give feedback.
All reactions