Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit27303c6

Browse files
authored
Build: Switch the minifier from UglifyJS to Terser
UglifyJS is ES5-only, while Terser supports newer ECMAScript versions. jQueryis authored in ES5 but jQuery 4.x will also have an ESM build that cannot beminified using UglifyJS directly.We could strip the `export` statement, minify via UglifyJS and re-add one butthat increases complexity & may not fully play nice with source maps.On the other hand, switching to Terser increases the minfied size by just 324bytes and the minified gzipped one by just 70 bytes. Such differences largelydisappear among bigger size gains from the `3.x-stable` line - around 2.7 KBminified gzipped as of now.Closesgh-5258
1 parent988a568 commit27303c6

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

‎Gruntfile.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -333,25 +333,26 @@ module.exports = function( grunt ) {
333333
files:["<%= eslint.dev.src %>"],
334334
tasks:["dev"]
335335
},
336-
uglify:{
336+
terser:{
337337
all:{
338338
files:{
339339
"dist/<%= grunt.option('filename').replace('.js', '.min.js') %>":
340340
"dist/<%= grunt.option('filename') %>"
341341
},
342342
options:{
343-
preserveComments:false,
344-
sourceMap:true,
345-
sourceMapName:
346-
"dist/<%= grunt.option('filename').replace('.js', '.min.map') %>",
347-
report:"min",
348-
output:{
349-
"ascii_only":true
343+
ecma:5,
344+
sourceMap:{
345+
filename:"dist/<%= grunt.option('filename').replace('.js', '.min.map') %>"
346+
},
347+
format:{
348+
ascii_only:true,
349+
comments:false,
350+
preamble:"/*! jQuery v<%= pkg.version %> | "+
351+
"(c) OpenJS Foundation and other contributors | "+
352+
"jquery.org/license */"
350353
},
351-
banner:"/*! jQuery v<%= pkg.version %> | "+
352-
"(c) OpenJS Foundation and other contributors | jquery.org/license */",
353354
compress:{
354-
"hoist_funs":false,
355+
hoist_funs:false,
355356
loops:false
356357
}
357358
}
@@ -420,7 +421,7 @@ module.exports = function( grunt ) {
420421
grunt.registerTask("dev",[
421422
"build:*:*",
422423
runIfNewNode("newer:eslint:dev"),
423-
"newer:uglify",
424+
"newer:terser",
424425
"remove_map_comment",
425426
"dist:*",
426427
"qunit_fixture",
@@ -431,7 +432,7 @@ module.exports = function( grunt ) {
431432
runIfNewNode("eslint:dev"),
432433
"build:*:*",
433434
"amd",
434-
"uglify",
435+
"terser",
435436
"remove_map_comment",
436437
"dist:*",
437438
"test:prepare",

‎build/tasks/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,6 @@ module.exports = function( grunt ) {
339339
"";
340340

341341
grunt.log.writeln("Creating custom build...\n");
342-
grunt.task.run(["build:*:*"+(modules ?":"+modules :""),"uglify","dist"]);
342+
grunt.task.run(["build:*:*"+(modules ?":"+modules :""),"terser","dist"]);
343343
});
344344
};

‎build/tasks/sourcemap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
varfs=require("fs");
44

55
module.exports=function(grunt){
6-
varconfig=grunt.config("uglify.all.files");
6+
varconfig=grunt.config("terser.all.files");
77
grunt.registerTask("remove_map_comment",function(){
88
varminLoc=grunt.config.process(Object.keys(config)[0]);
99

‎package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@
3535
"grunt-babel":"8.0.0",
3636
"grunt-cli":"1.4.3",
3737
"grunt-compare-size":"0.4.2",
38-
"grunt-contrib-uglify":"3.4.0",
3938
"grunt-contrib-watch":"1.1.0",
4039
"grunt-eslint":"24.0.0",
4140
"grunt-git-authors":"3.2.0",
4241
"grunt-jsonlint":"2.1.2",
4342
"grunt-karma":"4.0.2",
4443
"grunt-newer":"1.3.0",
4544
"grunt-npmcopy":"0.2.0",
45+
"grunt-terser":"2.0.0",
4646
"gzip-js":"0.3.2",
4747
"husky":"4.2.5",
4848
"jsdom":"19.0.0",
@@ -67,8 +67,8 @@
6767
"rollup":"2.21.0",
6868
"sinon":"7.3.1",
6969
"strip-json-comments":"3.1.1",
70-
"testswarm":"1.1.2",
71-
"uglify-js":"3.4.7"
70+
"terser":"5.17.6",
71+
"testswarm":"1.1.2"
7272
},
7373
"scripts": {
7474
"build":"npm install && grunt",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp