aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Minar2012-04-04 23:10:50 -0700
committerIgor Minar2012-04-05 10:22:27 -0700
commit637817e3ba48d149e7a9628533d21e81c650d988 (patch)
treeb2daa436337e8399c97065e2afa0d4728603fd24
parent86182a9415b9209662b16c25c180b958ba7e6cf9 (diff)
downloadangular.js-637817e3ba48d149e7a9628533d21e81c650d988.tar.bz2
fix(Rakefile): move 'use strict'; flag into the angular closure
closure compiler is stubborn and puts the flag to the top of the file, so we have to post-process the minified file to move the flag into the angular closure.
-rw-r--r--Rakefile15
-rw-r--r--src/angular.prefix3
2 files changed, 14 insertions, 4 deletions
diff --git a/Rakefile b/Rakefile
index d1f8f131..ccb82539 100644
--- a/Rakefile
+++ b/Rakefile
@@ -305,11 +305,22 @@ end
def closure_compile(filename)
puts "Compiling #{filename} ..."
+
+ min_path = path_to(filename.gsub(/\.js$/, '.min.js'))
+
%x(java -jar lib/closure-compiler/compiler.jar \
--compilation_level SIMPLE_OPTIMIZATIONS \
--language_in ECMASCRIPT5_STRICT \
--js #{path_to(filename)} \
- --js_output_file #{path_to(filename.gsub(/\.js$/, '.min.js'))})
+ --js_output_file #{min_path})
+
+ File.open(min_path, File::RDWR) do |f|
+ text = f.read
+ f.truncate 0
+ f.rewind
+ f.write text.sub("'use strict';", "").
+ sub(/\(function\([^)]*\)\{/, "\\0'use strict';")
+ end
end
def concat_file(filename, deps, footer='')
@@ -324,7 +335,7 @@ def concat_file(filename, deps, footer='')
gsub('"NG_VERSION_DOT"', NG_VERSION.dot).
gsub('"NG_VERSION_CODENAME"', NG_VERSION.codename).
gsub(/^\s*['"]use strict['"];?\s*$/, ''). # remove all file-specific strict mode flags
- gsub(/'USE STRICT'/, "'use strict'") # rename the placeholder in angular.prefix
+ sub(/\(function\([^)]*\)\s*\{/, "\\0\n'use strict';") # add single strict mode flag
f.write(content)
f.write(footer)
diff --git a/src/angular.prefix b/src/angular.prefix
index 2e8720b3..d66c099f 100644
--- a/src/angular.prefix
+++ b/src/angular.prefix
@@ -3,5 +3,4 @@
* (c) 2010-2012 AngularJS http://angularjs.org
* License: MIT
*/
-'USE STRICT';
-(function(window, document, undefined){
+(function(window, document, undefined) {