Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate most grunt tasks off of grunt #5318

Merged
merged 20 commits into from
Sep 18, 2023
Merged

Conversation

timmywil
Copy link
Member

@timmywil timmywil commented Sep 12, 2023

Summary

Migrates most grunt tasks to npm scripts.

While there are a lot of changes, the only change to the built jQuery file is the version string. See below for full details.

I've tried to mostly keep the commits to one per task, but there are some early commits migrating the lint task in steps and some later commits to combine certain tasks (i.e. build, minify, dist, and compare_size) and simplify them. Here are some important things to notes:

  • Added a new build command using yargs to parse command line arguments and provide a pretty help command.
  • minify and dist always run with a build.
  • With grunt npmcopy removed, I committed the package-lock.json. We could actually commit a yarn.lock as well if we want. npm now updates both.
  • The new watch task takes advantage of rollup's watcher directly. I've removed the copying functionality from the dist task, which now only fulfills its original purpose of making sure output is ascii-only and doesn't contain carriage returns. I think the copying was added very early on to copy builds to a dropbox folder to test things on jsfiddle. Fortunately, if that's still needed, the build command-and therefore the watch task-can write to any directory and multiple can be run at once.
  • I've written a simplified version of compare_size that now lives in the jQuery repo and has no non-node dependencies other than chalk for pretty terminal colors. It uses Node's zlib directly instead of gzip-js or another npm package. gzip-js hasn't been touched in years. Fortunately, zlib is easy-to-use. Sizes are a bit larger than before using the default options, but that should be okay as we're looking for comparisons, not completely accurate size predictions.
  • I've moved the tests that don't require karma off of grunt. This includes the promises tests and node smoke tests.
  • I removed the necessary grunt tasks all together in the last commit
  • As I mentioned in the meeting, I've temporarily disabled an eslint-plugin-import rule (no-unused-imports) until the plugin supports the new flat config format.
  • the authors task, to replace grunt-git-authors, is already migrated in another PR: Release: migrate release process to release-it #5306

Version string

The version string now includes a short SHA when the build is not a release build (e.g. 4.0.0-pre+SHA). Also, I made the version follow semver syntax. So, the slim version would now be 4.0.0+slim. In a non-release build, that would look like 4.0.0-pre+slim.SHA. Custom builds still add excluded/included modules to the version string (when not the slim build), but I didn't bother adding those in a way that follows semver syntax (e.g. 4.0.0-pre+a85a6aa2 -ajax,-ajax/binary,etc). I'd like to remove -pre as well, but that change has already been made in my release PR (#5306).

Checklist

TODO

  • I see that yargs throws an error on load in Node 10.x. I'll need to think on the best way to fix this. Should be good now. Turns out concurrently has yargs as a dependency. yargs requires Node >=12, so it can't be used in the pretest script on Node 10.

@timmywil timmywil force-pushed the grunt-migrate branch 4 times, most recently from 92eb540 to a85a6aa Compare September 12, 2023 16:11
mgol
mgol previously requested changes Sep 13, 2023
Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Publishing what I have so far. Tomorrow, I'll resume with commit 386acf4 (#5318)

@timmywil timmywil force-pushed the grunt-migrate branch 4 times, most recently from 802b344 to 11863e0 Compare September 14, 2023 02:46
@timmywil timmywil force-pushed the grunt-migrate branch 5 times, most recently from 8ffaa85 to 6d0e2f2 Compare September 15, 2023 03:22
@mgol mgol dismissed their stale review September 16, 2023 03:27

My remarks have been addressed

Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the whole thing now. Nice work! I like a lot of the simplifications.

I haven't had a chance to test it locally, I'll do that next.

@timmywil
Copy link
Member Author

timmywil commented Sep 16, 2023

I think I've covered all the remaining feedback. However, how would you feel about changing the name of build-all-variants to something shorter, like build:all? I've added a separate commit to the end to see what it would look like.

@timmywil timmywil force-pushed the grunt-migrate branch 4 times, most recently from 9576492 to 8c8e14f Compare September 16, 2023 22:44
@timmywil
Copy link
Member Author

I noticed an inconsistency between multiple compare_size runs and realized it's probably the version string varying by SHA. To fix it, compare_size now removes the banner for comparisons.

@mgol
Copy link
Member

mgol commented Sep 16, 2023

I think I've covered all the remaining feedback. However, how would you feel about changing the name of build-all-variants to something shorter, like build:all? I've added a separate commit to the end to see what it would look like.

Naming is hard. 🙂 I like build:all!


let contents = await fs.promises.readFile( filename, "utf8" );

// Remove the banner for size comparisons.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s not just the banner, the jquery property varies as well.

However, I don’t think we should remove it. It’s what’s in the file and that’s what is getting served to the users; we should take that into account.

@timmywil
Copy link
Member Author

timmywil commented Sep 18, 2023

Remaining feedback addressed. As soon as we merge this, I'll start preparing the 3.x PR. I had already made a 3.x branch, but I need to copy the changes made from PR feedback.

Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to test this locally but let's merge, any feedback for how things work we can address separately.

@timmywil timmywil merged commit 2bdecf8 into jquery:main Sep 18, 2023
@mgol mgol added this to the 4.0.0 milestone Sep 19, 2023
@mgol mgol added the Build label Sep 19, 2023
@timmywil timmywil deleted the grunt-migrate branch December 28, 2023 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants