post(blog): package.json exports 진입점 설계 포스트 추가 (#56) - #138
Merged
Conversation
- main의 한계(내부 파일 노출)와 exports의 옵트인 캡슐화 대비 - import/require/types 조건부 진입점과 조건 순서 규칙, 서브패스 패턴 정리 - 모든 동작을 Node·tsc로 직접 재현 검증(ERR_PACKAGE_PATH_NOT_EXPORTED, 확장자 함정 포함)
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
- 'Node로 확인' → types 검증은 tsc였으므로 Node와 TypeScript로 정정 - '키 이름이 아니라 순서로 매칭' 과장 표현을 실제 규칙에 맞게 수정 - JSON import의 with 구문이 Node 22 기준임을 주석에 명시
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
개요
#56 이슈의 주제로,
package.json의exports필드로 패키지 진입점을 설계하는 포스트를 추가했습니다.apps/blog/src/app/(main)/posts/frontend/package-json-exports/page.mdxfrontend/ postId:package-json-exports다루는 내용
main의 한계 — 진입점만 안내할 뿐 내부 파일 접근을 막지 못해, 소비자가 내부 구조에 의존하게 되는 문제exports의 옵트인 캡슐화 — 적어둔 경로만 열리고 나머지는 차단(ERR_PACKAGE_PATH_NOT_EXPORTED),./package.json도 함께 막히는 점import/require/types분기, 그리고 조건은 적힌 순서대로 첫 매칭 하나만 쓰인다는 규칙(default를 위에 두면 뒤가 죽음)types순서 — 순서에 따라 어느 선언 파일이 이기는지 달라져TS2322가 발생하는 사례*)의 확장자 설계와.json.json함정검증
모든 동작을 실제 패키지를 만들어 Node(v22)와 tsc(5.5.4)로 재현 확인했습니다.
main만 있을 때 내부 파일 deep import가 실제로 통과함을 확인exports도입 후 동일 경로가ERR_PACKAGE_PATH_NOT_EXPORTED로 차단됨을 확인(문자열 축약형·객체형 모두)import/require조건이 서로 다른 빌드로 해석됨을 확인default를 맨 위에 두면 뒤의import조건이 무시됨을 확인types순서에 따라 적용되는 선언 파일이 바뀌어TS2322가 나는 것을tsc로 재현*.jsonvs*)의 동작 차이와.json.json오류를 모두 재현pnpm run build통과(정적 페이지 생성 확인),pnpm run lint통과Closes #56