function convert( name, path, contents ) {
		var amdName;

		// Convert var modules
		if ( /.\/var\//.test( path.replace( process.cwd(), "" ) ) ) {
			contents = contents
				.replace(
					/define\([\w\W]*?return/,
					"var " +
					( /var\/([\w-]+)/.exec( name )[ 1 ] ) +
					" ="
				)
				.replace( rdefineEnd, "" );

		// Sizzle treatment
		} else if ( /\/sizzle$/.test( name ) ) {
			contents = "var Sizzle =\n" + contents

				// Remove EXPOSE lines from Sizzle
				.replace( /\/\/\s*EXPOSE[\w\W]*\/\/\s*EXPOSE/, "return Sizzle;" );

		} else {

			contents = contents
				.replace( /\s*return\s+[^\}]+(\}\s*?\);[^\w\}]*)$/, "$1" )

				// Multiple exports
				.replace( /\s*exports\.\w+\s*=\s*\w+;/g, "" );

			// Remove define wrappers, closure ends, and empty declarations
			contents = contents
				.replace( /define\([^{]*?{\s*(?:("|')use strict\1(?:;|))?/, "" )
				.replace( rdefineEnd, "" );

			// Remove anything wrapped with
			// /* ExcludeStart */ /* ExcludeEnd */
			// or a single line directly after a // BuildExclude comment
			contents = contents
				.replace( /\/\*\s*ExcludeStart\s*\*\/[\w\W]*?\/\*\s*ExcludeEnd\s*\*\//ig, "" )
				.replace( /\/\/\s*BuildExclude\n\r?[\w\W]*?\n\r?/ig, "" );

			// Remove empty definitions
			contents = contents
				.replace( /define\(\[[^\]]*\]\)[\W\n]+$/, "" );
		}

		// AMD Name
		if ( ( amdName = grunt.option( "amd" ) ) != null && /^exports\/amd$/.test( name ) ) {
			if ( amdName ) {
				grunt.log.writeln( "Naming jQuery with AMD name: " + amdName );
			} else {
				grunt.log.writeln( "AMD name now anonymous" );
			}

			// Remove the comma for anonymous defines
			contents = contents
				.replace( /(\s*)"jquery"(\,\s*)/, amdName ? "$1\"" + amdName + "\"$2" : "" );

		}
		return contents;
	}
function convert( name, path, contents ) {
		var amdName;

		// Convert var modules
		if ( /.\/var\//.test( path.replace( process.cwd(), "" ) ) ) {
			contents = contents
				.replace(
					/define\([\w\W]*?return/,
					"var " +
					( /var\/([\w-]+)/.exec( name )[ 1 ] ) +
					" ="
				)
				.replace( rdefineEnd, "" );

		// Sizzle treatment
		} else if ( /\/sizzle$/.test( name ) ) {
			contents = "var Sizzle =\n" + contents

				// Remove EXPOSE lines from Sizzle
				.replace( /\/\/\s*EXPOSE[\w\W]*\/\/\s*EXPOSE/, "return Sizzle;" );

		} else {

			contents = contents
				.replace( /\s*return\s+[^\}]+(\}\s*?\);[^\w\}]*)$/, "$1" )

				// Multiple exports
				.replace( /\s*exports\.\w+\s*=\s*\w+;/g, "" );

			// Remove define wrappers, closure ends, and empty declarations
			contents = contents
				.replace( /define\([^{]*?{\s*(?:("|')use strict\1(?:;|))?/, "" )
				.replace( rdefineEnd, "" );

			// Remove anything wrapped with
			// /* ExcludeStart */ /* ExcludeEnd */
			// or a single line directly after a // BuildExclude comment
			contents = contents
				.replace( /\/\*\s*ExcludeStart\s*\*\/[\w\W]*?\/\*\s*ExcludeEnd\s*\*\//ig, "" )
				.replace( /\/\/\s*BuildExclude\n\r?[\w\W]*?\n\r?/ig, "" );

			// Remove empty definitions
			contents = contents
				.replace( /define\(\[[^\]]*\]\)[\W\n]+$/, "" );
		}

		// AMD Name
		if ( ( amdName = grunt.option( "amd" ) ) != null && /^exports\/amd$/.test( name ) ) {
			if ( amdName ) {
				grunt.log.writeln( "Naming jQuery with AMD name: " + amdName );
			} else {
				grunt.log.writeln( "AMD name now anonymous" );
			}

			// Remove the comma for anonymous defines
			contents = contents
				.replace( /(\s*)"jquery"(\,\s*)/, amdName ? "$1\"" + amdName + "\"$2" : "" );

		}
		return contents;
	}
function convert ( name , path , contents ) { var amdName ; // Convert var modules if ( / .\/var\/ / . test ( path . replace ( process . cwd ( ) , "" ) ) ) { contents = contents . replace ( / define\([\w\W]*?return / , "var " + ( / var\/([\w-]+) / . exec ( name ) [ 1 ] ) + " =" ) . replace ( rdefineEnd , "" ) ; // Sizzle treatment } else if ( / \/sizzle$ / . test ( name ) ) { contents = "var Sizzle =\n" + contents // Remove EXPOSE lines from Sizzle . replace ( / \/\/\s*EXPOSE[\w\W]*\/\/\s*EXPOSE / , "return Sizzle;" ) ; } else { contents = contents . replace ( / \s*return\s+[^\}]+(\}\s*?\);[^\w\}]*)$ / , "$1" ) // Multiple exports . replace ( / \s*exports\.\w+\s*=\s*\w+; / g , "" ) ; // Remove define wrappers, closure ends, and empty declarations contents = contents . replace ( / define\([^{]*?{\s*(?:("|')use strict\1(?:;|))? / , "" ) . replace ( rdefineEnd , "" ) ; // Remove anything wrapped with // /* ExcludeStart */ /* ExcludeEnd */ // or a single line directly after a // BuildExclude comment contents = contents . replace ( / \/\*\s*ExcludeStart\s*\*\/[\w\W]*?\/\*\s*ExcludeEnd\s*\*\/ / ig , "" ) . replace ( / \/\/\s*BuildExclude\n\r?[\w\W]*?\n\r? / ig , "" ) ; // Remove empty definitions contents = contents . replace ( / define\(\[[^\]]*\]\)[\W\n]+$ / , "" ) ; } // AMD Name if ( ( amdName = grunt . option ( "amd" ) ) != null && / ^exports\/amd$ / . test ( name ) ) { if ( amdName ) { grunt . log . writeln ( "Naming jQuery with AMD name: " + amdName ) ; } else { grunt . log . writeln ( "AMD name now anonymous" ) ; } // Remove the comma for anonymous defines contents = contents . replace ( / (\s*)"jquery"(\,\s*) / , amdName ? "$1\"" + amdName + "\"$2" : "" ) ; } return contents ; }
Strip all definitions generated by requirejs
Convert "var" modules to var declarations
"var module" means the module only contains a return
statement that should be converted to a var declaration
This is indicated by including the file in any "var" folder
@param {String} name
@param {String} path
@param {String} contents The contents to be written (including their AMD wrappers)
Strip all definitions generated by requirejs Convert var modules to var declarations var module means the module only contains a return statement that should be converted to a var declaration This is indicated by including the file in any var folder
Convert a module name to a module name