Skip to content

chore: run app directly with bun src/main.ts — eliminate nest build#3016

Draft
PooyaRaki wants to merge 18 commits into
mainfrom
chore/migrate-nest-to-bun-runtime
Draft

chore: run app directly with bun src/main.ts — eliminate nest build#3016
PooyaRaki wants to merge 18 commits into
mainfrom
chore/migrate-nest-to-bun-runtime

Conversation

@PooyaRaki

Copy link
Copy Markdown
Contributor

Summary

Eliminates the nest build && tsc-alias compilation step by running TypeScript directly with bun src/main.ts. This removes tsc-alias and tsconfig-paths as dependencies, simplifies the Dockerfile, and makes dev/prod startup identical.

Changes

  • Build scripts: build now only generates ABIs; start/start:dev/start:debug/start:prod all use bun src/main.ts directly; typeorm CLI points to .ts source instead of compiled .js
  • Removed dependencies: tsc-alias, tsconfig-paths
  • Dockerfile: production stage copies src/ and tsconfig*.json instead of dist/, runs bun src/main.ts
  • Type imports (~278 files): added explicit import type / inline type keywords required by Bun's per-file transpilation (like isolatedModules)
  • Circular dependency fixes (15 cycles):
    • Extracted @Module classes from 6 interface files into dedicated *.module.ts files
    • Extracted shared types (RedisClientType, FetchClient, JwtClient, QueueConsumer) from module files into *.types.ts files
    • Extracted EventType enum and signature constants to break schema/entity cycles
    • Added z.lazy() for Zod schema circular references
    • Inlined Parameters<> types in repository interfaces
  • TypeORM bidirectional entities: used import type + require() in decorator callbacks to prevent emitDecoratorMetadata TDZ errors in Bun's ESM
  • Swagger enum metadata: added explicit enum option to @ApiProperty() for enum-typed properties (Bun emits enum objects as design:type instead of String/Number)
  • Pre-existing fixes: removed unused FeeCost builder, fixed wallets.entity.db.builder property names (created_atcreatedAt)

Pooya Raki and others added 18 commits April 8, 2026 20:34
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix bullmq getJob() returning undefined instead of null
- Handle Express 5 params type (string | string[])
- Use jest as direct command to avoid Bun CJS/ESM issue

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
NestJS CLI's tsconfig-paths hook doesn't rewrite @/ imports when
nest build runs under Bun. Add tsc-alias as a post-build step and
copy tsconfig.json into the production Docker container.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Pin oven-sh/setup-bun to commit SHA for supply-chain security
- Pin tsc-alias to exact version (1.8.16) matching project convention
- Remove unnecessary tsconfig from production Docker stage
- Use bunx for nest CLI invocations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bunx checks global installs before local node_modules, which could
cause version mismatches. Using bare nest relies on bun run adding
node_modules/.bin to PATH, same as the jest script.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Single source of truth for the Bun version:
- CI reads from .bun-version via bun-version-file parameter
- Dockerfile uses ARG with default from .bun-version

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Extract @module classes from 6 interface files into dedicated module files
- Extract shared types (RedisClientType, FetchClient, JwtClient, QueueConsumer) from module files
- Extract EventType enum and signature constants to break schema/entity cycles
- Add z.lazy() for Zod schema circular references (wallet, notification-subscription)
- Inline Parameters<> types in repository interfaces to remove reverse deps

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use import type + require() for TypeORM bidirectional entity relations
  to prevent emitDecoratorMetadata TDZ errors in Bun's ESM
- Add explicit enum option to @ApiProperty() for enum-typed DTO properties
  because Bun emits enum objects as design:type metadata instead of String/Number
- Add z.lazy() to notification-type schema circular reference

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Base automatically changed from chore/migrate-node-to-bun to main April 9, 2026 09:42
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.

1 participant