Skip to content

Conversation

serhalp
Copy link
Member

@serhalp serhalp commented Feb 27, 2025

📣 You should probably review this commit by commit!

2593f33 Remove postinstall hook that builds the package

  • It's nonstandard
  • It's surprising
  • Since we use tsc to build, it causes every CI check to fail if you have type errors
  • It causes issues when rewriting git history
  • It's a bit magical

I refactored an affected script in a separate commit first (be729a2), for easier review.

b57d815 Simplify site build scripts

There were two separate scripts for doing the same thing for some reason. I ran into this oddity while making the above change.

5c3f767 Remove leftover refs to ava

ava was removed a couple years ago

f4119f8 Rename misleading CI jobs

They handle two kinds of benchmarks, only one of which is package size

bf2bfa2 Split formating, linting, and unit testing

  • They were all jumbled together 😢
  • CI wouldn't run unit tests if you had a prettier or eslint error
  • The scripts were nonstandard and surprising
  • The scripts were unnecessarily complicated
  • CI was running formatting and linting on Windows, macOS, and Linux for no reason

846d1c4 Simplify CI workflow skipping for release branches

You can just skip the whole job instead of skipping every step!

7169000 chore(package.json): sort scripts

:feelsgood: This one is dedicated to @ndhoule. Keep fighting the good fight ✌🏼.

ec2e860 Add missing dependency on npm-run-all

We're using run-s which comes from this dep but it only happens to work because one of
our dependencies has a transitive dependency on npm-run-all.

IMO we should kill this, but for now this just adds the missing dep.

Note: npm-run-all2 is a maintained fork of the unmaintained npm-run-all

Copy link

github-actions bot commented Feb 27, 2025

📊 Benchmark results

Comparing with fb36998

  • Dependency count: 1,206 (no change)
  • Package size: 293 MB (no change)
  • Number of ts-expect-error directives: 729 (no change)

package.json Outdated
"site:build": "run-s site:build:*",
"site:build:install": "cd site && npm install --no-audit",
"site:build:assets": "cd site && npm run build",
"postinstall-pack": "node ./scripts/postinstall.js",
Copy link
Member Author

Choose a reason for hiding this comment

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

This postinstall-pack hook gets renamed to postinstall in a script triggered from the prepublishOnly hook, so that when users install this package they see some output we want them to see at install time.

"site:build:install": "cd site && npm install --no-audit",
"site:build:assets": "cd site && npm run build",
"postinstall-pack": "node ./scripts/postinstall.js",
"postinstall": "npm run build && node ./scripts/postinstall.js",
Copy link
Member Author

Choose a reason for hiding this comment

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

See comment above – we were also triggering this when running npm i in this repo when developing in this repo, but that seems unnecessary so I didn't bother preserving it.

Copy link
Member Author

Choose a reason for hiding this comment

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

... In fact this may be why we had the preinstall build step in the first place... so that this script can run (it uses some npm deps).

@serhalp serhalp force-pushed the chore/remove-postinstall-hook branch 2 times, most recently from 06768a9 to b914412 Compare February 27, 2025 18:29
There were two separate scripts for doing the same thing.
@serhalp serhalp force-pushed the chore/remove-postinstall-hook branch from b914412 to da1f74b Compare February 27, 2025 18:51
```

### Attaching a Debugger

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, my editor reformatted this. I can revert it if the reviewer cares.

CONTRIBUTING.md Outdated
Comment on lines 36 to 35
npm install && npm run site:build:install
npm install
Copy link
Member Author

Choose a reason for hiding this comment

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

This being mentioned here didn't make any sense so I removed it (there's a section below about the docs site)

package.json Outdated
"test:ci:vitest:integration": "vitest run --coverage tests/integration/",
"e2e": "node ./tools/e2e/run.js",
"docs": "npm run --prefix=site build",
"site:build": "npm run build && npm install --prefix=site --no-audit && npm run --prefix=site build",
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 love the npm install inside a script but that's a whole can of worms that didn't seem worth pursuing

No behavioural changes in this commit.
- It's nonstandard
- It's surprising
- Since we use `tsc` to build, it causes every CI check to fail if you have type errors
- It causes issues when rewriting git history
- It's a bit magical
ava was removed a couple years ago
They handle two kinds of benchmarks, only one of which is package size
@serhalp serhalp force-pushed the chore/remove-postinstall-hook branch from da1f74b to 946bd2d Compare February 27, 2025 19:38
@serhalp serhalp changed the title chore: remove bizarre postinstall hook that builds chore: simplify and standardize package.json scripts and CI setup Feb 27, 2025
We're using `run-s` which comes from this dep but it only happens to work because one of
our dependencies has a transitive dependency on `npm-run-all`.

IMO we should kill this, but for now this just adds the missing dep.

Note: npm-run-all2 is a maintained fork of the unmaintained npm-run-all
@serhalp serhalp force-pushed the chore/remove-postinstall-hook branch from 946bd2d to ec2e860 Compare February 27, 2025 19:48
@serhalp serhalp marked this pull request as ready for review February 27, 2025 19:48
@serhalp serhalp requested a review from a team as a code owner February 27, 2025 19:48
"test": "run-s format test:dev",
"format": "run-s format:check-fix:*",
"format:ci": "run-s format:check:*",
"format:check-fix:lint": "run-s format:check:lint format:fix:lint",
Copy link
Member Author

Choose a reason for hiding this comment

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

bonus win: this was running eslint twice... fixing also checks, so it was redundant!

"format:check-fix:lint": "run-s format:check:lint format:fix:lint",
"format:check:lint": "cross-env-shell eslint $npm_package_config_eslint",
"format:fix:lint": "cross-env-shell eslint --fix $npm_package_config_eslint",
"format:check-fix:prettier": "run-s format:check:prettier format:fix:prettier",
Copy link
Member Author

Choose a reason for hiding this comment

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

same for prettier

Copy link
Contributor

@ndhoule ndhoule left a comment

Choose a reason for hiding this comment

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

clapping_futurama

@serhalp serhalp enabled auto-merge (squash) February 27, 2025 22:54
@serhalp serhalp merged commit 94cb80a into main Feb 28, 2025
49 checks passed
@serhalp serhalp deleted the chore/remove-postinstall-hook branch February 28, 2025 11:42
@serhalp serhalp mentioned this pull request Feb 28, 2025
ndhoule added a commit that referenced this pull request Mar 4, 2025
ndhoule added a commit that referenced this pull request Mar 4, 2025
ndhoule added a commit that referenced this pull request Mar 4, 2025
ndhoule added a commit that referenced this pull request Mar 20, 2025
The CLI currently runs `npm run build` in a post-install script. Many
of commands in the CLI implicitly depend on this behavior, which is
unnecessarily complicated. This post-install script conflicts with the
user-facing post-install script, which means we need to do a little pre-
publish post-install script juggling to ensure that the end user runs
the correct script after installing the CLI.

This change removes the post-install script in favor of explicitly
building the CLI before e.g. CI steps that require a built CLI.

Partial un-reversion of #7069, which
was reverted in #7085.
ndhoule added a commit that referenced this pull request Mar 20, 2025
The CLI currently runs `npm run build` in a post-install script. Many
of commands in the CLI implicitly depend on this behavior, which is
unnecessarily complicated. This post-install script conflicts with the
user-facing post-install script, which means we need to do a little pre-
publish post-install script juggling to ensure that the end user runs
the correct script after installing the CLI.

This change removes the post-install script in favor of explicitly
building the CLI before e.g. CI steps that require a built CLI.

Partial un-reversion of #7069, which
was reverted in #7085.
ndhoule added a commit that referenced this pull request Mar 20, 2025
The CLI currently runs `npm run build` in a post-install script. Many
of commands in the CLI implicitly depend on this behavior, which is
unnecessarily complicated. This post-install script conflicts with the
user-facing post-install script, which means we need to do a little pre-
publish post-install script juggling to ensure that the end user runs
the correct script after installing the CLI.

This change removes the post-install script in favor of explicitly
building the CLI before e.g. CI steps that require a built CLI.

Partial un-reversion of #7069, which
was reverted in #7085.
ndhoule added a commit that referenced this pull request Mar 21, 2025
The CLI currently runs `npm run build` in a post-install script. Many
of commands in the CLI implicitly depend on this behavior, which is
unnecessarily complicated. This post-install script conflicts with the
user-facing post-install script, which means we need to do a little pre-
publish post-install script juggling to ensure that the end user runs
the correct script after installing the CLI.

This change removes the post-install script in favor of explicitly
building the CLI before e.g. CI steps that require a built CLI.

Partial un-reversion of #7069, which
was reverted in #7085.
ndhoule added a commit that referenced this pull request Mar 21, 2025
The CLI currently runs `npm run build` in a post-install script. Many
of commands in the CLI implicitly depend on this behavior, which is
unnecessarily complicated. This post-install script conflicts with the
user-facing post-install script, which means we need to do a little pre-
publish post-install script juggling to ensure that the end user runs
the correct script after installing the CLI.

This change removes the post-install script in favor of explicitly
building the CLI before e.g. CI steps that require a built CLI.

Partial un-reversion of #7069, which
was reverted in #7085.
ndhoule added a commit that referenced this pull request Mar 21, 2025
The CLI currently runs `npm run build` in a post-install script. Many
of commands in the CLI implicitly depend on this behavior, which is
unnecessarily complicated. This post-install script conflicts with the
user-facing post-install script, which means we need to do a little pre-
publish post-install script juggling to ensure that the end user runs
the correct script after installing the CLI.

This change removes the post-install script in favor of explicitly
building the CLI before e.g. CI steps that require a built CLI.

Partial un-reversion of #7069, which
was reverted in #7085.
ndhoule added a commit that referenced this pull request Mar 21, 2025
The CLI currently runs `npm run build` in a post-install script. Many
of commands in the CLI implicitly depend on this behavior, which is
unnecessarily complicated. This post-install script conflicts with the
user-facing post-install script, which means we need to do a little pre-
publish post-install script juggling to ensure that the end user runs
the correct script after installing the CLI.

This change removes the post-install script in favor of explicitly
building the CLI before e.g. CI steps that require a built CLI.

Partial un-reversion of #7069, which
was reverted in #7085.
ndhoule added a commit that referenced this pull request Mar 21, 2025
The CLI currently runs `npm run build` in a post-install script. Many
of commands in the CLI implicitly depend on this behavior, which is
unnecessarily complicated. This post-install script conflicts with the
user-facing post-install script, which means we need to do a little pre-
publish post-install script juggling to ensure that the end user runs
the correct script after installing the CLI.

This change removes the post-install script in favor of explicitly
building the CLI before e.g. CI steps that require a built CLI.

Partial un-reversion of #7069, which
was reverted in #7085.
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