Commit Graph

413 Commits

Author SHA1 Message Date
Timmy Willison
7e6cee72e2
Build: align eslint config with 3.x branch as much as possible
Close gh-5524
2024-08-08 21:39:11 -04:00
Timmy Willison
53ad94f319 Release: correct build date in verification; other improvements
- the date is actually the date of the commit *prior*
  to the tag commit, as the files are built and then committed.
- also, the CDN should still be checked for non-stable releases,
  and should use different filenames (including in the map files).
- certain files should be skipped when checking the CDN.
- removed file diffing because it ended up being far too noisy,
  making it difficult to find the info I needed.
- because the build script required an addition, release
  verification will not work until the next release.
- print all files in failure case and whether each matched
- avoid npm script log in GH release notes changelog
- exclude changelog.md from release:clean command
- separate the post-release script from release-it for now, so we
  can keep manual verification before each push. The exact command is
  printed at the ened for convenience.

Closes gh-5521
2024-07-29 12:34:41 -04:00
Timmy Willison
be048a027d
Release: remove dist files from main branch 2024-07-17 10:00:13 -04:00
Timmy Willison
3e612aeeb3
Release: ensure builds have the proper version
- order hooks in execution order
- update workflow actions

Closes gh-5519
2024-07-17 09:32:02 -04:00
Timmy Willison
1fa8df5dbd
Release: set preReleaseBase in config file
https://github.com/release-it/release-it/issues/1128#issuecomment-2224692805

Closes gh-5518
2024-07-12 15:43:41 -04:00
Timmy Willison
5518b2da18
Release: fix running pre/post release scripts in windows
- also fix tagging the release in the dist repo

Closes gh-5517
2024-07-11 12:23:10 -04:00
Timmy Willison
2646a8b07f Release: migrate release process to release-it
*Authors*
- Checking and updating authors has been migrated
  to a custom script in the repo

*Changelog*
- changelogplease is no longer maintained
- generate changelog in markdown for GitHub releases
- generate changelog in HTML for blog posts
- generate contributors list in HTML for blog posts

*dist*
- clone dist repo, copy files, and commit/push
- commit tag with dist files on main branch;
  remove dist files from main branch after release

*cdn*
- clone cdn repo, copy files, and commit/push
- create versioned and unversioned copies in cdn/
- generate md5 sums and archives for Google and MSFT

*build*
- implement reproducible builds and verify release builds
  * uses the last modified date for the latest commit
  * See https://reproducible-builds.org/
- the verify workflow also ensures all files were
  properly published to the CDN and npm

*docs*
- the new release workflow is documented at build/release/README.md

*misc*
- now that we don't need the jquery-release script and
  now that we no longer need to build on Node 10, we can
  use ESM in all files in the build folder
- move dist wrappers to "wrappers" folders for easy removal
  of all built files
- limit certain workflows to the main repo (not forks)
- version in package.json has been set to beta.1 so that
  the next release will be beta.2
- release-it added the `preReleaseBase` option and we
  now always set it to `1` in the npm script. This is
  a noop for stable releases.

Fixes jquery/jquery-release#114
Closes gh-5512
2024-07-11 10:00:56 -04:00
Timmy Willison
cb8ab6ccdb
Build: upgrade dependencies; fix bundler tests on windows
- account for newly unused parameters in the slim builds

Closes gh-5509
2024-06-15 09:11:34 -04:00
Michał Gołębiowski-Owczarek
7cdd837423
Docs: Update remaining HTTP URLs to HTTPS
Update a few remaining HTTP URLs to HTTPS. The only ones left are XMLNS-like
URLs or ones to localhost - those need to stay as-is.

Closes gh-5479
2024-04-25 00:22:36 +02:00
Michał Gołębiowski-Owczarek
60f11b58bf
Core: Fix the exports setup to make bundlers work with ESM & CommonJS
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
2024-03-12 00:39:34 +01:00
Timmy Willison
783c9d6958 Build: make compare size cache readable for manual edits
Ref gh-5440
2024-03-11 13:29:23 -04:00
Timmy Willison
8a3a74c475 Build: fix size comparison for slim files when the branch is dirty
Ref gh-5440
2024-03-11 13:29:23 -04:00
Timmy Willison
ae7f6139cc Build: migrate more uses of fs.promises; use node: protocol
Ref gh-5440
2024-03-11 13:29:23 -04:00
Timmy Willison
5aa7ed888d Build: drop support for Node 10
Close gh-5436
2024-03-09 10:36:47 -05:00
Timmy Willison
dfc693ea25
Tests: migrate testing infrastructure to minimal dependencies
This is a complete rework of our testing infrastructure. The main goal is to modernize and drop deprecated or undermaintained dependencies (specifically, grunt, karma, and testswarm). We've achieved that by limiting our dependency list to ones that are unlikely to drop support any time soon. The new dependency list includes:

