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

Build: replace grunt tasks with npm scripts #512

Merged
merged 1 commit into from
Jun 10, 2024
Merged

Conversation

timmywil
Copy link
Member

@timmywil timmywil commented May 30, 2024

Includes:

  • lint: lint all code using new eslint flat config
  • build: build using rollup, minify using uglify, process for dist the same as core
  • 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 ironically we need for ie9
  • add schedules to browserstack workflows so they run once a week
  • update browserstack project name in the test runner to jquery-migrate (it had been overridden when copying test queue code over from jquery)

Sample BrowsersStack runs:

git: https://github.com/timmywil/jquery-migrate/actions/runs/9304840969
3.x: https://github.com/timmywil/jquery-migrate/actions/runs/9305649366

@timmywil timmywil requested a review from mgol May 30, 2024 14:14
@timmywil timmywil force-pushed the build branch 12 times, most recently from 12d03f5 to 84b4216 Compare May 31, 2024 14:37
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.

A few comments.

.github/workflows/browserstack-3.x.yml Outdated Show resolved Hide resolved
build/tasks/minify.js Outdated Show resolved Hide resolved
eslint.config.js Outdated Show resolved Hide resolved
eslint.config.js Outdated Show resolved Hide resolved
eslint.config.js Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
src/jquery/core.js Outdated Show resolved Hide resolved
test/unit/jquery/effects.js Show resolved Hide resolved
timmywil added a commit to timmywil/jquery-migrate that referenced this pull request Jun 4, 2024
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
timmywil added a commit to timmywil/jquery-migrate that referenced this pull request Jun 4, 2024
timmywil added a commit to timmywil/jquery-migrate that referenced this pull request Jun 4, 2024
timmywil added a commit to timmywil/jquery-migrate that referenced this pull request Jun 4, 2024
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
- update browserstack project name to jquery-migrate
- run browserstack at least once a week

Closes jquerygh-512
@timmywil timmywil requested a review from mgol June 5, 2024 13:40
build/tasks/minify.js Outdated Show resolved Hide resolved
Comment on lines 21 to 24
migratePatchFunc(
jQuery.fn,
"init",
function( arg1 ) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to avoid all this reformatting in this file. We don't use Prettier and any time we do major code style changes like that - especially ones modifying line numbers - it gets harder to look at history.

If something is a result of stricter ESLint then fine, but this looks excessive to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't really know of a better way to format this. I understand the concern about diffing, but I think the way Prettier formatted this is the way it should have been formatted from the beginning. And, doing it now makes it less likely we'll have to make more formatting changes in the future. It was ESLint that prompted this, but I prefer to let tools do the formatting as much as possible so that maintainers like us don't waste any time doing delicate dances to get the code to pass lint.

Copy link
Member

Choose a reason for hiding this comment

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

Well, there is also the current style. Right now, this PR splits the style as other files use what was here before; you'd have to reformat everything to make it consistent again.

What exactly in ESLint triggered these changes?

I prefer to let tools do the formatting as much as possible so that maintainers like us don't waste any time doing delicate dances to get the code to pass lint

I have a more nuanced view on this. I do use formatters a lot - and usually it's Prettier as well - as it helps with avoiding some discussions, especially in large teams. But integrating such a tool doesn't mean you stop having formatting changes, unfortunately. Prettier's GitHub has many discussions about how to best format various code constructs and they change things from time to time. In my experience, having Prettier in a project means that you periodically need to update it & then reformat a huge percentage of files, creating huge diffs and obstructing the Git history. In larger teams & projects I believe it's still worth it but I have doubts about jQuery with just a few regular committers and quite rare source changes. In some files, we'd end up with the only modifications being occasional Prettier runs.

One option is to employ usage of https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view, although I expect it's not perfect and won't erase all the noise.

As for the current Migrate style as it's on main, I actually like it as the following:

migratePatchFunc( jQuery.fn, "init", function( arg1 ) {
	/* code */
}, "selector-empty-id" );

is quite similar visually to:

jQuery.fn.init = function( arg1 ) {
	/* code */
};

which is mostly what happens, modulo the migratePatchFunc wrapper that is needed for being able to selectively disable patches.

Copy link
Member Author

Choose a reason for hiding this comment

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

The first is what was failing. FWIW, I disagree on which is better. In the first example, it's easy to overlook that last argument after the function, especially when the function has enough lines. Putting each argument on its own line is the clearest way to prevent that. And, there are several cases in this file where there are 2 string arguments after the function, exacerbating the problem.

But, if you're adamant, we can avoid changing the whole file. This all started because you preferred to not change the indentation in the one of the functions that was inconsistent with the others, but had a ternary return that made it look awkward to be consistent. A possible solution for that is to do what was done elsewhere and start the function declaration on the next line. See the latest.

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
- update browserstack project name to jquery-migrate
- run browserstack at least once a week

Closes jquerygh-512
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.

Thanks, that looks less noisy, LGTM.

As for the code style itself, I could be convinced what's better in either direction but I tend to skew towards trying to avoid changing the existing style too much, at least as long as we don't employ automatic tooling that totally enforces that.

But that would have its own drawbacks in the context of jQuery projects as I mentioned in one of my comments. And I don't currently have a good answer for that.

@timmywil timmywil merged commit 6e7127e into jquery:main Jun 10, 2024
10 checks passed
@timmywil timmywil deleted the build branch June 10, 2024 13:00
mgol added a commit to mgol/jquery-migrate that referenced this pull request Jul 8, 2024
Git hooks are broken since jquerygh-512; this change fixes them by migrating to Husky
as jQuery Core did.

Without this fix, even `git commit --no-verify` doesn't work; only manually
deleting the `.git/hooks` directory and re-running `git commit` does.

Ref jquerygh-512
@mgol mgol mentioned this pull request Jul 8, 2024
mgol added a commit that referenced this pull request Jul 9, 2024
Git hooks are broken since gh-512; this change fixes them by migrating to Husky
as jQuery Core did.

Without this fix, even `git commit --no-verify` doesn't work; only manually
deleting the `.git/hooks` directory and re-running `git commit` does.

Ref gh-512
Closes gh-516
mgol added a commit to mgol/jquery-migrate that referenced this pull request Jul 15, 2024
PR jquerygh-512 added the `"type": "module"` field to the top-level `package.json`,
making Node-based workflows fail when trying to require Migrate as it's not
exposed as ESM. To fix this, add a small `package.json` with just
`"type": "commonjs"`. Also, add Node.js smoke tests as the simplest way to
verify this change.

Fixes jquerygh-523
Ref jquerygh-512
mgol added a commit to mgol/jquery-migrate that referenced this pull request Jul 15, 2024
PR jquerygh-512 added the `"type": "module"` field to the top-level `package.json`,
making Node-based workflows fail when trying to require Migrate as it's not
exposed as ESM. To fix this, add a small `package.json` with just
`"type": "commonjs"`. Also, add Node.js smoke tests as the simplest way to
verify this change.

Fixes jquerygh-523
Ref jquerygh-512
mgol added a commit that referenced this pull request Jul 16, 2024
PR gh-512 added the `"type": "module"` field to the top-level `package.json`,
making Node-based workflows fail when trying to require Migrate as it's not
exposed as ESM. To fix this, add a small `package.json` with just
`"type": "commonjs"`. Also, add Node.js smoke tests as the simplest way to
verify this change.

Fixes gh-523
Closes gh-525
Ref gh-512
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants