Skip to content

chore: remove ava require:ts-node/register for ava 8 ESM compatibility#460

Open
macminisupport wants to merge 11 commits into
developfrom
claude/peaceful-brown-6r06k9
Open

chore: remove ava require:ts-node/register for ava 8 ESM compatibility#460
macminisupport wants to merge 11 commits into
developfrom
claude/peaceful-brown-6r06k9

Conversation

@macminisupport

Copy link
Copy Markdown
Collaborator

Summary

Removes "require": ["ts-node/register"] from the ava config in functions/package.json.

Why: ava 8 is fully ESM internally and loads test workers via import(). The old require config key is no longer valid — ava resolves it as a relative file path instead of a node_modules specifier, causing:

Error: Cannot find module '.../functions/ts-node/register'
       imported from .../node_modules/ava/lib/worker/base.js

The --loader=ts-node/esm entry in nodeArguments already handles TypeScript transpilation for ESM. The require entry 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

  • CI passes (build + test with Firestore emulator)

🤖 Generated with Claude Code


Generated by Claude Code

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).
macminisupport and others added 10 commits June 26, 2026 03:11
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
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