npm run build -- --filename=jquery.module.js --esm
```
+##### Factory mode
+
+By default, jQuery depends on a global `window`. For environments that don't have one, you can generate a factory build that exposes a function accepting `window` as a parameter that you can provide externally (see [`README` of the published package](build/fixtures/README.md) for usage instructions). You can generate such a factory using the `--factory` parameter:
+
+```bash
+npm run build -- --filename=jquery.factory.js --factory
+```
+
+This option can be mixed with others like `--esm` or `--slim`:
+
+```bash
+npm run build -- --filename=jquery.factory.slim.module.js --factory --esm --slim --dir="/dist-module"
+```
+
#### Custom Build Examples
Create a custom build using `npm run build`, listing the modules to be excluded. Excluding a top-level module also excludes its corresponding directory of modules.
"Build an ES module (ESM) bundle. " +
"By default, a UMD bundle is built."
} )
+ .option( "factory", {
+ type: "boolean",
+ description:
+ "Build the factory bundle. " +
+ "By default, a UMD bundle is built."
+ } )
.option( "slim", {
alias: "s",
type: "boolean",
### Node.js pre-requisites
-For jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as [jsdom](https://github.com/jsdom/jsdom). This can be useful for testing purposes.
+For jQuery to work in Node, a `window` with a `document` is required. Since no such window exists natively in Node, one can be mocked by tools such as [jsdom](https://github.com/jsdom/jsdom). This can be useful for testing purposes.
-jQuery checks for a `window` global with a `document` property and - if one is not present, as is the default in Node.js - it returns a factory accepting a `window` as a parameter instead.
+For Node-based environments that don't have a global `window`, jQuery exposes a dedicated `jquery/factory` entry point.
To `import` jQuery using this factory, use the following:
```js
import { JSDOM } from "jsdom";
const { window } = new JSDOM( "" );
-import jQueryFactory from "jquery";
+import { jQueryFactory } from "jquery/factory";
const $ = jQueryFactory( window );
```
```js
const { JSDOM } = require( "jsdom" );
const { window } = new JSDOM( "" );
-const $ = require( "jquery" )( window );
-```
-
-If the `window` global is present at the moment of the `import` or `require` of `"jquery"`, it will resolve to a jQuery instance, as in the browser. You can set such a global manually to simulate the behavior; with `import`:
-
-```js
-import { JSDOM } from "jsdom";
-const { window } = new JSDOM( "" );
-globalThis.window = window;
-const { default: $ } = await import( "jquery" );
-```
-
-or with `require`:
-
-```js
-const { JSDOM } = require( "jsdom" );
-const { window } = new JSDOM( "" );
-globalThis.window = window;
-const $ = require( "jquery" );
+const { jQueryFactory } = require( "jquery/factory" );
+const $ = jQueryFactory( window );
```
#### Slim build in Node.js
-To use the slim build of jQuery in Node.js, use `"jquery/slim"` instead of `"jquery"` in both `require` or `import` calls above.
+To use the slim build of jQuery in Node.js, use `"jquery/slim"` instead of `"jquery"` in both `require` or `import` calls above. To use the slim build in Node.js with factory mode, use `jquery/factory-slim` instead of `jquery/factory`.
const rollupFileOverrides = require( "./lib/rollup-plugin-file-overrides" );
const pkg = require( "../../package.json" );
const isCleanWorkingDir = require( "./lib/isCleanWorkingDir" );
+const processForDist = require( "./dist" );
const minify = require( "./minify" );
const getTimestamp = require( "./lib/getTimestamp" );
const verifyNodeVersion = require( "./lib/verifyNodeVersion" );
return all;
}
-async function getOutputRollupOptions( { esm = false } = {} ) {
- const wrapperFileName = `wrapper${esm ? "-esm" : ""}.js`;
+async function getOutputRollupOptions( {
+ esm = false,
+ factory = false
+} = {} ) {
+ const wrapperFileName = `wrapper${
+ factory ? "-factory" : ""
+ }${
+ esm ? "-esm" : ""
+ }.js`;
+
const wrapperSource = await read( wrapperFileName );
// Catch `// @CODE` and subsequent comment lines event if they don't start
filename = "jquery.js",
include = [],
esm = false,
+ factory = false,
slim = false,
version,
watch = false
plugins: [ rollupFileOverrides( fileOverrides ) ]
} );
- const outputOptions = await getOutputRollupOptions( { esm } );
+ const outputOptions = await getOutputRollupOptions( { esm, factory } );
if ( watch ) {
const watcher = rollup.watch( {
version
} );
- await minify( { dir, filename, esm } );
+ // Don't minify factory files; they are not meant
+ // for the browser anyway.
+ if ( !factory ) {
+ await minify( { dir, filename, esm } );
+ }
break;
}
} );
} = await bundle.generate( outputOptions );
await writeCompiled( { code, dir, filename, version } );
- await minify( { dir, filename, esm } );
+
+ // Don't minify factory files; they are not meant
+ // for the browser anyway.
+ if ( !factory ) {
+ await minify( { dir, filename, esm } );
+ } else {
+
+ // We normally process for dist during minification to save
+ // file reads. However, some files are not minified and then
+ // we need to do it separately.
+ const contents = await fs.promises.readFile(
+ path.join( dir, filename ),
+ "utf8"
+ );
+ processForDist( contents, filename );
+ }
}
}
slim: true,
version,
watch
+ } ),
+
+ build( {
+ filename: "jquery.factory.js",
+ factory: true,
+ version,
+ watch
+ } ),
+ build( {
+ filename: "jquery.factory.slim.js",
+ slim: true,
+ factory: true,
+ version,
+ watch
+ } ),
+ build( {
+ dir: "dist-module",
+ filename: "jquery.factory.module.js",
+ esm: true,
+ factory: true,
+ version,
+ watch
+ } ),
+ build( {
+ dir: "dist-module",
+ filename: "jquery.factory.slim.module.js",
+ esm: true,
+ slim: true,
+ factory: true,
+ version,
+ watch
} )
] );
"use strict";
// Process files for distribution.
-module.exports = async function processForDist( text, filename ) {
+module.exports = function processForDist( text, filename ) {
if ( !text ) {
throw new Error( "text required for processForDist" );
}
const exec = util.promisify( require( "child_process" ).exec );
const verifyNodeVersion = require( "./lib/verifyNodeVersion" );
-const allowedModules = [ "commonjs", "module" ];
+const allowedLibraryTypes = [ "regular", "factory" ];
+const allowedSourceTypes = [ "commonjs", "module" ];
if ( !verifyNodeVersion() ) {
return;
// important so that the tests & the main process don't interfere with
// each other, e.g. so that they don't share the `require` cache.
-async function runTests( sourceType, module ) {
- if ( !allowedModules.includes( sourceType ) ) {
- throw new Error(
- `Usage: \`node_smoke_tests [${allowedModules.join( "|" )}]:JQUERY\``
- );
+async function runTests( { libraryType, sourceType, module } ) {
+ if ( !allowedLibraryTypes.includes( libraryType ) ||
+ !allowedSourceTypes.includes( sourceType ) ) {
+ throw new Error( `Incorrect libraryType or sourceType value; passed: ${
+ libraryType
+ } ${ sourceType } "${ module }"` );
}
- const dir = `./test/node_smoke_tests/${sourceType}`;
+ const dir = `./test/node_smoke_tests/${ sourceType }/${ libraryType }`;
const files = await fs.promises.readdir( dir, { withFileTypes: true } );
const testFiles = files.filter( ( testFilePath ) => testFilePath.isFile() );
+
+ if ( !testFiles.length ) {
+ throw new Error( `No test files found for ${
+ libraryType
+ } ${ sourceType } "${ module }"` );
+ }
+
await Promise.all(
testFiles.map( ( testFile ) =>
- exec( `node "${dir}/${testFile.name}" "${module}"` )
+ exec( `node "${ dir }/${ testFile.name }" "${ module }"` )
)
);
- console.log( `Node smoke tests passed for ${sourceType} "${module}".` );
+ console.log( `Node smoke tests passed for ${
+ libraryType
+ } ${ sourceType } "${ module }".` );
}
async function runDefaultTests() {
await Promise.all( [
- runTests( "commonjs", "jquery" ),
- runTests( "commonjs", "jquery/slim" ),
- runTests( "commonjs", "./dist/jquery.js" ),
- runTests( "commonjs", "./dist/jquery.slim.js" ),
- runTests( "module", "jquery" ),
- runTests( "module", "jquery/slim" ),
- runTests( "module", "./dist-module/jquery.module.js" ),
- runTests( "module", "./dist-module/jquery.slim.module.js" )
+ runTests( {
+ libraryType: "regular",
+ sourceType: "commonjs",
+ module: "jquery"
+ } ),
+ runTests( {
+ libraryType: "regular",
+ sourceType: "commonjs",
+ module: "jquery/slim"
+ } ),
+ runTests( {
+ libraryType: "regular",
+ sourceType: "commonjs",
+ module: "./dist/jquery.js"
+ } ),
+ runTests( {
+ libraryType: "regular",
+ sourceType: "commonjs",
+ module: "./dist/jquery.slim.js"
+ } ),
+ runTests( {
+ libraryType: "regular",
+ sourceType: "module",
+ module: "jquery"
+ } ),
+ runTests( {
+ libraryType: "regular",
+ sourceType: "module",
+ module: "jquery/slim"
+ } ),
+ runTests( {
+ libraryType: "regular",
+ sourceType: "module",
+ module: "./dist-module/jquery.module.js"
+ } ),
+ runTests( {
+ libraryType: "regular",
+ sourceType: "module",
+ module: "./dist-module/jquery.slim.module.js"
+ } ),
+
+ runTests( {
+ libraryType: "factory",
+ sourceType: "commonjs",
+ module: "jquery/factory"
+ } ),
+ runTests( {
+ libraryType: "factory",
+ sourceType: "commonjs",
+ module: "jquery/factory-slim"
+ } ),
+ runTests( {
+ libraryType: "factory",
+ sourceType: "commonjs",
+ module: "./dist/jquery.factory.js"
+ } ),
+ runTests( {
+ libraryType: "factory",
+ sourceType: "commonjs",
+ module: "./dist/jquery.factory.slim.js"
+ } ),
+ runTests( {
+ libraryType: "factory",
+ sourceType: "module",
+ module: "jquery/factory"
+ } ),
+ runTests( {
+ libraryType: "factory",
+ sourceType: "module",
+ module: "jquery/factory-slim"
+ } ),
+ runTests( {
+ libraryType: "factory",
+ sourceType: "module",
+ module: "./dist-module/jquery.factory.module.js"
+ } ),
+ runTests( {
+ libraryType: "factory",
+ sourceType: "module",
+ module: "./dist-module/jquery.factory.slim.module.js"
+ } )
] );
}
},
{
- files: [ "src/wrapper.js" ],
+ files: [
+ "src/wrapper.js",
+ "src/wrapper-esm.js",
+ "src/wrapper-factory.js",
+ "src/wrapper-factory-esm.js"
+ ],
languageOptions: {
- sourceType: "script",
globals: {
- jQuery: false,
- module: true
+ jQuery: false
}
},
rules: {
// This makes it so code within the wrapper is not indented.
ignoredNodes: [
- "Program > ExpressionStatement > CallExpression > :last-child > *"
+ "Program > FunctionDeclaration > *"
]
}
]
},
{
- files: [ "src/wrapper-esm.js" ],
+ files: [
+ "src/wrapper.js",
+ "src/wrapper-factory.js"
+ ],
languageOptions: {
+ sourceType: "script",
globals: {
- jQuery: false
+ module: false
}
- },
+ }
+ },
+
+ {
+ files: [ "src/wrapper.js" ],
rules: {
- "no-unused-vars": "off",
indent: [
"error",
"tab",
// This makes it so code within the wrapper is not indented.
ignoredNodes: [
- "Program > FunctionDeclaration > *"
+ "Program > ExpressionStatement > CallExpression > :last-child > *"
]
}
]
"script": "./dist/jquery.slim.min.js",
"default": "./dist-module/jquery.slim.module.min.js"
},
+ "./factory": {
+ "node": "./dist/jquery.factory.js",
+ "default": "./dist-module/jquery.factory.module.js"
+ },
+ "./factory-slim": {
+ "node": "./dist/jquery.factory.slim.js",
+ "default": "./dist-module/jquery.factory.slim.module.js"
+ },
"./src/*.js": "./src/*.js"
},
"main": "dist/jquery.js",
*/
// For ECMAScript module environments where a proper `window`
// is present, execute the factory and get jQuery.
-// For environments that do not have a `window` with a `document`
-// (such as Node.js), expose a factory as module.exports.
-// This accentuates the need for the creation of a real `window`.
-// e.g. var jQuery = require("jquery")(window);
-// See ticket trac-14549 for more info.
-var jQueryOrJQueryFactory = typeof window !== "undefined" && window.document ?
- jQueryFactory( window, true ) :
- function( w ) {
- if ( !w.document ) {
- throw new Error( "jQuery requires a window with a document" );
- }
- return jQueryFactory( w );
- };
-
function jQueryFactory( window, noGlobal ) {
+if ( typeof window === "undefined" || !window.document ) {
+ throw new Error( "jQuery requires a window with a document" );
+}
+
// @CODE
// build.js inserts compiled jQuery here
}
-export {
- jQueryOrJQueryFactory as jQuery,
- jQueryOrJQueryFactory as $
-};
+var jQuery = jQueryFactory( window, true );
+
+export { jQuery, jQuery as $ };
-export default jQueryOrJQueryFactory;
+export default jQuery;
--- /dev/null
+/*!
+ * jQuery JavaScript Library v@VERSION
+ * https://jquery.com/
+ *
+ * Copyright OpenJS Foundation and other contributors
+ * Released under the MIT license
+ * https://jquery.org/license
+ *
+ * Date: @DATE
+ */
+// Expose a factory as `jQueryFactory`. Aimed at environments without
+// a real `window` where an emulated window needs to be constructed. Example:
+//
+// import { jQueryFactory } from "jquery/factory";
+// const jQuery = jQueryFactory( window );
+//
+// See ticket trac-14549 for more info.
+function jQueryFactoryWrapper( window, noGlobal ) {
+
+if ( !window.document ) {
+ throw new Error( "jQuery requires a window with a document" );
+}
+
+// @CODE
+// build.js inserts compiled jQuery here
+
+return jQuery;
+
+}
+
+export function jQueryFactory( window ) {
+ return jQueryFactoryWrapper( window, true );
+}
--- /dev/null
+/*!
+ * jQuery JavaScript Library v@VERSION
+ * https://jquery.com/
+ *
+ * Copyright OpenJS Foundation and other contributors
+ * Released under the MIT license
+ * https://jquery.org/license
+ *
+ * Date: @DATE
+ */
+// Expose a factory as `jQueryFactory`. Aimed at environments without
+// a real `window` where an emulated window needs to be constructed. Example:
+//
+// const jQuery = require( "jquery/factory" )( window );
+//
+// See ticket trac-14549 for more info.
+function jQueryFactoryWrapper( window, noGlobal ) {
+
+"use strict";
+
+if ( !window.document ) {
+ throw new Error( "jQuery requires a window with a document" );
+}
+
+// @CODE
+// build.js inserts compiled jQuery here
+
+return jQuery;
+
+}
+
+function jQueryFactory( window ) {
+ "use strict";
+
+ return jQueryFactoryWrapper( window, true );
+}
+
+module.exports = { jQueryFactory: jQueryFactory };
// For CommonJS and CommonJS-like environments where a proper `window`
// is present, execute the factory and get jQuery.
- // For environments that do not have a `window` with a `document`
- // (such as Node.js), expose a factory as module.exports.
- // This accentuates the need for the creation of a real `window`.
- // e.g. var jQuery = require("jquery")(window);
- // See ticket trac-14549 for more info.
- module.exports = global.document ?
- factory( global, true ) :
- function( w ) {
- if ( !w.document ) {
- throw new Error( "jQuery requires a window with a document" );
- }
- return factory( w );
- };
+ module.exports = factory( global, true );
} else {
factory( global );
}
"use strict";
+if ( !window.document ) {
+ throw new Error( "jQuery requires a window with a document" );
+}
+
// @CODE
// build.js inserts compiled jQuery here
+++ /dev/null
-"use strict";
-
-const assert = require( "node:assert" );
-
-const { ensureGlobalNotCreated } = require( "./lib/ensure_global_not_created.cjs" );
-const { getJQueryModuleSpecifier } = require( "./lib/jquery-module-specifier.cjs" );
-
-const jQueryModuleSpecifier = getJQueryModuleSpecifier();
-const jQueryFactory = require( jQueryModuleSpecifier );
-
-assert.throws( () => {
- jQueryFactory( {} );
-}, /jQuery requires a window with a document/ );
-
-ensureGlobalNotCreated( module.exports );
+++ /dev/null
-"use strict";
-
-const { JSDOM } = require( "jsdom" );
-
-const { ensureJQuery } = require( "./lib/ensure_jquery.cjs" );
-const { ensureGlobalNotCreated } = require( "./lib/ensure_global_not_created.cjs" );
-const { getJQueryModuleSpecifier } = require( "./lib/jquery-module-specifier.cjs" );
-
-const { window } = new JSDOM( "" );
-
-const jQueryModuleSpecifier = getJQueryModuleSpecifier();
-const jQueryFactory = require( jQueryModuleSpecifier );
-const jQuery = jQueryFactory( window );
-
-ensureJQuery( jQuery );
-ensureGlobalNotCreated( module.exports );
--- /dev/null
+"use strict";
+
+const assert = require( "node:assert" );
+
+const { ensureGlobalNotCreated } = require( "../lib/ensure_global_not_created.cjs" );
+const { getJQueryModuleSpecifier } = require( "../lib/jquery-module-specifier.cjs" );
+
+const jQueryModuleSpecifier = getJQueryModuleSpecifier();
+const { jQueryFactory } = require( jQueryModuleSpecifier );
+
+assert.throws( () => {
+ jQueryFactory( {} );
+}, /jQuery requires a window with a document/ );
+
+ensureGlobalNotCreated( module.exports );
--- /dev/null
+"use strict";
+
+const { JSDOM } = require( "jsdom" );
+
+const { ensureJQuery } = require( "../lib/ensure_jquery.cjs" );
+const { ensureGlobalNotCreated } = require( "../lib/ensure_global_not_created.cjs" );
+const { getJQueryModuleSpecifier } = require( "../lib/jquery-module-specifier.cjs" );
+
+const { window } = new JSDOM( "" );
+
+const jQueryModuleSpecifier = getJQueryModuleSpecifier();
+const { jQueryFactory } = require( jQueryModuleSpecifier );
+const jQuery = jQueryFactory( window );
+
+ensureJQuery( jQuery );
+ensureGlobalNotCreated( module.exports );
--- /dev/null
+"use strict";
+
+const process = require( "node:process" );
+
+if ( typeof Symbol === "undefined" ) {
+ console.log( "Symbols not supported, skipping the test..." );
+ process.exit();
+}
+
+const { ensureIterability } = require( "../lib/ensure_iterability_es6.cjs" );
+const { getJQueryModuleSpecifier } = require( "../lib/jquery-module-specifier.cjs" );
+
+const jQueryModuleSpecifier = getJQueryModuleSpecifier();
+ensureIterability( jQueryModuleSpecifier );
+++ /dev/null
-"use strict";
-
-const process = require( "node:process" );
-
-if ( typeof Symbol === "undefined" ) {
- console.log( "Symbols not supported, skipping the test..." );
- process.exit();
-}
-
-const { ensureIterability } = require( "./lib/ensure_iterability_es6.cjs" );
-const { getJQueryModuleSpecifier } = require( "./lib/jquery-module-specifier.cjs" );
-
-const jQueryModuleSpecifier = getJQueryModuleSpecifier();
-ensureIterability( jQueryModuleSpecifier );
const ensureIterability = ( jQueryModuleSpecifier ) => {
const { window } = new JSDOM( "" );
- const jQueryFactory = require( jQueryModuleSpecifier );
+ const { jQueryFactory } = require( jQueryModuleSpecifier );
const jQuery = jQueryFactory( window );
const elem = jQuery( "<div></div><span></span><a></a>" );
--- /dev/null
+"use strict";
+
+const { JSDOM } = require( "jsdom" );
+
+const { ensureJQuery } = require( "../lib/ensure_jquery.cjs" );
+const { ensureGlobalNotCreated } = require( "../lib/ensure_global_not_created.cjs" );
+const { getJQueryModuleSpecifier } = require( "../lib/jquery-module-specifier.cjs" );
+
+const jQueryModuleSpecifier = getJQueryModuleSpecifier();
+
+const { window } = new JSDOM( "" );
+
+// Set the window global.
+globalThis.window = window;
+
+const jQuery = require( jQueryModuleSpecifier );
+
+ensureJQuery( jQuery );
+ensureGlobalNotCreated( module.exports, window );
+++ /dev/null
-"use strict";
-
-const { JSDOM } = require( "jsdom" );
-
-const { ensureJQuery } = require( "./lib/ensure_jquery.cjs" );
-const { ensureGlobalNotCreated } = require( "./lib/ensure_global_not_created.cjs" );
-const { getJQueryModuleSpecifier } = require( "./lib/jquery-module-specifier.cjs" );
-
-const jQueryModuleSpecifier = getJQueryModuleSpecifier();
-
-const { window } = new JSDOM( "" );
-
-// Set the window global.
-globalThis.window = window;
-
-const jQuery = require( jQueryModuleSpecifier );
-
-ensureJQuery( jQuery );
-ensureGlobalNotCreated( module.exports, window );
+++ /dev/null
-import assert from "node:assert";
-
-import { ensureGlobalNotCreated } from "./lib/ensure_global_not_created.js";
-import { getJQueryModuleSpecifier } from "./lib/jquery-module-specifier.js";
-
-const jQueryModuleSpecifier = getJQueryModuleSpecifier();
-const { default: jQueryFactory } = await import( jQueryModuleSpecifier );
-
-assert.throws( () => {
- jQueryFactory( {} );
-}, /jQuery requires a window with a document/ );
-
-ensureGlobalNotCreated();
+++ /dev/null
-import { JSDOM } from "jsdom";
-
-import { ensureJQuery } from "./lib/ensure_jquery.js";
-import { ensureGlobalNotCreated } from "./lib/ensure_global_not_created.js";
-import { getJQueryModuleSpecifier } from "./lib/jquery-module-specifier.js";
-
-const { window } = new JSDOM( "" );
-
-const jQueryModuleSpecifier = getJQueryModuleSpecifier();
-const { default: jQueryFactory } = await import( jQueryModuleSpecifier );
-const jQuery = jQueryFactory( window );
-
-ensureJQuery( jQuery );
-ensureGlobalNotCreated();
--- /dev/null
+import assert from "node:assert";
+
+import { ensureGlobalNotCreated } from "../lib/ensure_global_not_created.js";
+import { getJQueryModuleSpecifier } from "../lib/jquery-module-specifier.js";
+
+const jQueryModuleSpecifier = getJQueryModuleSpecifier();
+const { jQueryFactory } = await import( jQueryModuleSpecifier );
+
+assert.throws( () => {
+ jQueryFactory( {} );
+}, /jQuery requires a window with a document/ );
+
+ensureGlobalNotCreated();
--- /dev/null
+import { JSDOM } from "jsdom";
+
+import { ensureJQuery } from "../lib/ensure_jquery.js";
+import { ensureGlobalNotCreated } from "../lib/ensure_global_not_created.js";
+import { getJQueryModuleSpecifier } from "../lib/jquery-module-specifier.js";
+
+const { window } = new JSDOM( "" );
+
+const jQueryModuleSpecifier = getJQueryModuleSpecifier();
+const { jQueryFactory } = await import( jQueryModuleSpecifier );
+const jQuery = jQueryFactory( window );
+
+ensureJQuery( jQuery );
+ensureGlobalNotCreated();
--- /dev/null
+import process from "node:process";
+
+import { ensureIterability } from "../lib/ensure_iterability_es6.js";
+import { getJQueryModuleSpecifier } from "../lib/jquery-module-specifier.js";
+
+if ( typeof Symbol === "undefined" ) {
+ console.log( "Symbols not supported, skipping the test..." );
+ process.exit();
+}
+
+const jQueryModuleSpecifier = getJQueryModuleSpecifier();
+await ensureIterability( jQueryModuleSpecifier );
+++ /dev/null
-import process from "node:process";
-
-import { ensureIterability } from "./lib/ensure_iterability_es6.js";
-import { getJQueryModuleSpecifier } from "./lib/jquery-module-specifier.js";
-
-if ( typeof Symbol === "undefined" ) {
- console.log( "Symbols not supported, skipping the test..." );
- process.exit();
-}
-
-const jQueryModuleSpecifier = getJQueryModuleSpecifier();
-await ensureIterability( jQueryModuleSpecifier );
export const ensureIterability = async( jQueryModuleSpecifier ) => {
const { window } = new JSDOM( "" );
- const { default: jQueryFactory } = await import( jQueryModuleSpecifier );
+ const { jQueryFactory } = await import( jQueryModuleSpecifier );
const jQuery = jQueryFactory( window );
const elem = jQuery( "<div></div><span></span><a></a>" );
--- /dev/null
+import { JSDOM } from "jsdom";
+
+import { ensureJQuery } from "../lib/ensure_jquery.js";
+import { ensureGlobalNotCreated } from "../lib/ensure_global_not_created.js";
+import { getJQueryModuleSpecifier } from "../lib/jquery-module-specifier.js";
+
+const jQueryModuleSpecifier = getJQueryModuleSpecifier();
+
+const { window } = new JSDOM( "" );
+
+// Set the window global.
+globalThis.window = window;
+
+const { default: jQuery } = await import( jQueryModuleSpecifier );
+
+ensureJQuery( jQuery );
+ensureGlobalNotCreated( window );
+++ /dev/null
-import { JSDOM } from "jsdom";
-
-import { ensureJQuery } from "./lib/ensure_jquery.js";
-import { ensureGlobalNotCreated } from "./lib/ensure_global_not_created.js";
-import { getJQueryModuleSpecifier } from "./lib/jquery-module-specifier.js";
-
-const jQueryModuleSpecifier = getJQueryModuleSpecifier();
-
-const { window } = new JSDOM( "" );
-
-// Set the window global.
-globalThis.window = window;
-
-const { default: jQuery } = await import( jQueryModuleSpecifier );
-
-ensureJQuery( jQuery );
-ensureGlobalNotCreated( window );
const { window } = new JSDOM( "" );
-const jQuery = require( "../../" )( window );
+const { jQueryFactory } = require( "jquery/factory" );
+const jQuery = jQueryFactory( window );
module.exports.deferred = () => {
const deferred = jQuery.Deferred();
const { window } = new JSDOM( "" );
-const jQuery = require( "../../" )( window );
+const { jQueryFactory } = require( "jquery/factory" );
+const jQuery = jQueryFactory( window );
module.exports.deferred = () => {
let adopted, promised;