From 71dfced06de716dcc24cdc933ee02bdb4e75d535 Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Sun, 15 Jan 2012 22:56:41 -0800 Subject: [PATCH] Provide filename to isolation function. --- node/utils/Minify.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/node/utils/Minify.js b/node/utils/Minify.js index 8b198f3e..016739b1 100644 --- a/node/utils/Minify.js +++ b/node/utils/Minify.js @@ -179,7 +179,8 @@ function _handle(req, res, jsFilename, jsFiles) { if(type == "JS") { - embeds[filename] = compressJS([isolateJS(data)]); + var shortFilename = filename.replace(/^..\/static\/js\//, ''); + embeds[filename] = compressJS([isolateJS(data, shortFilename)]); } else { @@ -297,14 +298,14 @@ function tarCode(filesInOrder, files, write) { for(var i = 0, ii = filesInOrder.length; i < filesInOrder.length; i++) { var filename = filesInOrder[i]; write("\n\n\n/*** File: static/js/" + filename + " ***/\n\n\n"); - write(isolateJS(files[filename])); + write(isolateJS(files[filename], 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. // exports is global and require is a function that returns global. -function isolateJS(code) { +function isolateJS(code, filename) { return '(function (exports, require) {' + code + '\n' + '}(function () {return this}(), (function (path) {return (function () {return this}())})));\n';