Work around a Closure Compiler bug without a pre/post process. [via @phated]

Former-commit-id: 2b9ead74c8c29357a7d8af965b6e0702e77872a5
This commit is contained in:
John-David Dalton
2012-11-08 09:01:47 -08:00
parent a1545c60d6
commit d255f8400f
5 changed files with 58 additions and 67 deletions

View File

@@ -29,13 +29,8 @@
// move vars exposed by the Closure Compiler into the IIFE
source = source.replace(/^((?:(['"])use strict\2;)?(?:var (?:[a-z]+=(?:!0|!1|null)[,;])+)?)([\s\S]*?function[^)]+\){)/, '$3$1');
// avoid bugs with the Closure Compiler
source = source
// correct overly aggressive Closure Compiler minification
.replace(/prototype\s*=\s*{\s*valueOf\s*:\s*1\s*}/, 'prototype={valueOf:1,y:1}')
// restore `arrayRef` and `objectRef` values modified by pre-compile.js
.replace(/= *Array.prototype/, '=[]')
.replace(/= *Object.prototype/, '={}');
// correct overly aggressive Closure Compiler minification
source = source.replace(/prototype\s*=\s*{\s*valueOf\s*:\s*1\s*}/, 'prototype={valueOf:1,y:1}');
// unescape properties (i.e. foo["bar"] => foo.bar)
source = source.replace(/(\w)\["([^."]+)"\]/g, function(match, left, right) {