<commit_before>/**
 * Special build task to handle various jQuery build requirements.
 * Compiles JS modules into one bundle, sets the custom AMD name,
 * and includes/excludes specified modules
 */

"use strict";

module.exports = function( grunt ) {
	const fs = require( "fs" );
	const path = require( "path" );
	const rollup = require( "rollup" );
	const rollupFileOverrides = require( "./lib/rollup-plugin-file-overrides" );
	const Insight = require( "insight" );
	const pkg = require( "../../package.json" );
	const srcFolder = path.resolve( `${ __dirname }/../../src` );
	const read = function( fileName ) {
		return grunt.file.read( `${ srcFolder }/${ fileName }` );
	};

	// Catch `// @CODE` and subsequent comment lines event if they don't start
	// in the first column.
	const wrapper = read( "wrapper.js" )
		.split( /[\x20\t]*\/\/ @CODE\n(?:[\x20\t]*\/\/[^\n]+\n)*/ );

	const inputFileName = "jquery.js";
	const inputRollupOptions = {
		input: `${ srcFolder }/${ inputFileName }`
	};
	const outputRollupOptions = {

		// The ESM format is not actually used as we strip it during
		// the build; it's just that it doesn't generate any extra
		// wrappers so there's nothing for us to remove.
		format: "esm",

		intro: wrapper[ 0 ]
			.replace( /\n*$/, "" ),
		outro: wrapper[ 1 ]
			.replace( /^\n*/, "" )
	};
	const fileOverrides = new Map();

	function getOverride( filePath ) {
		return fileOverrides.get( path.resolve( filePath ) );
	}

	function setOverride( filePath, source ) {

		// We want normalized paths in overrides as they will be matched
		// against normalized paths in the file overrides Rollup plugin.
		fileOverrides.set( path.resolve( filePath ), source );
	}

	grunt.registerMultiTask(
		"build",
		"Build jQuery ECMAScript modules, " +
			"(include/exclude modules with +/- flags), embed date/version",
	async function() {
		const done = this.async();

		try {
			const slimFlags = [ "-ajax", "-callbacks", "-deferred", "-effects" ];
			const flags = this.flags;
			const optIn = flags[ "*" ];
			let name = grunt.option( "filename" );
			const minimum = this.data.minimum;
			const removeWith = this.data.removeWith;
			const excluded = [];
			const included = [];
			let version = grunt.config( "pkg.version" );

			// We'll skip printing the whole big exclusions for a bare `build:*:*:slim` which
			// usually comes from `custom:slim`.
			const isPureSlim = !!( flags.slim && flags[ "*" ] &&
				Object.keys( flags ).length === 2 );

			delete flags[ "*" ];

			if ( flags.slim ) {
				delete flags.slim;
				for ( const flag of slimFlags ) {
					flags[ flag ] = true;
				}
			}


			/**<commit_msg>Build: Explicitly exclude the queue module from the slim build<commit_after>/**
 * Special build task to handle various jQuery build requirements.
 * Compiles JS modules into one bundle, sets the custom AMD name,
 * and includes/excludes specified modules
 */

"use strict";

module.exports = function( grunt ) {
	const fs = require( "fs" );
	const path = require( "path" );
	const rollup = require( "rollup" );
	const rollupFileOverrides = require( "./lib/rollup-plugin-file-overrides" );
	const Insight = require( "insight" );
	const pkg = require( "../../package.json" );
	const srcFolder = path.resolve( `${ __dirname }/../../src` );
	const read = function( fileName ) {
		return grunt.file.read( `${ srcFolder }/${ fileName }` );
	};

	// Catch `// @CODE` and subsequent comment lines event if they don't start
	// in the first column.
	const wrapper = read( "wrapper.js" )
		.split( /[\x20\t]*\/\/ @CODE\n(?:[\x20\t]*\/\/[^\n]+\n)*/ );

	const inputFileName = "jquery.js";
	const inputRollupOptions = {
		input: `${ srcFolder }/${ inputFileName }`
	};
	const outputRollupOptions = {

		// The ESM format is not actually used as we strip it during
		// the build; it's just that it doesn't generate any extra
		// wrappers so there's nothing for us to remove.
		format: "esm",

		intro: wrapper[ 0 ]
			.replace( /\n*$/, "" ),
		outro: wrapper[ 1 ]
			.replace( /^\n*/, "" )
	};
	const fileOverrides = new Map();

	function getOverride( filePath ) {
		return fileOverrides.get( path.resolve( filePath ) );
	}

	function setOverride( filePath, source ) {

		// We want normalized paths in overrides as they will be matched
		// against normalized paths in the file overrides Rollup plugin.
		fileOverrides.set( path.resolve( filePath ), source );
	}

	grunt.registerMultiTask(
		"build",
		"Build jQuery ECMAScript modules, " +
			"(include/exclude modules with +/- flags), embed date/version",
	async function() {
		const done = this.async();

		try {
			const slimFlags = [ "-ajax", "-callbacks", "-deferred", "-effects", "-queue" ];
			const flags = this.flags;
			const optIn = flags[ "*" ];
			let name = grunt.option( "filename" );
			const minimum = this.data.minimum;
			const removeWith = this.data.removeWith;
			const excluded = [];
			const included = [];
			let version = grunt.config( "pkg.version" );

			// We'll skip printing the whole big exclusions for a bare `build:*:*:slim` which
			// usually comes from `custom:slim`.
			const isPureSlim = !!( flags.slim && flags[ "*" ] &&
				Object.keys( flags ).length === 2 );

			delete flags[ "*" ];

			if ( flags.slim ) {
				delete flags.slim;
				for ( const flag of slimFlags ) {
					flags[ flag ] = true;
				}
			}


			/**
{'fraction_non_alphanumeric': 0.15639632890054317, 'fraction_numerical': 0.002622213897733658, 'mean_word_length': 3.1013824884792625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6918383', 'n_tokens_mistral': 1868, 'n_tokens_neox': 1683, 'n_words': 542}