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 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
  • Loading branch information
timmywil committed May 30, 2024
1 parent b6648af commit a66c95b
Show file tree
Hide file tree
Showing 36 changed files with 938 additions and 2,120 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.

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
3 changes: 3 additions & 0 deletions build/tasks/build-default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { build } from "./build.js";

build();
3 changes: 3 additions & 0 deletions build/tasks/build-watch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { build } from "./build.js";

build( { watch: true } );
Loading

0 comments on commit a66c95b

Please sign in to comment.