Skip to content

fix(build): substituir tsc-alias por tsup para resolver ESM no Node.js#18

Merged
diego64 merged 1 commit into
mainfrom
fix/esm-extensoes-node
Jun 7, 2026
Merged

fix(build): substituir tsc-alias por tsup para resolver ESM no Node.js#18
diego64 merged 1 commit into
mainfrom
fix/esm-extensoes-node

Conversation

@diego64

@diego64 diego64 commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace tsc && tsc-alias with tsup as the build tool
  • tsup bundles the entry point (src/infra/http/servidor.ts) into dist/servidor.js, resolving @/ path aliases via tsconfig paths and emitting valid ESM with correct extensions
  • Update start script from node dist/infra/http/servidor.js to node dist/servidor.js

Root cause (two-step failure)

  1. First error: Cannot find package '@/infra'tsc emits @/ aliases unchanged; Node.js ESM interprets @/ as a scoped npm package
  2. This error: Cannot find module '.../dist/infra/http/aplicacao'tsc-alias rewrote aliases to relative paths but without .js extensions; Node.js ESM strict mode requires explicit extensions

Both failures share the same root cause: tsc with moduleResolution: "Bundler" is designed for bundlers (Vite, webpack, esbuild), not direct Node.js execution. tsup (esbuild-based) is the correct tool for this output target.

Output

ESM dist/servidor.js     65.84 KB
ESM dist/servidor.js.map 137.89 KB
Build success in 91ms

Test plan

  • pnpm build — confirm dist/servidor.js is generated with no @/ aliases and no extensionless relative imports
  • pnpm typecheck && pnpm test — all 359 tests passing
  • Render deploy — server starts without ERR_MODULE_NOT_FOUND

🤖 Generated with Claude Code

O Node.js ESM exige extensoes .js explicitas nos imports, mas o tsc com
moduleResolution Bundler emite imports sem extensao. tsc-alias resolvia
os aliases @/ mas nao adicionava extensoes, causando ERR_MODULE_NOT_FOUND.

Substitui por tsup que bundla o entry point resolvendo aliases via tsconfig
paths e emitindo ESM valido para Node.js. Output: dist/servidor.js (65 KB).
Atualiza start para node dist/servidor.js.
@diego64 diego64 merged commit 1ee38b7 into main Jun 7, 2026
@diego64 diego64 deleted the fix/esm-extensoes-node branch June 7, 2026 01:36
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