Skip to content

Commit

Permalink
Build: replace grunt tasks with npm scripts
Browse files Browse the repository at this point in the history
Includes:

- **lint**: lint all code using new eslint flat config
- **build**: build using rollup, minify using uglify, process for dist
- **npmcopy**: copy some node module files to the external folder
- **start**: watch source files and rebuild on changes using rollup.watch

Also:
- Update the build function in the release script to use the new build
- Update CONTRIBUTING.md and README.md with new scripts
- Confirm the min file was identical to the main branch build, aside from the version update.
- Keep uglify-js at 3.9.4, which is the last version that officially
  supported the ie8 argument, which we need for ie9

Closes jquerygh-512
  • Loading branch information
timmywil committed Jun 4, 2024
1 parent 3f7103e commit 3a82e5d
Show file tree
Hide file tree
Showing 38 changed files with 1,013 additions and 2,217 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

32 changes: 0 additions & 32 deletions .eslintrc-browser.json

This file was deleted.

18 changes: 0 additions & 18 deletions .eslintrc-node.json

This file was deleted.

14 changes: 0 additions & 14 deletions .eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/browserstack-3.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ jobs:
- name: Install dependencies
run: npm install

- name: Build
run: npm run build
- name: Pretest script
run: npm run pretest

- name: Test
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/browserstack-git.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ jobs:
- name: Install dependencies
run: npm install

- name: Build
run: npm run build
- name: Pretest script
run: npm run pretest

- name: Test
run: |
Expand Down
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ CDN
/*.html
.DS_Store
.sizecache.json
.eslintcache

# Ignore everything in dist folder except for eslint config
/dist/*
!/dist/.eslintrc.json

/dist
/external
/node_modules

Expand Down
15 changes: 9 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ See: [jQuery Core Style Guide](http://docs.jquery.com/JQuery_Core_Style_Guidelin

To test the plugin you will need:

* Some kind of localhost server(any will do)
* Node.js
* NPM (comes with the latest version of Node.js)
* Grunt (install with: `npm install grunt -g`)


### Build a Local Copy of the plugin

Expand Down Expand Up @@ -108,13 +105,19 @@ Get in the habit of pulling in the "upstream" `main` branch to stay up to date a
$ git pull upstream main
```

Run the Grunt tools:
Run the build and rebuild when source files change:

```bash
$ npm start
```

In another terminal, run the test server:

```bash
$ grunt && grunt watch
$ npm run test:server
```

Now open the jQuery test suite in a browser at http://localhost/test. If there is a port, be sure to include it.
Now open the jQuery test suite in a browser at http://localhost:3000/test/.

Success! You just built and tested jQuery!

Expand Down
155 changes: 0 additions & 155 deletions Gruntfile.js

This file was deleted.

15 changes: 4 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,12 @@ Build and run tests:
====================================================

## Build with `npm` commands
```sh
$ git clone git://github.com/jquery/jquery-migrate.git
$ cd jquery-migrate
$ npm install
$ npm run build
```

## Build with [`grunt`](http://gruntjs.com/)

```sh
$ git clone git://github.com/jquery/jquery-migrate.git
$ cd jquery-migrate
$ npm install
$ npm install -g grunt-cli
$ grunt build
$ npm run build
```

### Run tests
Expand All @@ -115,5 +106,7 @@ $ npm test
### Or

```sh
$ grunt test
$ npm run test:server
```

and open http://localhost:3000/test/ in your browser.
21 changes: 7 additions & 14 deletions build/release.mjs → build/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* JQuery Migrate Plugin Release Management
*/

"use strict";

// Debugging variables
var dryrun = false,
skipRemote = false;
Expand All @@ -14,6 +12,7 @@ import child from "child_process";
import path from "path";
import chalk from "chalk";
import enquirer from "enquirer";
import { build } from "./tasks/build";

var releaseVersion,
nextVersion,
Expand All @@ -27,7 +26,6 @@ var releaseVersion,

// Windows needs the .cmd version but will find the non-.cmd
// On Windows, also ensure the HOME environment variable is set
gruntCmd = process.platform === "win32" ? "grunt.cmd" : "grunt",
npmCmd = process.platform === "win32" ? "npm.cmd" : "npm",

readmeFile = "README.md",
Expand All @@ -40,10 +38,10 @@ var releaseVersion,
steps(
initialize,
checkGitStatus,
gruntBuild,
buildRelease,
updateVersions,
tagReleaseVersion,
gruntBuild,
buildRelease,
makeReleaseCopies,
publishToNPM,
setNextVersion,
Expand All @@ -64,7 +62,7 @@ function initialize( next ) {

// -r skip remote mode, no remote commands are executed
// (git push, npm publish, cdn copy)
// Reset with `git reset --hard HEAD~2 && git tag -d (version) && grunt`
// Reset with `git reset --hard HEAD~2 && git tag -d (version) && npm run build`
if ( process.argv[ 2 ] === "-r" ) {
process.argv.shift();
skipRemote = true;
Expand Down Expand Up @@ -153,14 +151,9 @@ function updateVersions( next ) {
next();
}

function gruntBuild( next ) {
exec( gruntCmd, [], function( error, stdout, stderr ) {
if ( error ) {
die( error + stderr );
}
log( stdout || "(no output)" );
next();
} );
async function buildRelease( next ) {
await build( { version: releaseVersion } );
next();
}

function makeReleaseCopies( next ) {
Expand Down
Loading

0 comments on commit 3a82e5d

Please sign in to comment.