mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Remove workarounds for the uglify task mishandling banners when used with source maps. (cherry-picked from d0fadbba9f
)
The issue was fixed in grunt-contrib-uglify: https://github.com/gruntjs/grunt-contrib-uglify/issues/22
This commit is contained in:
parent
ff951314e3
commit
7c38b0686d
39
Gruntfile.js
39
Gruntfile.js
@ -5,7 +5,7 @@ module.exports = function( grunt ) {
|
|||||||
var data = {};
|
var data = {};
|
||||||
try {
|
try {
|
||||||
data = grunt.file.readJSON( filepath );
|
data = grunt.file.readJSON( filepath );
|
||||||
} catch(e) {}
|
} catch ( e ) {}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,8 +17,8 @@ module.exports = function( grunt ) {
|
|||||||
delete srcHintOptions.onevar;
|
delete srcHintOptions.onevar;
|
||||||
|
|
||||||
grunt.initConfig({
|
grunt.initConfig({
|
||||||
pkg: grunt.file.readJSON("package.json"),
|
pkg: grunt.file.readJSON( "package.json" ),
|
||||||
dst: readOptionalJSON("dist/.destination.json"),
|
dst: readOptionalJSON( "dist/.destination.json" ),
|
||||||
compare_size: {
|
compare_size: {
|
||||||
files: [ "dist/jquery.js", "dist/jquery.min.js" ],
|
files: [ "dist/jquery.js", "dist/jquery.min.js" ],
|
||||||
options: {
|
options: {
|
||||||
@ -87,39 +87,28 @@ module.exports = function( grunt ) {
|
|||||||
tasks: "build/tasks/*.js"
|
tasks: "build/tasks/*.js"
|
||||||
},
|
},
|
||||||
testswarm: {
|
testswarm: {
|
||||||
tests: "ajax attributes callbacks core css data deferred dimensions effects event manipulation offset queue selector serialize support traversing Sizzle".split(" ")
|
tests: "ajax attributes callbacks core css data deferred dimensions effects event manipulation offset queue selector serialize support traversing Sizzle".split( " " )
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
files: [ "<%= jshint.grunt.src %>", "<%= jshint.tests.src %>", "src/**/*.js" ],
|
files: [ "<%= jshint.grunt.src %>", "<%= jshint.tests.src %>", "src/**/*.js" ],
|
||||||
tasks: "dev"
|
tasks: "dev"
|
||||||
},
|
},
|
||||||
"pre-uglify": {
|
|
||||||
all: {
|
|
||||||
files: {
|
|
||||||
"dist/jquery.pre-min.js": [ "dist/jquery.js" ]
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
banner: "\n\n\n\n\n\n\n\n\n\n\n\n" + // banner line size must be preserved
|
|
||||||
"/*! jQuery v<%= pkg.version %> | " +
|
|
||||||
"(c) 2005, 2013 jQuery Foundation, Inc. | " +
|
|
||||||
"jquery.org/license */\n"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
uglify: {
|
uglify: {
|
||||||
all: {
|
all: {
|
||||||
files: {
|
files: {
|
||||||
"dist/jquery.min.js": [ "dist/jquery.pre-min.js" ]
|
"dist/jquery.min.js": [ "dist/jquery.js" ]
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
// Keep our hard-coded banner
|
preserveComments: false,
|
||||||
preserveComments: "some",
|
|
||||||
sourceMap: "dist/jquery.min.map",
|
sourceMap: "dist/jquery.min.map",
|
||||||
sourceMappingURL: "jquery.min.map",
|
sourceMappingURL: "jquery.min.map",
|
||||||
report: "min",
|
report: "min",
|
||||||
beautify: {
|
beautify: {
|
||||||
ascii_only: true
|
ascii_only: true
|
||||||
},
|
},
|
||||||
|
banner: "/*! jQuery v<%= pkg.version %> | " +
|
||||||
|
"(c) 2005, 2013 jQuery Foundation, Inc. | " +
|
||||||
|
"jquery.org/license */",
|
||||||
compress: {
|
compress: {
|
||||||
hoist_funs: false,
|
hoist_funs: false,
|
||||||
loops: false,
|
loops: false,
|
||||||
@ -127,14 +116,6 @@ module.exports = function( grunt ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"post-uglify": {
|
|
||||||
all: {
|
|
||||||
src: [ "dist/jquery.min.map" ],
|
|
||||||
options: {
|
|
||||||
tempFiles: [ "dist/jquery.pre-min.js" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -148,5 +129,5 @@ module.exports = function( grunt ) {
|
|||||||
grunt.registerTask( "dev", [ "build:*:*", "jshint", "jscs" ] );
|
grunt.registerTask( "dev", [ "build:*:*", "jshint", "jscs" ] );
|
||||||
|
|
||||||
// Default grunt
|
// Default grunt
|
||||||
grunt.registerTask( "default", [ "jsonlint", "dev", "pre-uglify", "uglify", "post-uglify", "dist:*", "compare_size" ] );
|
grunt.registerTask( "default", [ "jsonlint", "dev", "uglify", "dist:*", "compare_size" ] );
|
||||||
};
|
};
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
module.exports = function( grunt ) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var fs = require( "fs" );
|
|
||||||
|
|
||||||
// Work around grunt-contrib-uglify sourceMap issues (jQuery #13776)
|
|
||||||
grunt.registerMultiTask( "pre-uglify", function() {
|
|
||||||
var banner = this.options().banner;
|
|
||||||
|
|
||||||
this.files.forEach(function( mapping ) {
|
|
||||||
// Join src
|
|
||||||
var input = mapping.src.map(function( file ) {
|
|
||||||
var contents = grunt.file.read( file );
|
|
||||||
|
|
||||||
// Strip banners
|
|
||||||
return contents
|
|
||||||
// Remove the main jQuery banner, it'll be replaced by the new banner anyway.
|
|
||||||
.replace( /^\/\*![\W\w]*?\*\/\n?/g, "" )
|
|
||||||
// Strip other banners preserving line count.
|
|
||||||
.replace( /^\/\*!(?:.|\n)*?\*\/\n?/gm, function( match ) {
|
|
||||||
return match.replace( /[^\n]/gm, "" );
|
|
||||||
});
|
|
||||||
}).join( "\n" );
|
|
||||||
|
|
||||||
// Write temp file (with optional banner)
|
|
||||||
grunt.file.write( mapping.dest, ( banner || "" ) + input );
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Change the map file to point back to jquery.js instead of jquery.pre-min.js.
|
|
||||||
// The problem is caused by the pre-uglify task.
|
|
||||||
grunt.registerMultiTask( "post-uglify", function() {
|
|
||||||
this.files.forEach(function( mapping ) {
|
|
||||||
mapping.src.forEach( function( src ) {
|
|
||||||
// Refer to the source jquery.js, not the temporary jquery.pre-min.js.
|
|
||||||
grunt.file.write( src, grunt.file.read( src ).replace( /\.pre-min\./g, "." ) );
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Remove temporary files.
|
|
||||||
this.options().tempFiles.forEach(function( fileName ) {
|
|
||||||
fs.unlink( fileName );
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
@ -33,7 +33,7 @@
|
|||||||
"grunt": "~0.4.1",
|
"grunt": "~0.4.1",
|
||||||
"grunt-compare-size": "~0.4.0",
|
"grunt-compare-size": "~0.4.0",
|
||||||
"grunt-contrib-jshint": "~0.7.0",
|
"grunt-contrib-jshint": "~0.7.0",
|
||||||
"grunt-contrib-uglify": "~0.2.4",
|
"grunt-contrib-uglify": "~0.2.7",
|
||||||
"grunt-contrib-watch": "~0.5.3",
|
"grunt-contrib-watch": "~0.5.3",
|
||||||
"grunt-git-authors": "~1.2.0",
|
"grunt-git-authors": "~1.2.0",
|
||||||
"grunt-jscs-checker": "~0.2.3",
|
"grunt-jscs-checker": "~0.2.3",
|
||||||
|
Loading…
Reference in New Issue
Block a user