aboutsummaryrefslogtreecommitdiffstats
path: root/dist
Commit message (Collapse)AuthorAgeFilesLines
* Core: Fix the exports setup to make bundlers work with ESM & CommonJSMichał Gołębiowski-Owczarek2024-03-122-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We cannot pass a single file via the `module` condition as then `require( "jquery" )` will not return jQuery but instead the module object with `default`, `$` & `jQuery` as keys. Instead: 1. For Node.js, detected via the `node` condition: 1. Expose a regular CommonJS version to `require` 2. Expose a tiny wrapper over CommonJS to `import` 2. For bundlers, detected via the `module` condition: 1. Expose a regular ESM version to `import` 2. Expose a tiny wrapper over ESM to `require` 3. If neither Node.js nor bundlers are detected (no `node` or `module` conditions`): 1. Expose a regular CommonJS version to `require` 2. Expose a regular ESM version to `import` The reasons for such definitions are as follows: 1. In Node.js, one can synchronously import from a CommonJS file inside of an ESM one but not vice-versa. To use an ESM file in a CommonJS one, a dynamic import is required and that forces asynchronicity. 2. In some bundlers CommonJS is not necessarily enabled - e.g. in Rollup without the CommonJS plugin. Therefore, the ESM version needs to be pure ESM. However, bundlers allow synchronously calling `require` on an ESM file. This is possible since bundlers merge the files before they are passed to the browser to execute and the final bundles no longer contain async import code. 3. Bare ESM & CommonJS versions are provided to non-Node non-bundler environments where we cannot assume interoperability between ESM & CommonJS is supported. 4. Bare versions cannot be supplied to Node or bundlers as projects using both ESM & CommonJS to fetch jQuery would result in duplicate jQuery instances, leading to increased JS size and disjoint data storage. In addition to the above changes, the `script` condition has been dropped. Only Webpack documents this condition and it's not clear when exactly it's triggered. Adding support for a new condition can be added later without a breaking change; removing is not so easy. The `production` & `development` conditions have been removed as well. They were not really applied correctly; we'd need to provide both of them to each current leaf which would double the size of the definition for the `.` & `./slim` entry points. In jQuery, the only difference between development & production builds is minification; there are no logic changes so we can pass unminified versions to all the tooling, expecting minification down the line. As for the factory entry points: 1. Node.js always gets the CommonJS version 2. Bundlers always get the ESM version 3. Other tools take the ESM version when using `import` and the CommonJS when using `require`. The complexity is lower than for the `.` & `./slim` entry points because there's no default export to handle so Node/bundler wrapper files are not necessary. Other changes: * Tests: Change "node:assert" to "node:assert/strict"; the former is deprecated * Docs: Mention that the CommonJS module doesn't expose named exports * Tests: Run Node & bundler tests for all the above cases Fixes gh-5416 Closes gh-5429
* Build: migrate most grunt tasks off of gruntTimmy Willison2023-09-181-41/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Updated tasks include: - lint - npmcopy - build, minify, and process for distribution. - new custom build command using yargs - compare size of minified/gzip built files - pretest scripts, including qunit-fixture, babel transpilation, and npmcopy - node smoke tests - promises aplus tests - new watch task using `rollup.watch` directly Also: - upgraded husky and added the new lint command - updated lint config to use new "flat" config format. See https://eslint.org/docs/latest/use/configure/configuration-files-new - Temporarily disabled one lint rule until flat config is supported by eslint-plugin-import. See https://github.com/import-js/eslint-plugin-import/issues/2556 - committed package-lock.json - updated all test scripts to use the new build - added an express test server that uses middleware-mockserver (this can be used to run tests without karma) - build-all-variants is now build:all Close gh-5318
* Build: Add `exports` to package.json, export slim & esm buildsMichał Gołębiowski-Owczarek2023-07-102-1/+15
| | | | | | | | | | | | | | | | | | | | Summary of the changes: * define the `exports` field in `package.json`; `jQuery` & `$` are also exported as named exports in ESM builds now * declare `"type": "module"` globally except for the `build` folder * add the `--esm` option to `grunt custom`, generating jQuery as an ECMAScript module into the `dist-module` folder * expand `node_smoke_tests` to test the slim & ESM builds and their various combinations; also, test both jQuery loaded via a path to the file as well as from module specifiers that should be parsed via the `exports` feature * add details about ESM usage to the release package README * run `compare_size` on all built minified files; don't run it anymore on unminified files where they don't provide lots of value * remove the remove_map_comment task; SWC doesn't insert the `//# sourceMappingURL=` pragma by default so there's nothing to strip Fixes gh-4592 Closes gh-5255
* Build: Move ESLint max-len disable-directive to dist/.eslintrc.jsonEd S2020-04-271-0/+3
| | | | | | | This disable-directive only applies to the built version, so put it in /dist. This avoids a warning about an unused directive in the source version. Closes gh-4676
* Build: Enable ESLint one-var rule for var declarations in browser codeMichał Gołębiowski-Owczarek2020-03-021-1/+2
| | | | | | | Node.js code is written more & more commonly in ES6+ so it doesn't make sense to enable it there. There are many violations in test code so it's disabled there as well. Closes gh-4615
* Build: Lint the minified jQuery file as wellMichał Gołębiowski-Owczarek2020-01-211-8/+13
| | | | | | | While we have absolutely no style-related expectations to our minified file, we do care that it's valid ES 5.1. This is now verified. Fixes gh-3075 Closes gh-4594
* Core: Migrate from AMD to ES modules 🎉Michał Gołębiowski-Owczarek2019-11-181-0/+11
| | | | | | | | | | | | | | | | | | | | | | Migrate all source AMD modules to ECMAScript modules. The final bundle is compiled by a custom build process that uses Rollup under the hood. Test files themselves are still loaded via RequireJS as that has to work in IE 11. Tests can now be run in "Load as modules" mode which replaces the previous "Load with AMD" option. That option of running tests doesn't work in IE and Edge as it requires support for dynamic imports. Some of the changes required by the migration: * check `typeof` of `noGlobal` instead of using the variable directly as it's not available when modules are used * change the nonce module to be an object as ECMASscript module exports are immutable * remove some unused exports * import `./core/parseHTML.js` directly in `jquery.js` so that it's not being cut out when the `ajax` module is excluded in a custom compilation Closes gh-4541
* Selector: Inline Sizzle into the selector moduleMichał Gołębiowski-Owczarek2019-07-291-14/+1
| | | | | | | | | | | | | | | | | | This commit removes Sizzle from jQuery, inlining its code & removing obsolete workarounds where applicable. The selector-native module has been removed. Further work on the selector module may decrease the size enough that it will no longer be necessary. If it turns out it's still useful, we'll reinstate it but the code will look different anyway as we'll want to share as much code as possible with the existing selector module. The Sizzle AUTHORS.txt file has been merged with the jQuery one - people are sorted by their first contributions to either of the two repositories. The commit reduces the gzipped jQuery size by 1460 bytes compared to master. Closes gh-4395
* Build: ESLint: forbid unused function parametersMichał Gołębiowski-Owczarek2019-05-131-1/+2
| | | | | | | | | | | | | This commit requires all function parameters to be used, not just the last one. In cases where that's not possible as we need to match an external API, there's an escape hatch of prefixing an unused argument with `_`. This change makes it easier to catch unused AMD dependencies and unused parameters in internal functions the API of which we may change at will, among other things. Unused AMD dependencies have been removed as part of this commit. Closes gh-4381
* Build: Fix comment typoMatan Kotler-Berkowitz2017-08-081-1/+1
| | | Closes gh-3747
* Build: ESLint setup improvementsMichał Gołębiowski2016-12-191-1/+4
| | | | | | | 1. Use the short name of the preset in the config. 2. Run ESLint first on non-minified files. 3. Explicitly specify environments in every config file (those settings cascade which means we've been assuming a Node.js environment where we shouldn't have).
* Build: .eslintrc -> .eslintrc.jsonOleg Gaidarenko2016-08-021-1/+1
| | | | | | | | `.eslintrc` format is deprecated - http://eslint.org/docs/user-guide/configuring#configuration-file-formats Fixes gh-3248 Closes gh-3247
* Build: Simplify Gruntfile constructionsOleg Gaidarenko2016-08-021-1/+1
| | | | Fixes gh-3246
* Build: Update eslint config and fix associated errorsOleg Gaidarenko2016-07-151-0/+1
|
* Build: More ESLint related changesOleg Gaidarenko2016-07-091-0/+1
|
* Build: ESLint detailsOleg Gaidarenko2016-06-111-0/+17
Use eslint pragmas, fix new errors, etc Closes gh-3148