Skip to content

Conversation

ItsHarper
Copy link
Contributor

@ItsHarper ItsHarper commented Aug 14, 2025

Context

Step 2 for #928. View isolated diff and CI results here: ItsHarper#5

At time of writing, the isolated diff has +37, -57 lines added/removed.

This change is ready-to-go, but I'm marking it as a draft until #929 has been merged, as it is relatively difficult to review in this context until that happens.

Problem

While jest is set up to run a package and its tests without needing a full build step, it will use the last-built version of the other packages for its dependencies, so we're not actually guaranteed to be testing the all of the latest code unless we build all of a package's local dependencies before we start testing it. The same goes for the codemod-dev shell script.

This problem doesn't exist when using tsc, because there are references set up in each package's tsconfig.json file. Unfortunately, esbuild doesn't respect that as far as I can tell, so the issue does exist when running the tests or codemod-dev (see evanw/esbuild#1250 for the only discussion I found of this discrepancy between esbuild and tsc).

Solution

For the tests, I've added a top-level check script that builds the whole project and then runs all test and lint scripts from the packages in parallel. CI has been updated to use this instead of building, linting, and testing each package individually, and I would

I've replaced codemod-dev with a new top-level cli pnpm script that runs a build and then executes the resulting JS.

The test:watch scripts have been removed, as a watch mode that tests without ensuring the local dependencies are -up-to-date is not reliable. If they're deemed important enough, I can look into re-running the tests when the built files changed (combined with tsc --watch, that should be the complete picture).

I don't think any local packages are getting injected, but I added syncInjectedDepsAfterScripts: [ 'build' ] to pnpm-workspace.yaml to be safe.

Performance of local execution and tests

Always running the build step before running tests or the CLI obviously will involve a performance hit, and it seems like you at least used to care a lot about that. However, while a repeat build with no changes made takes about 2.4 seconds on my computer for this PR, that's reduced to just 1.8 seconds in #931 (which updates Typescript but makes no configuration changes), and about 650ms in #932.

The build should then get about 10x faster than that when Typescript 7 lands (which is written in go and takes advantage of multithreading). This should be a nearly a non-issue in practice, especially long-term (I'd expect Typescript 7 to be released within the next year, based on my perception of the speed of their progress).

Especially now that development has slowed so much on this project, prioritizing simplicity and correctness over dev-time performance seems like the right choice to me anyway.

@ItsHarper ItsHarper mentioned this pull request Aug 14, 2025
9 tasks
@ItsHarper ItsHarper force-pushed the test/ensure-up-to-date-deps branch from 0f8ebbd to 278b751 Compare August 14, 2025 21:17
While jest can run a package and its tests without needing a full build
step, it will use the last-built version of the other packages for its
dependencies, so we're not actually guaranteed to be testing the latest
state unless we build all of a package's local dependencies before we
start testing it.

The `test:watch` scripts have been removed, as a watch mode that tests
without building the dependencies is not reliable.

I don't think any local packages are getting injected, but I added
`syncInjectedDepsAfterScripts` to `pnpm-workspace.yaml` to be safe.

Since we're running tests in parallel, individual tests run slower, so
I had to increase some timeouts.
Replaces `codemod-dev` shell script with a new `cli` pnpm script in
the top-level package
@ItsHarper ItsHarper force-pushed the test/ensure-up-to-date-deps branch from 278b751 to 1c790db Compare August 15, 2025 05:04
@ItsHarper ItsHarper changed the title test: ensure local dependencies are up-to-date Ensure local dependencies are up-to-date for tests and local execution Aug 15, 2025
@ItsHarper ItsHarper changed the title Ensure local dependencies are up-to-date for tests and local execution Ensure local deps are up-to-date when testing and running locally Aug 15, 2025
@ItsHarper ItsHarper changed the title Ensure local deps are up-to-date when testing and running locally Ensure local deps are up-to-date when testing or running the CLI locally Aug 15, 2025
@eventualbuddha
Copy link
Collaborator

Is there anything that needs to happen before this is reviewable?

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