-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jQuery source has been migrated in gh-4541 from AMD to ES modules. To maintain support for consumers of our AMD modules, this commits adds a task transpiling the ES modules sources in `src/` to AMD in `amd/`. A "Load with AMD" checkbox was also restored to the QUnit setup. Note that, contrary to jQuery 3.x, AMD files need to be generated via `grunt amd` or `grunt` as sources are not authored in ECMAScript modules. To achieve a similar no-compile experience during jQuery 4.x testing, use the new "Load as modules" checkbox which works in all supported browsers except for IE & Edge (the legacy, EdgeHTML-based one). Ref gh-4541 Closes gh-4554
- Loading branch information
Showing
10 changed files
with
91 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
external | ||
amd | ||
node_modules | ||
*.min.js | ||
dist/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* 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" | ||
}; | ||
|
||
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 ); | ||
} | ||
} ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters