diff --git a/lib/closure-compiler/compiler.jar b/lib/closure-compiler/compiler.jar index 694808c0cac6..d958a61882cf 100644 Binary files a/lib/closure-compiler/compiler.jar and b/lib/closure-compiler/compiler.jar differ diff --git a/lib/grunt/utils.js b/lib/grunt/utils.js index 0ba03da2c69f..037cf5ea1cec 100644 --- a/lib/grunt/utils.js +++ b/lib/grunt/utils.js @@ -89,7 +89,8 @@ module.exports = { .replace(/"NG_VERSION_MINOR"/, NG_VERSION.minor) .replace(/"NG_VERSION_DOT"/, NG_VERSION.dot) .replace(/"NG_VERSION_CDN"/, NG_VERSION.cdn) - .replace(/"NG_VERSION_CODENAME"/, NG_VERSION.codename); + .replace(/"NG_VERSION_CODENAME"/, NG_VERSION.codename) + .replace(/"NG_SOURCE_MAP"/, NG_VERSION.sourcemap); if (strict !== false) processed = this.singleStrict(processed, '\n\n', true); return processed; }, @@ -98,12 +99,20 @@ module.exports = { build: function(config, fn){ var files = grunt.file.expand(config.src); var styles = config.styles; + //sourcemap + var NG_VERSION = grunt.config('NG_VERSION'); + var sourcemapPrefix = '//@ sourceMappingURL='; + var sourceMappingURL = config.dest + .replace('build/', '') + .replace(/\.js$/, '-' + NG_VERSION.full + '.min.js.map'); + + NG_VERSION.sourcemap = sourcemapPrefix + sourceMappingURL; //concat var src = files.map(function(filepath){ return grunt.file.read(filepath); }).join(grunt.util.normalizelf('\n')); //process - var processed = this.process(src, grunt.config('NG_VERSION'), config.strict); + var processed = this.process(src, NG_VERSION, config.strict); if (styles) processed = this.addStyle(processed, styles.css, styles.minify); //write grunt.file.write(config.dest, processed); @@ -121,17 +130,22 @@ module.exports = { min: function(file, done) { + var NG_VERSION = grunt.config('NG_VERSION'); var minFile = file.replace(/\.js$/, '.min.js'); + var mapFile = file.replace(/\.js$/, '-' + NG_VERSION.full + '.min.js.map'); shell.exec( 'java ' + this.java32flags() + ' ' + '-jar lib/closure-compiler/compiler.jar ' + '--compilation_level SIMPLE_OPTIMIZATIONS ' + '--language_in ECMASCRIPT5_STRICT ' + + '--source_map_format=V3 ' + + '--create_source_map ' + mapFile + ' ' + '--js ' + file + ' ' + '--js_output_file ' + minFile, function(code) { if (code !== 0) grunt.fail.warn('Error minifying ' + file); + grunt.file.write(mapFile, grunt.file.read(mapFile).replace('"sources":["build/','"sources":["')); grunt.file.write(minFile, this.singleStrict(grunt.file.read(minFile), '\n')); grunt.log.ok(file + ' minified into ' + minFile); done(); diff --git a/src/angular.prefix b/src/angular.prefix index 7a6ff34416c0..0a9e3e90678f 100644 --- a/src/angular.prefix +++ b/src/angular.prefix @@ -2,5 +2,6 @@ * @license AngularJS v"NG_VERSION_FULL" * (c) 2010-2012 Google, Inc. http://angularjs.org * License: MIT + * "NG_SOURCE_MAP" */ (function(window, document, undefined) { diff --git a/src/loader.prefix b/src/loader.prefix index 3ab7dd06e4fe..d506ab01bbe0 100644 --- a/src/loader.prefix +++ b/src/loader.prefix @@ -2,6 +2,7 @@ * @license AngularJS v"NG_VERSION_FULL" * (c) 2010-2012 Google, Inc. http://angularjs.org * License: MIT + * "NG_SOURCE_MAP" */ 'use strict'; ( diff --git a/src/module.prefix b/src/module.prefix index 791edb90350c..9a6f7be1c3e1 100644 --- a/src/module.prefix +++ b/src/module.prefix @@ -2,5 +2,6 @@ * @license AngularJS v"NG_VERSION_FULL" * (c) 2010-2012 Google, Inc. http://angularjs.org * License: MIT + * "NG_SOURCE_MAP" */ (function(window, angular, undefined) {