function hello() {
return 'hello'
}
define(function(){
function world() {
return hello() +'world';
}
});
打包后生成
if ("undefined" == typeof SP$) SP$ = function () {
var e = {}, n = function () {
return !1
}, r = {};
var t = function (n, r) {
return e.toString.call(n) === "[object " + r + "]"
};
return function (e, a) {
var i = r[e], c = t(a, "Function");
if (null != a && !c) i = a;
if (c) {
var o = [];
for (var f = 2, l = arguments.length; f < l; f++)o.push(arguments.callee(arguments[f]));
var u = {};
o.push.call(o, u, {}, n, []);
var s = a.apply(null, o) || u;
if (!i || !t(s, "Object")) i = s; else if (Object.keys)for (var b = Object.keys(s), f = 0, l = b.length,
d; f < l; f++) {
d = b[f];
i[d] = s[d]
} else for (var d in s)i[d] = s[d]
}
if (null == i) i = {};
r[e] = i;
return i
}
}();
SP$("a2e2234f08c9abcffd8c6990a600a5e2", function () {
function e() {
//hello function 消失了
return hello() + "world"
}
});
SP$("27dc51be1142bbdf8060d8dc0c454a2f", function () {
}, "a2e2234f08c9abcffd8c6990a600a5e2");
使用NEJ打包,当define中存在闭包,打包后会无法找到引用的代码,如,源代码
打包后生成