fix(build): nest build 출력을 dist 루트로 정렬 (dist/main.js)#128
Conversation
tsconfig.build.json 에 include: ["src/**/*"] 추가. 기존엔 include 부재로 tsc 가 src+scripts+prisma 전체를 컴파일 → 공통 루트가 프로젝트 루트가 되어 dist/src/main.js 로 출력됐고, ecosystem.config.js(script: dist/main.js)·start:prod(node dist/main) 와 불일치해 PM2 부팅 실패가 잠복(자동배포 비활성으로 미발견). src 만 컴파일하도록 제한 → dist/main.js 로 출력. nest-cli 에셋(dist/features/) 및 실행 경로와 정합. 부팅 테스트로 모듈해석·DI 정상 확인(DB 연결 단계 도달).
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c43b5baa4a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -1,4 +1,5 @@ | |||
| { | |||
| "extends": "./tsconfig.json", | |||
| "include": ["src/**/*"], | |||
There was a problem hiding this comment.
Add alias resolution for the relocated entrypoint
When production starts the newly generated dist/main.js via node dist/main or PM2's dist/main.js, the emitted file still contains imports like @/app.module from src/main.ts; TypeScript paths only affects type resolution and does not rewrite those module specifiers. Since the runtime commands do not preload tsconfig-paths/register or run an alias-rewrite step, this change gets past the previous missing-file error but then crashes with Cannot find module '@/app.module' before the app boots.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
false positive. dist/**/*.js에 @/ specifier 0개 — nest build가 전부 상대경로(require("./app.module"))로 emit함. NODE_ENV=production node dist/main 부팅 시 InstanceLoader까지 진입(모듈 전부 로드 성공), DOCS_ACCESS_TOKEN env 가드에서 멈춤. Cannot find module 미발생.
Coverage report
Test suite run success1254 tests passing in 146 suites. Report generated by 🧪jest coverage report action from c43b5ba |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
nest build산출물 경로 불일치로 인한 **운영 부팅 실패(잠복 결함)**를 고칩니다.tsconfig.build.json에include가 없어 tsc 가src+scripts+prisma를 모두 컴파일 → 공통 루트가 프로젝트 루트가 되어 진입점이dist/src/main.js로 출력됐습니다. 반면ecosystem.config.js(script: 'dist/main.js')와package.json(start:prod: "node dist/main")은dist/main.js를 기대 → PM2/start 가 모듈을 못 찾아 부팅 실패. 자동 배포가 비활성(workflow_dispatch)이라 그동안 드러나지 않았습니다.릴리즈 영향 점검 중 발견했습니다 (
docs_*_develop-to-main-release-impact.md). 이 상태로 배포하면 PM2 start 단계에서 깨집니다.Scope
변경:
tsconfig.build.json"include": ["src/**/*"]추가 → 빌드가src만 컴파일, rootDir 이src로 잡혀dist/main.js로 출력dist/features/**/*.graphql) 및 실행 경로(ecosystem/start:prod)와 정합. ecosystem/start 스크립트는 변경 불필요(원래 기대 경로가 맞았음)진행 상황
P2 완료 (fix(audit): client IP trust-proxy 정합 + 감사 로그 IP 배선 (ALS 요청 컨텍스트) #124refactor(lint): cross-feature 내부 import 금지 (boundaries) + barrel 경유 정리 (P2-3) #127)TRUST_PROXY_HOPS+ 인프라 기동 확인 후)Impact
dist/main.js로 출력 (이전dist/src/main.js).dist/src/·dist/scripts/·dist/prisma/(루트 prisma 디렉터리 산출물) 등 불필요 산출물 제거 → 번들 정리.script: dist/main.js부팅 정상화. 이 수정 없이는 배포 시 부팅 실패.Test plan
yarn build→dist/main.js생성 확인,dist/src/부재 확인,dist/features/*.graphql에셋 유지node dist/main.js가 전체 모듈 그래프·DI 해석 후 DB 연결 단계까지 도달 (Cannot find module/Nest can't resolve없음). DB 미연결 에러만 발생 = 코드/경로 정상require("./...")) 가 새 루트에서 정합