New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge modules before minification #27

Closed
gfwilliams opened this Issue Mar 30, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@gfwilliams
Copy link
Member

gfwilliams commented Mar 30, 2016

Add a minification option that converts module code of the form:

// these lines currently get added by the ide
Modules.removeAllCached();
Modules.addModule("x","exports.foo = function() {console.log('Hello'); };exports.unused = 42;");
// actual code
var a = require("x");
a.foo();

to something like:

// these lines currently get added by the ide
var required_x = (function(){
  var exports = {}; 
  exports.foo = function() {console.log('Hello'); }; 
  exports.unused = 42;
  return exports; 
})();
// actual code
var a = required_x;
a.foo();

This might need some tweaking, but the idea is that when the minifier runs, it can:

  • Inline small functions/variables in modules
  • Make function names in modules a single name
  • Detect unused functions and totally remove them

This would massively decrease the size of uploaded code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment