From: Michał Gołębiowski-Owczarek Date: Tue, 27 Jun 2023 16:23:58 +0000 (+0200) Subject: Build: Drop individual AMD modules X-Git-Tag: 4.0.0-beta~45 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5701957b7223659c52a43f8c2c5465fdf2803df4;p=jquery.git Build: Drop individual AMD modules With this change, jQuery build no longer generates the `amd` directory with AMD modules transpiled from source `src` ECMAScript Modules. To use individual jQuery modules from source, ESM is now required. Note that this DOES NOT affect the main `"jquery"` AMD module defined by built jQuery files; those remain supported. Closes gh-5276 --- diff --git a/.eslintignore b/.eslintignore index e1d456ddf..2d52f5cda 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,3 @@ -amd external node_modules *.min.js diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 92497822d..da773cf17 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -36,10 +36,6 @@ jobs: 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" diff --git a/.gitignore b/.gitignore index 9cc148904..6cb83bb6e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,6 @@ npm-debug.log* /dist/* !/dist/.eslintrc.json -/amd /external /node_modules diff --git a/Gruntfile.js b/Gruntfile.js index 9029be85d..65aec9648 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -225,12 +225,6 @@ module.exports = function( grunt ) { 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)", @@ -268,21 +262,6 @@ module.exports = function( grunt ) { } } }, - 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: { @@ -431,7 +410,6 @@ module.exports = function( grunt ) { grunt.registerTask( "default", [ runIfNewNode( "eslint:dev" ), "build:*:*", - "amd", "terser", "remove_map_comment", "dist:*", diff --git a/build/release.js b/build/release.js index e7399c968..379f7de0a 100644 --- a/build/release.js +++ b/build/release.js @@ -32,12 +32,10 @@ module.exports = function( Release ) { 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` ); }, /** diff --git a/build/release/dist.js b/build/release/dist.js index ea7c64b8a..eb8adc7e7 100644 --- a/build/release/dist.js +++ b/build/release/dist.js @@ -13,7 +13,6 @@ module.exports = function( Release, files, complete ) { // These files are included with the distribution const extras = [ - "amd", "src", "LICENSE.txt", "AUTHORS.txt", diff --git a/build/tasks/amd.js b/build/tasks/amd.js deleted file mode 100644 index c4c9c8941..000000000 --- a/build/tasks/amd.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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 ); - } - } ); -}; diff --git a/package.json b/package.json index 56eaa6822..dd92954d3 100644 --- a/package.json +++ b/package.json @@ -76,11 +76,10 @@ "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": { diff --git a/test/data/testinit.js b/test/data/testinit.js index 906686d86..8d85a0edc 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -366,11 +366,10 @@ this.loadTests = function() { // 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( " - + - + @@ -31,13 +31,12 @@ // 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(); } diff --git a/test/jquery.js b/test/jquery.js index 329285251..4146aec13 100644 --- a/test/jquery.js +++ b/test/jquery.js @@ -37,10 +37,6 @@ 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", @@ -77,20 +73,6 @@ 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( " diff --git a/test/karma.debug.html b/test/karma.debug.html index 8a95a3f51..93351adef 100644 --- a/test/karma.debug.html +++ b/test/karma.debug.html @@ -32,13 +32,12 @@