mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
55cd3a4436
This commit cleans up a few comments & configurations that are out of date after the migration to ES modules backed by a Rollup-based compilation. Also, de-indent AMD modules. This will preserve a more similar structure to the one on 3.x-stable where the body of the main `define` wrapper is not indented. Closes gh-4705
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
/**
|
|
* Compiles sources from ES Modules in `src/` to AMD in `amd/`.
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
module.exports = function( grunt ) {
|
|
const path = require( "path" );
|
|
const rimraf = require( "rimraf" );
|
|
const rollup = require( "rollup" );
|
|
const srcFolder = path.resolve( __dirname, "..", "..", "src" );
|
|
const amdFolder = path.resolve( srcFolder, "..", "amd" );
|
|
const inputFileName = "jquery.js";
|
|
|
|
const inputRollupOptions = {
|
|
input: path.resolve( srcFolder, inputFileName ),
|
|
preserveModules: true
|
|
};
|
|
|
|
const outputRollupOptions = {
|
|
format: "amd",
|
|
dir: "amd",
|
|
indent: false
|
|
};
|
|
|
|
grunt.registerTask(
|
|
"amd",
|
|
"Convert ES modules from `src/` to AMD modules in `amd/`",
|
|
async function() {
|
|
const done = this.async();
|
|
|
|
try {
|
|
grunt.verbose.writeln( "Removing the 'amd' directory..." );
|
|
rimraf( amdFolder, async function() {
|
|
const bundle = await rollup.rollup( inputRollupOptions );
|
|
await bundle.write( outputRollupOptions );
|
|
grunt.log.ok( "Sources from 'src' converted to AMD in 'amd'." );
|
|
done();
|
|
} );
|
|
} catch ( err ) {
|
|
done( err );
|
|
}
|
|
} );
|
|
};
|