aboutsummaryrefslogtreecommitdiffstats
path: root/Gruntfile.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-05-31 18:59:35 +0200
committerGitHub <noreply@github.com>2023-05-31 18:59:35 +0200
commit27303c6be09b8fc24c13454deae234e480cbf995 (patch)
tree16479591d00d12db7f3e4341c10a35111835ecef /Gruntfile.js
parent988a56847de301ce18a653f84b07c5af432a269f (diff)
downloadjquery-27303c6be09b8fc24c13454deae234e480cbf995.tar.gz
jquery-27303c6be09b8fc24c13454deae234e480cbf995.zip
Build: Switch the minifier from UglifyJS to Terser
UglifyJS is ES5-only, while Terser supports newer ECMAScript versions. jQuery is authored in ES5 but jQuery 4.x will also have an ESM build that cannot be minified using UglifyJS directly. We could strip the `export` statement, minify via UglifyJS and re-add one but that increases complexity & may not fully play nice with source maps. On the other hand, switching to Terser increases the minfied size by just 324 bytes and the minified gzipped one by just 70 bytes. Such differences largely disappear among bigger size gains from the `3.x-stable` line - around 2.7 KB minified gzipped as of now. Closes gh-5258
Diffstat (limited to 'Gruntfile.js')
-rw-r--r--Gruntfile.js27
1 files changed, 14 insertions, 13 deletions
diff --git a/Gruntfile.js b/Gruntfile.js
index c5e238ced..9029be85d 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -333,25 +333,26 @@ module.exports = function( grunt ) {
files: [ "<%= eslint.dev.src %>" ],
tasks: [ "dev" ]
},
- uglify: {
+ terser: {
all: {
files: {
"dist/<%= grunt.option('filename').replace('.js', '.min.js') %>":
"dist/<%= grunt.option('filename') %>"
},
options: {
- preserveComments: false,
- sourceMap: true,
- sourceMapName:
- "dist/<%= grunt.option('filename').replace('.js', '.min.map') %>",
- report: "min",
- output: {
- "ascii_only": true
+ ecma: 5,
+ sourceMap: {
+ filename: "dist/<%= grunt.option('filename').replace('.js', '.min.map') %>"
+ },
+ format: {
+ ascii_only: true,
+ comments: false,
+ preamble: "/*! jQuery v<%= pkg.version %> | " +
+ "(c) OpenJS Foundation and other contributors | " +
+ "jquery.org/license */"
},
- banner: "/*! jQuery v<%= pkg.version %> | " +
- "(c) OpenJS Foundation and other contributors | jquery.org/license */",
compress: {
- "hoist_funs": false,
+ hoist_funs: false,
loops: false
}
}
@@ -420,7 +421,7 @@ module.exports = function( grunt ) {
grunt.registerTask( "dev", [
"build:*:*",
runIfNewNode( "newer:eslint:dev" ),
- "newer:uglify",
+ "newer:terser",
"remove_map_comment",
"dist:*",
"qunit_fixture",
@@ -431,7 +432,7 @@ module.exports = function( grunt ) {
runIfNewNode( "eslint:dev" ),
"build:*:*",
"amd",
- "uglify",
+ "terser",
"remove_map_comment",
"dist:*",
"test:prepare",