]> source.dussan.org Git - jquery.git/commitdiff
Build: Drop individual AMD modules
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Tue, 27 Jun 2023 16:23:58 +0000 (18:23 +0200)
committerGitHub <noreply@github.com>
Tue, 27 Jun 2023 16:23:58 +0000 (18:23 +0200)
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

13 files changed:
.eslintignore
.github/workflows/node.js.yml
.gitignore
Gruntfile.js
build/release.js
build/release/dist.js
build/tasks/amd.js [deleted file]
package.json
test/data/testinit.js
test/index.html
test/jquery.js
test/karma.context.html
test/karma.debug.html

index e1d456ddfdb5a6620fdd3c8fed65fe71a73c7e74..2d52f5cda93bc2ac1da0fe701583209a5d656aae 100644 (file)
@@ -1,4 +1,3 @@
-amd
 external
 node_modules
 *.min.js
index 92497822d73d4fb66f906bd13218545cde5db292..da773cf176fdf0edbd3eb86230fbc752ff8568a1 100644 (file)
@@ -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"
index 9cc148904e624582c0c67908c05f1b06336fc881..6cb83bb6e2fa901a1fe3c3eea1e3c691868d6a69 100644 (file)
@@ -16,7 +16,6 @@ npm-debug.log*
 /dist/*
 !/dist/.eslintrc.json
 
-/amd
 /external
 /node_modules
 
index 9029be85dca483bdbf696041779751a2cfa1f81d..65aec9648a0df07deaab22b377a16baeadacd509 100644 (file)
@@ -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:*",
index e7399c968aea277188be84b80091505fe423faa3..379f7de0a2a0478558d7bb2e4007681a8f5afce0 100644 (file)
@@ -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` );
                },
 
                /**
index ea7c64b8ab64b235826db97d5fc9dfb67b989a1b..eb8adc7e7b47ee5a6584dd232ecb0e1d101d1d8b 100644 (file)
@@ -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 (file)
index c4c9c89..0000000
+++ /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 );
-                       }
-               } );
-};
index 56eaa6822742a66eb1f246d002d4c81d3be95050..dd92954d323e9e4d262e9346a2b2d69e79a229fe 100644 (file)
     "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": {
index 906686d86ca294fc3f14d58d7dabe38809b86714..8d85a0edc9d330fec4033b8a610ac86cfba0ca2d 100644 (file)
@@ -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( "<script src='" + parentUrl + "test/unit/ready.js'><\x2Fscript>" );
        } else {
                QUnit.module( "ready", function() {
index b3c64aedee2ac51e314a0d4a267f88f265311128..f2c468a0795d84444097be5e6a7f2a95d352a1d8 100644 (file)
@@ -19,9 +19,9 @@
        <!-- 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>
index 3292852510b896163006f6755a0bc3bdaf93195e..4146aec130b1732e3559a0f7754957b19128c9ed 100644 (file)
                        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>" );
index 222e2ff190587ff0b1d8c62f7ba0cd2f51a4ccdf..a8977b7659342e47aedf038bc8199f198616fd1e 100644 (file)
        <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>
index 8a95a3f519a6c0fa3fb222516d164f5cf442e1a5..93351adef0ac36618f56eaf894ee79618b52c3d4 100644 (file)
        <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>