- `qunit` (our trusty unit testing library)
- `selenium-webdriver` (for spinning up local browsers)
- `express` (for starting a test server and adding middleware)
  - express middleware includes uses of `body-parser` and `raw-body`
- `yargs` (for constructing a CLI with pretty help text)
- BrowserStack (for running each of our QUnit modules separately in all of our supported browsers)
  - `browserstack-local` (for opening a local tunnel. This is the same package still currently used in the new Browserstack SDK)
  - We are not using any other BrowserStack library. The newest BrowserStack SDK does not fit our needs (and isn't open source). Existing libraries, such as `node-browserstack` or `browserstack-runner`, either do not quite fit our needs, are under-maintained and out-of-date, or are not robust enough to meet all of our requirements. We instead call the [BrowserStack REST API](https://github.com/browserstack/api) directly.

## BrowserStack Runner
- automatically retries individual modules in case of test failure(s)
- automatically attempts to re-establish broken tunnels
- automatically refreshes the page in case a test run has stalled
- runs all browsers concurrently and uses as many sessions as are available under the BrowserStack plan. It will wait for available sessions if there are none.
- supports filtering the available list of browsers by browser name, browser version, device, OS, and OS version (see `npm run test:unit -- --list-browsers` for more info). It will retrieve the latest matching browser available if any of those parameters are not specified.
- cleans up after itself (closes the local tunnel, stops the test server, etc.)
- Requires `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables.

## Selenium Runner
- supports running any local browser as long as the driver is installed, including support for headless mode in Chrome, FF, and Edge
- supports running `basic` tests on the latest [jsdom](https://github.com/jsdom/jsdom#readme), which can be seen in action in this PR (see `test:browserless`)
- Node tests will run as before in PRs and all non-dependabot branches, but now includes tests on real Safari in a GH actions macos image instead of playwright-webkit.
- can run multiple browsers and multiple modules concurrently

Other notes:
- Stale dependencies have been removed and all remaining dependencies have been upgraded with a few exceptions:
  - `sinon`: stopped supporting IE in version 10. But, `sinon` has been updated to 9.x.
  - `husky`: latest does not support Node 10 and runs on `npm install`. Needed for now until git builds are migrated to GitHub Actions.
  - `rollup`: latest does not support Node 10. Needed for now until git builds are migrated to GitHub Actions.
- BrowserStack tests are set to run on each `main` branch commit
- `debug` mode leaves Selenium browsers open whether they pass or fail and leaves browsers with test failures open on BrowserStack. The latter is to avoid leaving open too many sessions.
- This PR includes a workflow to dispatch BrowserStack runs on-demand
- The Node version used for most workflow tests has been upgraded to 20.x
- updated supportjQuery to 3.7.1

Run `npm run test:unit -- --help` for CLI documentation

Close gh-5418
2024-02-26 09:42:10 -05:00
Timmy Willison
1a324b0792
Release: add factory files to release distribution
Fixes gh-5411
Close gh-5412
2024-02-08 19:42:51 -05:00
Timmy Willison
b507c8648f
Release: use buildDefaultFiles directly and pass version
- also add the ability to pass VERSION in env to test final builds
- adjust sha regex to account for lack of shas
- set the version on the dist package.json

Close gh-5408
2024-02-06 09:53:30 -05:00
Timmy Willison
63767650b5
Release: copy dist-module folder as well
Close gh-5407
2024-02-05 12:56:33 -05:00
Timmy Willison
3a0ca684eb
Release: only published versioned files to cdn
Close gh-5406
2024-02-05 11:51:11 -05:00
Timmy Willison
7eac932da7
Release: remove scripts and dev deps from dist package.json
- this became necessary due to the addition of the prepare script
- scripts aren't needed and don't work in the dist repo

Close gh-5404
2024-02-05 10:36:47 -05:00
Timmy Willison
3b963a2166
Release: update build command in Release.generateArtifacts
Close gh-5399
2024-01-31 09:18:41 -05:00
Timmy Willison
af79c99939
Build: migrate grunt authors to a custom script
- the new script pulls all authors from the Sizzle repo
- added temporary grunt task for releases

Close gh-5395
2024-01-22 21:08:16 -05:00
Michał Gołębiowski-Owczarek
f47c6a8337
Build: Update ESLint-related packages, fix linting errors
The main change is the new rule in `eslint-config-jquery`:
`template-curly-spacing`.

Closes gh-5347
Ref jquery/eslint-config-jquery#21
Ref gh-5348
2023-11-02 00:48:50 +01:00
Michał Gołębiowski-Owczarek
ace646f6e8
Docs: Fix module links in the package README
The package README used to show examples importing from a regular jQuery file;
this won't work natively. Instead, use module versions of jQuery in these
examples.

Closes gh-5336
2023-09-22 01:39:05 +02:00
Timmy Willison
a7fa303fda
Build: sort branches in compare_size; last run last
Close gh-5333
2023-09-21 17:45:33 -04:00
Timmy Willison
7ef9099d32 Build: fix inconsistent builds in Node 20
- one fileOverrides per build
- only run the lint build when running lint

Close gh-5332
2023-09-20 18:20:59 -04:00
Timmy Willison
09972bcc68
Build: add commit SHAs and last runs to comparisons
- only remove the short SHA and .dirty from version strings
- automatically reset the cache on version mismatch

Close gh-5329
2023-09-20 15:43:30 -04:00
Michał Gołębiowski-Owczarek
5f86959092
Core: Add more info about named exports
Also, fix an example importing from `jquery/src/css.js` as that is supposed
to use named exports now.

Closes gh-5328
2023-09-20 01:29:05 +02:00
Michał Gołębiowski-Owczarek
46f6e3da79
Core: Move the factory to separate exports
Since versions 1.11.0/2.1.0, jQuery has used a module wrapper with one strange
addition - in CommonJS environments, if a global `window` with a `document` was
not present, jQuery exported a factory accepting a `window` implementation and
returning jQuery.

This approach created a number of problems:
1. Properly typing jQuery would be a nightmare as the exported value depends on
   the environment. In practice, typing definitions ignored the factory case.
2. Since we now use named exports for the jQuery module version, it felt weird
   to have `jQuery` and `$` pointing to the factory instead of real jQuery.

Instead, for jQuery 4.0 we leverage the just added `exports` field in
`package.json` to expose completely separate factory entry points: one for the
full build, one for the slim one.

Exports definitions for `./factory` & `./factory-slim` are simpler than for `.`
and `./slim` - this is because it's a new entry point, we only expose a named
export and so there's no issue with just pointing Node.js to the CommonJS
version (we cannot use the module version for `import` from Node.js to avoid
double package hazard). The factory entry points are also not meant for the Web
browser which always has a proper `window` - and they'd be unfit for an
inclusion in a regular script tag anyway. Because of that, we also don't
generate minified versions of these entry points.

The factory files are not pushed to the CDN since they are mostly aimed
at Node.js.

Closes gh-5293
2023-09-19 18:58:24 +02:00
Timmy Willison
2bdecf8b7b
Build: migrate most grunt tasks off of grunt
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
2023-09-18 12:39:00 -04:00
Michał Gołębiowski-Owczarek
f75daab091
Core: Use named exports in src/
The `default` export is treated differently across tooling when transpiled
to CommonJS - tools differ on whether `module.exports` represents the full
module object or just its default export. Switch `src/` modules to named
exports for tooling consistency.

Fixes gh-5262
Closes gh-5292
2023-09-12 02:27:19 +02:00
Timmy Willison
48cc402a91
Build: replace CRLF with LF during minify
- SWC is not respecting the git setting and does not have
  an option to force LF. This fixes the build on Windows.

Close gh-5305
2023-08-10 21:13:24 -04:00
Michał Gołębiowski-Owczarek
8be4c0e4f8
Build: Add exports to package.json, export slim & esm builds
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
2023-07-10 19:14:08 +02:00
Michał Gołębiowski-Owczarek
e24218758b
Build: Switch form Terser to SWC for JS minification (#5286)
Also, as part of this, fix the `file` & `sources` properties of the source map
file.

Fixes gh-5285
Closes gh-5286
Ref gh-5258
2023-07-10 18:23:07 +02:00
Michał Gołębiowski-Owczarek
5701957b72
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
2023-06-27 18:23:58 +02:00
Michał Gołębiowski-Owczarek
27303c6be0
Build: Switch the minifier from UglifyJS to Terser
UglifyJS is ES5-only, while Terser supports newer ECMAScript versions. jQuery
is authored in ES5 but jQuery 4.x will also have an ESM build that cannot be
minified using UglifyJS directly.

We could strip the `export` statement, minify via UglifyJS and re-add one but
that increases complexity & may not fully play nice with source maps.

On the other hand, switching to Terser increases the minfied size by just 324
bytes and the minified gzipped one by just 70 bytes. Such differences largely
disappear among bigger size gains from the `3.x-stable` line - around 2.7 KB
minified gzipped as of now.

Closes gh-5258
2023-05-31 18:59:35 +02:00
Timmy Willison
f088c36631
Release: add support for md5 sums in windows
Close gh-5219
2023-03-09 20:19:07 +00:00
Timmy Willison
c66d4700dc
Build: remove stale Insight package from custom builds
Close gh-5182
2022-12-20 20:57:49 +00:00
Michał Gołębiowski-Owczarek
4c1171f2ed
Selector: Re-introduce selector-native.js
Re-introduce the `selector-native` similar to the one on the `3.x-stable`
branch. One difference is since the `main` branch inlined Sizzle, some
selector utils can be shared between the main `selector` module and
`selector-native`.

The main `selector` module can be disabled in favor of `selector-native`
via:

    grunt custom:-selector

Other changes:
* Tests: Fix Safari detection - Chrome Headless has a different user
  agent than Safari and a browser check in selector tests didn't take
  that into account.
* Tests: Run selector-native tests in `npm test`
* Selector: Fix querying on document fragments

Ref gh-4395
Closes gh-5085
2022-11-21 23:23:39 +01:00
Michał Gołębiowski-Owczarek
edccabf10d
Docs: Update the README of the published package
The previous details were showing their age, e.g. mentions about browsers
not supporting ES2015. The story with ES modules is more complex as it's also
about loaders but to keep the README simple, let's just make it more up to date
with typical usage.

Closes gh-5108
2022-10-03 22:55:49 +02:00
Simon Legner
01819bc3bc
Docs: Update webpack website in README
Webpack has migrated to https://webpack.js.org/ since version 2.

Closes gh-5037
2022-07-12 17:16:24 +02:00
Michał Gołębiowski-Owczarek
fae5fee8b4
Tests: Exclude tests based on compilation flags, not API presence
Introduces a new test API, `includesModule`. The method returns whether
a particular module like "ajax" or "deprecated" is included in the current
jQuery build; it handles the slim build as well. The util was created so that
we don't treat presence of particular APIs to decide whether to run a test as
then if we accidentally remove an API, the tests would still not fail.

Fixes gh-5069
Closes gh-5046
2022-06-28 12:39:01 +02:00
Timmy Willison
b2bbaa36d4
Release: remove the need to install grunt globally 2021-03-01 18:16:04 -05:00
Timmy Willison
967af73203
Release: upgrade release dependencies
- Remove unused npm dependency
2021-03-01 18:15:21 -05:00
Michał Gołębiowski-Owczarek
8ae477a432
Build: Rename master to main across the repository
The default branch was updated, this updates the remaining occurrences in code
& comments.

Closes gh-4838
2021-02-05 22:00:56 +01:00
Michał Gołębiowski-Owczarek
a503c691dc
Build: Explicitly exclude the queue module from the slim build
The queue module is not present in the slim build as it depends on deferred
and our Gruntfile specifies excluding deferred should also exclude queue:
https://github.com/jquery/jquery/blob/3.5.1/Gruntfile.js#L66
This commit makes this exclusion explicit so that the queue module never
accidentally gets re-included in the slim build if it stopped importing from
the deferred module directly.

Closes gh-4793
2020-09-28 18:33:33 +02:00
Michał Gołębiowski-Owczarek
bfb6897c55
Release: Remove an unused chalk dependency
Chalk was used for a Sizzle version check that's no longer there on `master`.

Closes gh-4712
2020-05-18 22:45:04 +02:00
Michał Gołębiowski-Owczarek
ef4d6ca6c3
Build: Update eslint-config-jquery, fix linting violations
Closes gh-4696
Ref jquery/eslint-config-jquery#15
Ref jquery/eslint-config-jquery#16
2020-05-18 22:25:49 +02:00
Michał Gołębiowski-Owczarek
55cd3a4436
Build: Followups after introducing ES modules compiled via Rollup
This commit cleans up a few comments & configurations that are out of date
after the migration to ES modules backed by a Rollup-based compilation.

Also, de-indent AMD modules. This will preserve a more similar
structure to the one on 3.x-stable where the body of the main `define`
wrapper is not indented.

Closes gh-4705
2020-05-05 14:30:14 +02:00
Pierre Grimaud
1a7332ce83
Docs: Fix typos
Closes gh-4686
2020-04-29 21:18:23 +02:00