-amd
external
node_modules
*.min.js
NODE_VERSION: "18.x"
NPM_SCRIPT: "test:esmodules"
BROWSERS: "ChromeHeadless"
- - NAME: "Browser tests: AMD build, Chrome"
- NODE_VERSION: "18.x"
- NPM_SCRIPT: "test:amd"
- BROWSERS: "ChromeHeadless"
- NAME: "Browser tests: full build, Firefox ESR"
NODE_VERSION: "18.x"
NPM_SCRIPT: "test:browser"
/dist/*
!/dist/.eslintrc.json
-/amd
/external
/node_modules
served: true,
nocache: true
},
- {
- pattern: "amd/**",
- included: false,
- served: true,
- nocache: true
- },
{ pattern: "external/**", included: false, served: true },
{
pattern: "test/**/*.@(js|css|jpg|html|xml|svg)",
}
}
},
- amd: {
- browsers: customBrowsers || [ "ChromeHeadless" ],
- options: {
- client: {
- qunit: {
-
- // We're running `QUnit.start()` ourselves via `loadTests()`
- // in test/jquery.js
- autostart: false,
-
- amd: true
- }
- }
- }
- },
jsdom: {
options: {
grunt.registerTask( "default", [
runIfNewNode( "eslint:dev" ),
"build:*:*",
- "amd",
"terser",
"remove_map_comment",
"dist:*",
issueTracker: "github",
/**
- * Set the version in the src folder for distributing ES modules
- * and in the amd folder for AMD.
+ * Set the version in the src folder for distributing ES modules.
*/
_setSrcVersion: function() {
setSrcVersion( `${ __dirname }/../src/core.js` );
- setSrcVersion( `${ __dirname }/../amd/core.js` );
},
/**
// These files are included with the distribution
const extras = [
- "amd",
"src",
"LICENSE.txt",
"AUTHORS.txt",
+++ /dev/null
-/**
- * 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 );
- }
- } );
-};
"test:browserless": "grunt && grunt test:slow",
"test:browser": "grunt && grunt karma:main",
"test:esmodules": "grunt && grunt karma:esmodules",
- "test:amd": "grunt && grunt karma:amd",
"test:no-deprecated": "grunt test:prepare && grunt custom:-deprecated && grunt karma:main",
"test:selector-native": "grunt test:prepare && grunt custom:-selector && grunt karma:main",
"test:slim": "grunt test:prepare && grunt custom:slim && grunt karma:main",
- "test": "npm run test:slim && npm run test:no-deprecated && npm run test:selector-native && grunt && grunt test:slow && grunt karma:main && grunt karma:esmodules && grunt karma:amd",
+ "test": "npm run test:slim && npm run test:no-deprecated && npm run test:selector-native && grunt && grunt test:slow && grunt karma:main && grunt karma:esmodules",
"jenkins": "npm run test:browserless"
},
"commitplease": {
// QUnit.config is populated from QUnit.urlParams but only at the beginning
// of the test run. We need to read both.
- var esmodules = QUnit.config.esmodules || QUnit.urlParams.esmodules,
- amd = QUnit.config.amd || QUnit.urlParams.amd;
+ var esmodules = QUnit.config.esmodules || QUnit.urlParams.esmodules;
// Directly load tests that need evaluation before DOMContentLoaded.
- if ( ( !esmodules && !amd ) || document.readyState === "loading" ) {
+ if ( !esmodules || document.readyState === "loading" ) {
document.write( "<script src='" + parentUrl + "test/unit/ready.js'><\x2Fscript>" );
} else {
QUnit.module( "ready", function() {
<!-- See testinit for the list of tests -->
<script src="data/testinit.js"></script>
- <!-- A script that includes jQuery min, dev, ES modules or AMD modules -->
+ <!-- A script that includes jQuery min, dev or ES modules -->
<!-- Adds "basic" URL option, even to iframes -->
- <!-- iframes will not load AMD as loading needs to be synchronous for some tests -->
+ <!-- iframes will not load ESM as loading needs to be synchronous for some tests -->
<!-- Also executes the function above to load tests -->
<script src="jquery.js"></script>
// jQuery is on the page when the testrunner executes
// QUnit.config is populated from QUnit.urlParams but only at the beginning
// of the test run. We need to read both.
- var esmodules = QUnit.config.esmodules || QUnit.urlParams.esmodules,
- amd = QUnit.config.amd || QUnit.urlParams.amd;
+ var esmodules = QUnit.config.esmodules || QUnit.urlParams.esmodules;
// Workaround: Remove call to `window.__karma__.loaded()`
// in favor of calling `window.__karma__.start()` from `loadTests()`
// because tests such as unit/ready.js should run after document ready.
- if ( !esmodules && !amd ) {
+ if ( !esmodules ) {
loadTests();
}
</script>
id: "esmodules",
label: "Load as modules",
tooltip: "Load the jQuery module file (and its dependencies)"
- }, {
- id: "amd",
- label: "Load with AMD",
- tooltip: "Load the AMD jQuery file (and its dependencies)"
}, {
id: "dev",
label: "Load unminified",
eval( dynamicImportSource );
- // Apply similar treatment for AMD modules
- } else if ( config.amd && QUnit ) {
- require.config( {
- baseUrl: parentUrl
- } );
- src = "amd/jquery";
-
- // Include tests if specified
- if ( typeof loadTests !== "undefined" ) {
- require( [ src ], loadTests );
- } else {
- require( [ src ] );
- }
-
// Otherwise, load synchronously
} else {
document.write( "<script id='jquery-js' nonce='jquery+hardcoded+nonce' src='" + parentUrl + src + "'><\x2Fscript>" );
<script>
// QUnit.config is populated from QUnit.urlParams but only at the beginning
// of the test run. We need to read both.
- var esmodules = QUnit.config.esmodules || QUnit.urlParams.esmodules,
- amd = QUnit.config.amd || QUnit.urlParams.amd;
+ var esmodules = QUnit.config.esmodules || QUnit.urlParams.esmodules;
// Workaround: Remove call to `window.__karma__.loaded()`
// in favor of calling `window.__karma__.start()` from `loadTests()`
// because tests such as unit/ready.js should run after document ready.
- if ( !esmodules && !amd ) {
+ if ( !esmodules ) {
loadTests();
}
</script>
<script>
// QUnit.config is populated from QUnit.urlParams but only at the beginning
// of the test run. We need to read both.
- var esmodules = QUnit.config.esmodules || QUnit.urlParams.esmodules,
- amd = QUnit.config.amd || QUnit.urlParams.amd;
+ var esmodules = QUnit.config.esmodules || QUnit.urlParams.esmodules;
// Workaround: Remove call to `window.__karma__.loaded()`
// in favor of calling `window.__karma__.start()` from `loadTests()`
// because tests such as unit/ready.js should run after document ready.
- if ( !esmodules && !amd ) {
+ if ( !esmodules ) {
loadTests();
}
</script>