Skip to content

chore(server): switch jest transform to @swc/jest#2948

Merged
enoch85 merged 5 commits into
developmentfrom
fix/issue-2946-swc-jest
May 21, 2026
Merged

chore(server): switch jest transform to @swc/jest#2948
enoch85 merged 5 commits into
developmentfrom
fix/issue-2946-swc-jest

Conversation

@enoch85

@enoch85 enoch85 commented May 20, 2026

Copy link
Copy Markdown
Collaborator

Closes #2946.

Replaces the server's ts-jest transform with @swc/jest (transpile-only). The server suite drops from ~66s to ~13s and workers exit cleanly — the intermittent "A worker process has failed to exit gracefully" warning is gone (it was slow ts-jest worker teardown under load, not a real handle leak).

SWC's stricter CommonJS live-binding exports turn the existing circular dependencies into TDZ ReferenceErrors at module load, so this also makes those cycles SWC-safe with no runtime change:

  • TypeORM relation property types wrapped in Relation<> (TypeORM's documented fix) so design:type no longer eagerly references the related entity.
  • forwardRef-injected constructor params annotated via type-only import aliases so design:paramtypes doesn't eagerly reference the class; the value import remains for the forwardRef arrow.
  • The media-server factory's three adapter injections gain explicit @Inject(forwardRef(...)) (matching the two sibling params) so their types can be aliased too.

DI tokens/wiring are unchanged. Type-checking still runs via nest build in CI. The only behavioural change is to the test transformer.

Note: this adds @Inject(forwardRef(...)) to the factory's adapter params — worth a quick boot smoke-test of the running server in addition to the green unit suite, since unit tests mock DI.

…eps SWC-safe

ts-jest kept a full TypeScript program per worker, so workers were slow to
tear down under CI load and intermittently logged "A worker process has
failed to exit gracefully". @swc/jest is transpile-only: the server suite
drops from ~66s to ~13s and workers exit cleanly with no warning.

SWC's stricter CommonJS live-binding exports turn the codebase's existing
circular dependencies into TDZ ReferenceErrors at module load, so this makes
those cycles SWC-safe without changing runtime behaviour:

- Wrap singular concrete TypeORM relation property types in `Relation<>` so
  emitted `design:type` metadata no longer eagerly references the related
  entity class.
- Annotate forwardRef-injected constructor params with type-only import
  aliases so `design:paramtypes` doesn't eagerly reference the class; the
  value import stays for the forwardRef arrow. DI tokens are unchanged.
- Give the media-server factory's three adapter injections explicit
  `@Inject(forwardRef(...))` (matching the sibling params) so their types
  can be aliased as well.

Closes #2946
@enoch85 enoch85 requested a review from SmolSoftBoi May 20, 2026 21:28
@enoch85

enoch85 commented May 20, 2026

Copy link
Copy Markdown
Collaborator Author

@SmolSoftBoi Does this make sense? Ran into this several times already. Tests that times out, going slow and whatnot - after this they are not.

Please look through it here, and tell me what you think. 👍

@enoch85 enoch85 merged commit ab79401 into development May 21, 2026
13 checks passed
@enoch85 enoch85 deleted the fix/issue-2946-swc-jest branch May 21, 2026 15:42
@enoch85

enoch85 commented May 21, 2026

Copy link
Copy Markdown
Collaborator Author

@SmolSoftBoi Decided to merge, it's a good improvement, and I will follow up with a larger PR refactor later.

@maintainerr-automation

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.12.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@enoch85 enoch85 added this to the 3.12.1 milestone May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overhaul server circular dependencies (unblocks faster @swc/jest test transform)

1 participant