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

Not as optimized for Browserify as it could be. #29

Closed aickin closed 7 years ago

aickin commented 8 years ago

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.

nolanlawson commented 7 years ago

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).

davidmarkclements commented 7 years ago

Should this be closed due to #36?

nolanlawson commented 7 years ago

yes