Make the IIFE Closure Compiler regexp in post process more restrictive to work better with the "iife" build option.

Former-commit-id: 999602451e50850eb82680b9c377d97605be8af4
This commit is contained in:
John-David Dalton
2012-09-13 01:40:28 -07:00
parent e69bdabc99
commit 13d901bf8d
3 changed files with 64 additions and 45 deletions

View File

@@ -27,7 +27,7 @@
*/
function postprocess(source) {
// move vars exposed by Closure Compiler into the IIFE
source = source.replace(/^([^(\n]+)\s*(\(function[^)]+\){)/, '$2$1');
source = source.replace(/^((?:(['"])use strict\2;)?(?:var (?:[a-z]+=(?:!0|!1|null)[,;])+)?)([\s\S]*?function[^)]+\){)/, '$3$1');
// unescape properties (i.e. foo["bar"] => foo.bar)
source = source.replace(/(\w)\["([^."]+)"\]/g, function(match, left, right) {