chore: remove ava require:ts-node/register for ava 8 ESM compatibility#460
Open
macminisupport wants to merge 11 commits into
Open
chore: remove ava require:ts-node/register for ava 8 ESM compatibility#460macminisupport wants to merge 11 commits into
macminisupport wants to merge 11 commits into
Conversation
ava 8 loads test workers via ESM import() and no longer supports the `require` config key for module resolution. The --loader=ts-node/esm nodeArgument already handles TypeScript transpilation for ESM. This unblocks Dependabot PR #441 (ava 7→8).
3 tasks
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Start from Dependabot's ava 8 lockfile resolution, overlay develop's newer packages (sinon 22, typescript 6, prettier 3.8.4, tar 7.5.16, @firebase/rules-unit-testing 5.0.1, etc.) and add cbor/nofilter from develop. Keeps ava 8's new deps (@cto.af/wtf8, cbor2, cli-truncate 6, emittery 2, memoize 11, slice-ansi 9). This matches package.json which already has ava ^8.0.1 on this branch.
Properly merges the Dependabot ava 8 lockfile resolution with develop's newer packages. Strategy: start from Dependabot's ava 8 resolution base, overlay develop's newer entries (sinon 22, typescript 6, prettier 3.8.4, tar 7.5.16, @firebase/rules-unit-testing 5.0.1, class-validator 0.15.1, firebase-functions-test 3.5.0, google-gax 5.0.7, hasown 2.0.4). Keeps ava 8's new required packages: @cto.af/wtf8, cbor2, cli-truncate@6, emittery@2, memoize@11, slice-ansi@9. Adds cbor/nofilter from develop. Fixes npm ci EUSAGE: lock file's ava@7 does not satisfy ava@8 error. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
nyc uses append-transform/default-require-extensions CJS require hooks that fail with ava 8's ESM worker loading: ERR_REQUIRE_CYCLE_MODULE: Cannot require() ES Module [...].test.ts in a cycle c8 uses Node.js V8 native coverage (--v8-coverage) and works with ESM out of the box. It's a drop-in replacement for nyc: nyc --reporter html --reporter text ava → c8 --reporter=html --reporter=text ava Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Node 22.20+ introduced strict ERR_REQUIRE_CYCLE_MODULE detection that fires when the deprecated --loader=ts-node/esm API tries to require() a module already in the ESM loading graph. tsx uses Node's modern module.register() API (--import flag) which avoids this cycle entirely. tsx is also lighter weight than ts-node and has first-class ESM support with no special configuration needed. Also removes ts-node from nodeArguments (kept as dev dep for tslint interop); @ava/typescript stays but is not configured as a provider since tsx handles TypeScript compilation directly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… imports Replace tsx --import ESM hook approach with @ava/typescript compile+rewrite strategy. tsc compiles src/ and __tests__/ to lib_test/ (rootDir: "."), then ava loads compiled CJS files via Node's standard require resolution, which handles extensionless imports correctly without needing ESM hooks. - tsconfig.json: test config (rootDir: ".", outDir: lib_test, include src+__tests__) - tsconfig.build.json: production build config (original tsconfig.json) - build script now uses tsconfig.build.json - ava config: typescript.compile + rewritePaths instead of tsx nodeArguments - remove tsx devDependency (no longer needed) - add lib_test/ to .gitignore Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Krt2bEr8y3RnBiG8c5DvW1
Test files were never previously type-checked and pass string | undefined values where string | null is expected. The production build config (tsconfig.build.json) retains strictNullChecks: true. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Krt2bEr8y3RnBiG8c5DvW1
Test files and some src files have implicit any violations that were never previously caught (ava used ts-node transpile-only, not tsc). Override strict mode's noImplicitAny for the test compilation config. Production tsconfig.build.json is unaffected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Krt2bEr8y3RnBiG8c5DvW1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes
"require": ["ts-node/register"]from the ava config infunctions/package.json.Why: ava 8 is fully ESM internally and loads test workers via
import(). The oldrequireconfig key is no longer valid — ava resolves it as a relative file path instead of anode_modulesspecifier, causing:The
--loader=ts-node/esmentry innodeArgumentsalready handles TypeScript transpilation for ESM. Therequireentry is redundant and incompatible with ava 8.Impact: Unblocks Dependabot PR #441 (ava 7→8). Once this merges to
develop, Dependabot can cleanly rebase #441 and CI will pass.Test plan
🤖 Generated with Claude Code
Generated by Claude Code