Skip to content

Commit f71d7f5

Browse files
committed
Release: remove sourcemap comment from all copies of minified file
Fixes gh-1707
1 parent 7352216 commit f71d7f5

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ module.exports = function( grunt ) {
161161
grunt.registerTask( "test", [ "test_fast" ] );
162162

163163
// Short list as a high frequency watch task
164-
grunt.registerTask( "dev", [ "build:*:*", "lint", "uglify", "dist:*" ] );
164+
grunt.registerTask( "dev", [ "build:*:*", "lint", "uglify", "remove_map_comment", "dist:*" ] );
165165

166166
grunt.registerTask( "default", [ "dev", "test_fast", "compare_size" ] );
167167
};

build/release/cdn.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ function makeReleaseCopies( Release ) {
4848
"\"file\":\"" + unpathedFile.replace( /\.min\.map/, ".min.js" ) +
4949
"\",\"sources\":[\"" + unpathedFile.replace( /\.min\.map/, ".js" ) + "\"]" );
5050
fs.writeFileSync( releaseFile, text );
51-
} else if ( /\.min\.js$/.test( releaseFile ) ) {
52-
// Remove the source map comment; it causes way too many problems.
53-
// Keep the map file in case DevTools allow manual association.
54-
text = fs.readFileSync( builtFile, "utf8" )
55-
.replace( /\/\/# sourceMappingURL=\S+/, "" );
56-
fs.writeFileSync( releaseFile, text );
5751
} else if ( builtFile !== releaseFile ) {
5852
shell.cp( "-f", builtFile, releaseFile );
5953
}

build/tasks/sourcemap.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var fs = require( "fs" );
2+
3+
module.exports = function( grunt ) {
4+
var minLoc = Object.keys( grunt.config( "uglify.all.files" ) )[ 0 ];
5+
grunt.registerTask( "remove_map_comment", function() {
6+
// Remove the source map comment; it causes way too many problems.
7+
// The map file is still generated for manual associations
8+
// https://github.com/jquery/jquery/issues/1707
9+
var text = fs.readFileSync( minLoc, "utf8" )
10+
.replace( /\/\/# sourceMappingURL=\S+/, "" );
11+
fs.writeFileSync( minLoc, text );
12+
});
13+
};

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"grunt-cli": "0.1.13",
3636
"grunt-compare-size": "0.4.0",
3737
"grunt-contrib-jshint": "0.10.0",
38-
"grunt-contrib-uglify": "0.6.0",
38+
"grunt-contrib-uglify": "0.7.0",
3939
"grunt-contrib-watch": "0.6.1",
4040
"grunt-git-authors": "2.0.1",
4141
"grunt-jscs-checker": "0.8.1",
@@ -60,7 +60,6 @@
6060
"Tests",
6161
"Build",
6262
"Release",
63-
6463
"Core",
6564
"Ajax",
6665
"Attributes",

0 commit comments

Comments
 (0)