nolanlawson / optimize-js

Optimize a JS file for faster parsing (UNMAINTAINED)

Home Page:https://nolanlawson.github.io/optimize-js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not as optimized for Browserify as it could be.

aickin opened this issue · comments

In the vein of #7, I think optimize-js also doesn't work optimally for Browserify.

Whereas Webpack wraps modules in function expressions that are elements in an array, Browserify wraps modules in function expressions that are elements in an array which is in turn a value in an object with numeric keys, something like this:

!function(o){
  /* loader code */
}({
  1:[function(o,r){/*module 1 code */}, {}],
  2:[function(o,r){/*module 2 code */}, {}],
  3:[function(o,r){/*module 3 code */}, {}]
}

I noticed in making my patch for #7 and testing on The Cost of Small Modules benchmark repo that optimize-js had essentially no effect on the Browserify bundles, and I'm pretty sure this is why.

Good insight! I 100% failed to notice this. Luckily if we modify the code to fix this, then some of the benchmark code should already run faster, since I know a few of them are build with Browserify (e.g. PouchDB is).

Should this be closed due to #36?