diff --git a/build/build.ls b/build/build.ls index ca3f0df12c7c..4b58ff281b90 100644 --- a/build/build.ls +++ b/build/build.ls @@ -161,10 +161,8 @@ module.exports = ({modules = [], blacklist = [], library = no}, next)!-> next null """ #banner - !function(undefined){ + !function(__e, __g, undefined){ 'use strict'; - var __e = null, __g = null; - #script // CommonJS export if(typeof module != 'undefined' && module.exports)module.exports = __e; @@ -172,5 +170,5 @@ module.exports = ({modules = [], blacklist = [], library = no}, next)!-> else if(typeof define == 'function' && define.amd)define(function(){return __e}); // Export to global object else __g.core = __e; - }(); + }(1, 1); """ diff --git a/build/index.js b/build/index.js index 4dc2c74b5733..aaa52798ee42 100644 --- a/build/index.js +++ b/build/index.js @@ -84,7 +84,7 @@ if (check(err)) { return; } - next(null, "" + banner + "\n!function(undefined){\n'use strict';\nvar __e = null, __g = null;\n\n" + script + "\n// CommonJS export\nif(typeof module != 'undefined' && module.exports)module.exports = __e;\n// RequireJS export\nelse if(typeof define == 'function' && define.amd)define(function(){return __e});\n// Export to global object\nelse __g.core = __e;\n}();"); + next(null, "" + banner + "\n!function(__e, __g, undefined){\n'use strict';\n" + script + "\n// CommonJS export\nif(typeof module != 'undefined' && module.exports)module.exports = __e;\n// RequireJS export\nelse if(typeof define == 'function' && define.amd)define(function(){return __e});\n// Export to global object\nelse __g.core = __e;\n}(1, 1);"); }); }); }); diff --git a/library/modules/$.core.js b/library/modules/$.core.js index 43cf376dcdae..b5d1f15f86b9 100644 --- a/library/modules/$.core.js +++ b/library/modules/$.core.js @@ -1,3 +1,3 @@ var core = {}; module.exports = core; -if(typeof __e != 'undefined')__e = core; // eslint-disable-line no-undef \ No newline at end of file +if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef \ No newline at end of file diff --git a/library/modules/$.def.js b/library/modules/$.def.js index 0e8f2c495c88..871e5a61bc07 100644 --- a/library/modules/$.def.js +++ b/library/modules/$.def.js @@ -1,6 +1,7 @@ var global = require('./$.global') , isFunction = require('./$.is-function') - , core = require('./$.core'); + , core = require('./$.core') + , PROTOTYPE = 'prototype'; function ctx(fn, that){ return function(){ return fn.apply(that, arguments); @@ -18,7 +19,7 @@ function $def(type, name, source){ , isGlobal = type & $def.G , isProto = type & $def.P , target = isGlobal ? global : type & $def.S - ? global[name] : (global[name] || {}).prototype + ? global[name] : (global[name] || {})[PROTOTYPE] , exports = isGlobal ? core : core[name] || (core[name] = {}); if(isGlobal)source = name; for(key in source){ @@ -36,12 +37,12 @@ function $def(type, name, source){ exp = function(param){ return this instanceof C ? new C(param) : C(param); }; - exp.prototype = C.prototype; + exp[PROTOTYPE] = C[PROTOTYPE]; }(out); else exp = isProto && isFunction(out) ? ctx(Function.call, out) : out; // export exports[key] = exp; - if(isProto)(exports.prototype || (exports.prototype = {}))[key] = out; + if(isProto)(exports[PROTOTYPE] || (exports[PROTOTYPE] = {}))[key] = out; } } module.exports = $def; \ No newline at end of file diff --git a/library/modules/$.global.js b/library/modules/$.global.js index 8f75da770546..8c15fdc5b62d 100644 --- a/library/modules/$.global.js +++ b/library/modules/$.global.js @@ -1,3 +1,3 @@ var global = typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); -if(typeof __g != 'undefined')__g = global; // eslint-disable-line no-undef -module.exports = global; \ No newline at end of file +module.exports = global; +if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef \ No newline at end of file diff --git a/modules/$.core.js b/modules/$.core.js index 43cf376dcdae..b5d1f15f86b9 100644 --- a/modules/$.core.js +++ b/modules/$.core.js @@ -1,3 +1,3 @@ var core = {}; module.exports = core; -if(typeof __e != 'undefined')__e = core; // eslint-disable-line no-undef \ No newline at end of file +if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef \ No newline at end of file diff --git a/modules/$.def.js b/modules/$.def.js index b0f38c3809c9..2141f1add07a 100644 --- a/modules/$.def.js +++ b/modules/$.def.js @@ -2,7 +2,8 @@ var global = require('./$.global') , core = require('./$.core') , hide = require('./$.hide') , $redef = require('./$.redef') - , isFunction = require('./$.is-function'); + , isFunction = require('./$.is-function') + , PROTOTYPE = 'prototype'; function ctx(fn, that){ return function(){ return fn.apply(that, arguments); @@ -21,7 +22,7 @@ function $def(type, name, source){ , isGlobal = type & $def.G , isProto = type & $def.P , target = isGlobal ? global : type & $def.S - ? global[name] || (global[name] = {}) : (global[name] || {}).prototype + ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE] , exports = isGlobal ? core : core[name] || (core[name] = {}); if(isGlobal)source = name; for(key in source){ @@ -36,7 +37,7 @@ function $def(type, name, source){ if(target && !own)$redef(target, key, out); // export if(exports[key] != out)hide(exports, key, exp); - if(isProto)(exports.prototype || (exports.prototype = {}))[key] = out; + if(isProto)(exports[PROTOTYPE] || (exports[PROTOTYPE] = {}))[key] = out; } } module.exports = $def; \ No newline at end of file diff --git a/modules/$.global.js b/modules/$.global.js index 8f75da770546..8c15fdc5b62d 100644 --- a/modules/$.global.js +++ b/modules/$.global.js @@ -1,3 +1,3 @@ var global = typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); -if(typeof __g != 'undefined')__g = global; // eslint-disable-line no-undef -module.exports = global; \ No newline at end of file +module.exports = global; +if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef \ No newline at end of file diff --git a/modules/library/$.def.js b/modules/library/$.def.js index 0e8f2c495c88..871e5a61bc07 100644 --- a/modules/library/$.def.js +++ b/modules/library/$.def.js @@ -1,6 +1,7 @@ var global = require('./$.global') , isFunction = require('./$.is-function') - , core = require('./$.core'); + , core = require('./$.core') + , PROTOTYPE = 'prototype'; function ctx(fn, that){ return function(){ return fn.apply(that, arguments); @@ -18,7 +19,7 @@ function $def(type, name, source){ , isGlobal = type & $def.G , isProto = type & $def.P , target = isGlobal ? global : type & $def.S - ? global[name] : (global[name] || {}).prototype + ? global[name] : (global[name] || {})[PROTOTYPE] , exports = isGlobal ? core : core[name] || (core[name] = {}); if(isGlobal)source = name; for(key in source){ @@ -36,12 +37,12 @@ function $def(type, name, source){ exp = function(param){ return this instanceof C ? new C(param) : C(param); }; - exp.prototype = C.prototype; + exp[PROTOTYPE] = C[PROTOTYPE]; }(out); else exp = isProto && isFunction(out) ? ctx(Function.call, out) : out; // export exports[key] = exp; - if(isProto)(exports.prototype || (exports.prototype = {}))[key] = out; + if(isProto)(exports[PROTOTYPE] || (exports[PROTOTYPE] = {}))[key] = out; } } module.exports = $def; \ No newline at end of file