nolanlawson / optimize-js

Optimize a JS file for faster parsing (UNMAINTAINED)
https://nolanlawson.github.io/optimize-js
Apache License 2.0
3.75k stars 104 forks source link

Browserify-specific fix for #29 #36

Closed aickin closed 7 years ago

aickin commented 7 years ago

Fix for #29, trying to optimize browserify modules, in a very specific way.

This fix will optimize function expressions that are:

Added both positive and negative test cases. I did some basic testing against the PouchDB benchmark, and this PR makes it a lot faster.

nolanlawson commented 7 years ago

This looks fantastic! One thing I was momentarily confused on was:

browserify-style function call that has non-numeric object indices shouldn't be optimized

I thought this referred to Browserify with the bundle-collapser plugin vs without, but I tested manually and confirmed that both bundle-collapser style and regular style are covered (i.e. parens are correctly added). I'll add some additional tests on the way in to make this clearer.

BTW just a quick remark that these PRs are incredibly thorough and well-written, and I'm extremely grateful that you're improving my little weekend project so much. 🙇 optimize-js is suddenly turning into a very nice general-purpose tool!

aickin commented 7 years ago

BTW just a quick remark that these PRs are incredibly thorough and well-written

Aw shucks, my pleasure. Thanks for accepting the PRs!

nki2 commented 7 years ago

It seems this update is not included in the release v1.0.2 yet. (not avail via npm neither) Could you please check (and make it available if possible) Thank you!

PS: I tried it on a large browserify project and I had HUGE improvements!! Great work!

nolanlawson commented 7 years ago

I'm going to work on a large rewrite of the benchmarks to include better stats, and then re-run them to ensure there are no regressions. Unfortunately I've been swamped, hence why this has sat for so long.