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

Commit812b4a1

Browse files
authored
Build: Reduce the slim build header comment & jQuery.fn.jquery
So far, the slim build was expanded to its full exclusion list, generating thefollowing `jQuery.fn.jquery`:```v4.0.0-pre -ajax,-ajax/jsonp,-ajax/load,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-deprecated/ajax-event-alias,-callbacks,-deferred,-deferred/exceptionHook,-effects,-effects/Tween,-effects/animatedSelector,-queue,-queue/delay,-core/ready```This commit changes it to just `v4.0.0-pre slim`. Only the pure slim build istreated this way, any modification to it goes through the old expansion; e.g.for `custom:slim,-deprecated` we get the following `jQuery.fn.jquery`:```v4.0.0-pre -deprecated,-deprecated/ajax-event-alias,-deprecated/event,-ajax,-ajax/jsonp,-ajax/load,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-callbacks,-deferred,-deferred/exceptionHook,-effects,-effects/Tween,-effects/animatedSelector,-queue,-queue/delay,-core/ready```Since the version string is also put in the jQuery header comment, it also gotsmaller.Also, the logic to skip including the commit hash in the header comment - whenprovided through the COMMIT environment variable which we do in Jenkins - inminified builds headers has been applied to builds with exclusions as well.Closesgh-4649
1 parent9b73204 commit812b4a1

File tree

1 file changed

+36
-21
lines changed

1 file changed

+36
-21
lines changed

‎build/tasks/build.js

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module.exports = function( grunt ) {
6060
constdone=this.async();
6161

6262
try{
63-
letflag,index;
63+
constslimFlags=["-ajax","-callbacks","-deferred","-effects"];
6464
constflags=this.flags;
6565
constoptIn=flags["*"];
6666
letname=grunt.option("filename");
@@ -70,6 +70,21 @@ module.exports = function( grunt ) {
7070
constincluded=[];
7171
letversion=grunt.config("pkg.version");
7272

73+
// We'll skip printing the whole big exclusions for a bare `build:*:*:slim` which
74+
// usually comes from `custom:slim`.
75+
constisPureSlim=!!(flags.slim&&flags["*"]&&
76+
Object.keys(flags).length===2);
77+
78+
deleteflags["*"];
79+
80+
if(flags.slim){
81+
deleteflags.slim;
82+
for(constflagofslimFlags){
83+
flags[flag]=true;
84+
}
85+
}
86+
87+
7388
/**
7489
* Recursively calls the excluder to remove on all modules in the list
7590
*@param {Array} list
@@ -187,8 +202,7 @@ module.exports = function( grunt ) {
187202
// trumped by explicit exclude of dependency)
188203
// *:+effects none except effects and its dependencies
189204
// (explicit include trumps implicit exclude of dependency)
190-
deleteflags["*"];
191-
for(flaginflags){
205+
for(constflaginflags){
192206
excluder(flag);
193207
}
194208

@@ -198,7 +212,8 @@ module.exports = function( grunt ) {
198212
read(inputFileName).replace(/\n*exportdefaultjQuery;\n*/,"\n"));
199213

200214
// Replace exports/global with a noop noConflict
201-
if((index=excluded.indexOf("exports/global"))>-1){
215+
if(excluded.includes("exports/global")){
216+
constindex=excluded.indexOf("exports/global");
202217
setOverride(`${srcFolder}/exports/global.js`,
203218
"import jQuery from \"../core.js\";\n\n"+
204219
"jQuery.noConflict = function() {};");
@@ -224,13 +239,24 @@ module.exports = function( grunt ) {
224239
grunt.verbose.writeflags(excluded,"Excluded");
225240
grunt.verbose.writeflags(included,"Included");
226241

227-
// append excluded modules to version
228-
if(excluded.length){
242+
// Indicate a Slim build without listing all of the exclusions
243+
// to save space.
244+
if(isPureSlim){
245+
version+=" slim";
246+
247+
// Append excluded modules to version.
248+
}elseif(excluded.length){
229249
version+=" -"+excluded.join(",-");
250+
}
251+
252+
if(excluded.length){
230253

231-
// set pkg.version to version with excludes, so minified file picks it up
232-
grunt.config.set("pkg.version",version);
233-
grunt.verbose.writeln("Version changed to "+version);
254+
// Set pkg.version to version with excludes or with the "slim" marker,
255+
// so minified file picks it up but skip the commit hash the same way
256+
// it's done for the full build.
257+
constcommitlessVersion=version.replace(" "+process.env.COMMIT,"");
258+
grunt.config.set("pkg.version",commitlessVersion);
259+
grunt.verbose.writeln("Version changed to "+commitlessVersion);
234260

235261
// Replace excluded modules with empty sources.
236262
for(constmoduleofexcluded){
@@ -299,18 +325,7 @@ module.exports = function( grunt ) {
299325
grunt.registerTask("custom",function(){
300326
constargs=this.args;
301327
constmodules=args.length ?
302-
args[0]
303-
.split(",")
304-
305-
// Replace "slim" with respective exclusions meant for
306-
// the official slim build
307-
.reduce((acc,elem)=>acc.concat(
308-
elem==="slim" ?
309-
["-ajax","-callbacks","-deferred","-effects"] :
310-
[elem]
311-
),[])
312-
313-
.join(":") :
328+
args[0].split(",").join(":") :
314329
"";
315330
constdone=this.async();
316331
constinsight=newInsight({

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp