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

Optimise wrappers#13

Closed
Victorystick wants to merge 7 commits intomasterfrom
optimise-wrappers
Closed

Optimise wrappers#13
Victorystick wants to merge 7 commits intomasterfrom
optimise-wrappers

Conversation

@Victorystick
Copy link
Copy Markdown
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
Copy Markdown
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