Isolate all files in a closure.
This commit is contained in:
parent
ab02135643
commit
fc68a25b21
|
@ -179,7 +179,7 @@ function _handle(req, res, jsFilename, jsFiles) {
|
||||||
|
|
||||||
if(type == "JS")
|
if(type == "JS")
|
||||||
{
|
{
|
||||||
embeds[filename] = compressJS([data]);
|
embeds[filename] = compressJS([isolateJS(data)]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -297,10 +297,16 @@ function tarCode(filesInOrder, files, write) {
|
||||||
for(var i = 0, ii = filesInOrder.length; i < filesInOrder.length; i++) {
|
for(var i = 0, ii = filesInOrder.length; i < filesInOrder.length; i++) {
|
||||||
var filename = filesInOrder[i];
|
var filename = filesInOrder[i];
|
||||||
write("\n\n\n/*** File: static/js/" + filename + " ***/\n\n\n");
|
write("\n\n\n/*** File: static/js/" + filename + " ***/\n\n\n");
|
||||||
write(files[filename]);
|
write(isolateJS(files[filename]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wrap the following code in a self executing function and assign exports to
|
||||||
|
// global. This is a first step towards removing symbols from the global scope.
|
||||||
|
function isolateJS(code) {
|
||||||
|
return '(function (exports) {'+code+'\n}(function () {return this}()));\n';
|
||||||
|
}
|
||||||
|
|
||||||
function compressJS(values)
|
function compressJS(values)
|
||||||
{
|
{
|
||||||
var complete = values.join("\n");
|
var complete = values.join("\n");
|
||||||
|
|
Loading…
Reference in New Issue