Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Optimise wrappers #13

Closed
wants to merge 7 commits into from
Closed

Optimise wrappers #13

wants to merge 7 commits into from

Conversation

Victorystick
Copy link
Contributor

Reduce the overhead of the CommonJS wrappers using a helper function __commonjs_wrapper.

function __commonjs_wrapper(fn, module) {
  return module = { exports: {} }, fn(module, module.exports), module.exports;
}

Result after minification

// before ~75 bytes
var a=function(o){o.exports;return o.exports=r.Foo,o.exports}({exports:{}})

// after ~35 bytes
var a = r(function(r){r.exports=e.Foo})

// webpack (for comparison) ~35 bytes
function(a,b,c){a.exports=c(5).Foo}

See #12 (comment)

@Victorystick Victorystick mentioned this pull request Nov 26, 2015
This was referenced Dec 5, 2015
@Rich-Harris
Copy link
Contributor

Closing this in favour of #20, which has the same result but doesn't include all the unmergeable stuff from other PRs

@Rich-Harris Rich-Harris closed this Dec 5, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants