Repository navigation
fix(kopis-cli): CJS 듀얼 빌드로 attw 경고 해소 - #24
Merged
Merged
Conversation
- tsup에서 SDK 엔트리를 esm/cjs 양쪽으로 빌드 - exports를 import/require 조건별로 분리하고 조건마다 types를 최상단에 배치 - node10 폴백(main/types)을 CJS 산출물(index.cjs/index.d.cts)로 정렬 - attw 검사 스크립트(check:attw)와 turbo 태스크 추가 Closes #23 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
빌드 산출물의 CJS/ESM 해석을 CI에서 검증하도록 `pnpm turbo check:attw` 스텝을 추가했습니다. build 스텝은 명시적으로 남겨 워크플로우만 봐도 흐름이 보이게 했고, 중복 실행은 turbo 캐시가 흡수합니다(두 번째 호출은 build 캐시 히트). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Closes #23
배경
@coldsurf/tickets@0.10.1에서 attw(are the types wrong) 경고가 떴습니다.패키지가
"type": "module"+ tsupformat: ['esm']로 ESM 단독 산출물만 내보내고exports에require조건이 없어서, CJS 소비자가require('@coldsurf/tickets')하면 ESM 파일로 해결됩니다. Node에서는 에러가 나고await import()로만 쓸 수 있는 상태였습니다.변경사항
듀얼 빌드
tsup.config.ts— SDK 엔트리를format: ['esm', 'cjs']로. CLI/MCP bin 엔트리는 실행 파일이라 ESM 그대로 둡니다.package.json—exports를import/require조건별로 분리하고 각 조건 안에types를 최상단 배치. node10 폴백(main/types)은 CJS 산출물로 정렬했습니다(폴백끼리 포맷이 어긋나면 attw가FalseCJS를 새로 띄웁니다). 레거시 번들러용module필드 추가.회귀 방지
check:attw스크립트(attw --pack .) 추가 — 임시 tarball을 직접 말아서 검사하므로 실제 배포될 산출물 기준으로 검증됩니다.turbo.json에check:attw태스크 등록(dependsOn: ["build"]), 루트에pnpm check:attw연결.검증
pnpm check:attwrequire("@coldsurf/tickets")createKopisClient포함 7개 exportimport { ... }KOPIS_AREAS17개 areatickets --helppacked tarball을 실제로
npm i한 임시 프로젝트에서 bare specifier 해석까지 확인했습니다.참고
dual package hazard(ESM/CJS 인스턴스가 각각 로드되는 문제)는 이 SDK가 모듈 레벨 싱글턴 없이
createKopisClient로 객체만 만들어 반환하는 구조라 현재는 무해합니다. 추후 모듈 스코프 캐시나instanceof체크(KopisApiError등)를 도입하면 다시 볼 지점입니다.🤖 Generated with Claude Code