Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions build/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function read( filename ) {
// and ensure unix-style path separators
function moduleName( filename ) {
return filename
.replace( `${srcFolder}${path.sep}`, "" )
.replace( `${ srcFolder }${ path.sep }`, "" )
.replace( /\.js$/, "" )
.split( path.sep )
.join( path.posix.sep );
Expand Down Expand Up @@ -112,7 +112,7 @@ async function checkExclude( exclude, include ) {

for ( const module of exclude ) {
if ( minimum.indexOf( module ) !== -1 ) {
throw new Error( `Module \"${module}\" is a minimum requirement.` );
throw new Error( `Module \"${ module }\" is a minimum requirement.` );
}

// Exclude all files in the dir of the same name
Expand Down Expand Up @@ -152,7 +152,7 @@ async function writeCompiled( { code, dir, filename, version } ) {
.replace( /@DATE/g, new Date().toISOString().replace( /:\d+\.\d+Z$/, "Z" ) );

await fs.promises.writeFile( path.join( dir, filename ), compiledContents );
console.log( `[${getTimestamp()}] ${filename} v${version} created.` );
console.log( `[${ getTimestamp() }] ${ filename } v${ version } created.` );
}

// Build jQuery ECMAScript modules
Expand Down Expand Up @@ -187,7 +187,9 @@ async function build( {

// "+[slim.]SHA" is semantically correct
// Add ".dirty" as well if the working dir is not clean
version = `${pkg.version}+${slim ? "slim." : ""}${stdout.trim()}${isClean ? "" : ".dirty"}`;
version = `${ pkg.version }+${ slim ? "slim." : "" }${ stdout.trim() }${
isClean ? "" : ".dirty"
}`;
} else if ( slim ) {
version += "+slim";
}
Expand All @@ -204,7 +206,7 @@ async function build( {
if ( excluded.includes( "exports/global" ) ) {
const index = excluded.indexOf( "exports/global" );
setOverride(
`${srcFolder}/exports/global.js`,
`${ srcFolder }/exports/global.js`,
"import { jQuery } from \"../core.js\";\n\n" +
"jQuery.noConflict = function() {};"
);
Expand All @@ -223,12 +225,12 @@ async function build( {
// No name means an anonymous define
const amdExportContents = await read( "exports/amd.js" );
setOverride(
`${srcFolder}/exports/amd.js`,
`${ srcFolder }/exports/amd.js`,
amdExportContents.replace(

// Remove the comma for anonymous defines
/(\s*)"jquery"(,\s*)/,
amd ? `$1\"${amd}\"$2` : " "
amd ? `$1\"${ amd }\"$2` : " "
)
);
}
Expand All @@ -246,11 +248,11 @@ async function build( {
}

const inputOptions = {
input: `${srcFolder}/jquery.js`
input: `${ srcFolder }/jquery.js`
};

const includedImports = included
.map( ( module ) => `import "./${module}.js";` )
.map( ( module ) => `import "./${ module }.js";` )
.join( "\n" );

const jQueryFileContents = await read( "jquery.js" );
Expand All @@ -272,7 +274,7 @@ async function build( {
// Replace excluded modules with empty sources.
for ( const module of excluded ) {
setOverride(
`${srcFolder}/${module}.js`,
`${ srcFolder }/${ module }.js`,

// The `selector` module is not removed, but replaced
// with `selector-native`.
Expand All @@ -288,7 +290,7 @@ async function build( {
output: [ outputOptions ],
plugins: [ rollupFileOverrides( fileOverrides ) ],
watch: {
include: `${srcFolder}/**`,
include: `${ srcFolder }/**`,
skipWrite: true
}
} );
Expand Down
14 changes: 7 additions & 7 deletions build/tasks/compare_size.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function getCommitHash() {
function getBranchHeader( branch, commit ) {
let branchHeader = branch.trim();
if ( commit ) {
branchHeader = chalk.bold( branchHeader ) + chalk.gray( ` @${commit}` );
branchHeader = chalk.bold( branchHeader ) + chalk.gray( ` @${ commit }` );
} else {
branchHeader = chalk.italic( branchHeader );
}
Expand Down Expand Up @@ -65,13 +65,13 @@ function saveCache( loc, cache ) {

function compareSizes( existing, current, padLength ) {
if ( typeof current !== "number" ) {
return chalk.grey( `${existing}`.padStart( padLength ) );
return chalk.grey( `${ existing }`.padStart( padLength ) );
}
const delta = current - existing;
if ( delta > 0 ) {
return chalk.red( `+${delta}`.padStart( padLength ) );
return chalk.red( `+${ delta }`.padStart( padLength ) );
}
return chalk.green( `${delta}`.padStart( padLength ) );
return chalk.green( `${ delta }`.padStart( padLength ) );
}

function sortBranches( a, b ) {
Expand Down Expand Up @@ -130,7 +130,7 @@ export async function compareSize( { cache = ".sizecache.json", files } = {} ) {
const sizes = results.map( function( result ) {
const rawSize = result.raw.toString().padStart( rawPadLength );
const gzSize = result.gz.toString().padStart( gzPadLength );
return `${rawSize} ${gzSize} ${result.filename}`;
return `${ rawSize } ${ gzSize } ${ result.filename }`;
} );

const comparisons = Object.keys( sizeCache ).sort( sortBranches ).map( function( branch ) {
Expand All @@ -146,7 +146,7 @@ export async function compareSize( { cache = ".sizecache.json", files } = {} ) {

const compareRaw = compareSizes( branchResult.raw, compareResult.raw, rawPadLength );
const compareGz = compareSizes( branchResult.gz, compareResult.gz, gzPadLength );
return `${compareRaw} ${compareGz} ${filename}`;
return `${ compareRaw } ${ compareGz } ${ filename }`;
} );

return [
Expand Down Expand Up @@ -182,7 +182,7 @@ export async function compareSize( { cache = ".sizecache.json", files } = {} ) {
meta: { commit },
files: cacheResults( results )
};
console.log( `Saved cache for ${branch}.` );
console.log( `Saved cache for ${ branch }.` );
}

await saveCache( cache, sizeCache );
Expand Down
2 changes: 1 addition & 1 deletion build/tasks/lib/getTimestamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ module.exports = function getTimestamp() {
const hours = now.getHours().toString().padStart( 2, "0" );
const minutes = now.getMinutes().toString().padStart( 2, "0" );
const seconds = now.getSeconds().toString().padStart( 2, "0" );
return `${hours}:${minutes}:${seconds}`;
return `${ hours }:${ minutes }:${ seconds }`;
};
6 changes: 4 additions & 2 deletions build/tasks/minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = async function minify( { filename, dir, esm } ) {
ecma: esm ? 2015 : 5,
asciiOnly: true,
comments: false,
preamble: `/*! jQuery ${version}` +
preamble: `/*! jQuery ${ version }` +
" | (c) OpenJS Foundation and other contributors" +
" | jquery.org/license */\n"
},
Expand Down Expand Up @@ -63,5 +63,7 @@ module.exports = async function minify( { filename, dir, esm } ) {
processForDist( code, minFilename );
processForDist( map, mapFilename );

console.log( `[${getTimestamp()}] ${minFilename} ${version} with ${mapFilename} created.` );
console.log( `[${ getTimestamp() }] ${ minFilename } ${ version } with ${
mapFilename
} created.` );
};
2 changes: 1 addition & 1 deletion build/tasks/npmcopy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function npmcopy() {
const toDir = path.dirname( to );
await fs.promises.mkdir( toDir, { recursive: true } );
await fs.promises.copyFile( from, to );
console.log( `${source} → ${dest}` );
console.log( `${ source } → ${ dest }` );
}
}

Expand Down
2 changes: 1 addition & 1 deletion build/tasks/promises_aplus_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if ( !verifyNodeVersion() ) {

const command = path.resolve(
__dirname,
`../../node_modules/.bin/promises-aplus-tests${os.platform() === "win32" ? ".cmd" : ""}`
`../../node_modules/.bin/promises-aplus-tests${ os.platform() === "win32" ? ".cmd" : "" }`
);
const args = [ "--reporter", "dot", "--timeout", "2000" ];
const tests = [
Expand Down
Loading