Skip to content

fix(build): Dual ESM/CJS 빌드 패턴 적용#12

Merged
ywkim merged 1 commit intomainfrom
fix/build-dual-esm-cjs-pattern
Jan 4, 2026
Merged

fix(build): Dual ESM/CJS 빌드 패턴 적용#12
ywkim merged 1 commit intomainfrom
fix/build-dual-esm-cjs-pattern

Conversation

@ywkim
Copy link
Copy Markdown
Contributor

@ywkim ywkim commented Jan 4, 2026

요약

Fancall의 Vite 빌드 설정을 aioia-core, trade-safety와 동일한 dual ESM/CJS 패턴으로 표준화합니다.

목적

  • 라이브러리 빌드 설정 표준화 (aioia-core PR #23, trade-safety PR #84와 동일 패턴)
  • Next.js 13.5.6 webpack 버그 회피 (.mjs.js 변경)
  • Jest 호환성 개선 (CJS 파일 확장자 표준화)

주요 변경 사항

빌드 출력 파일명 변경

  • ESM: .mjs.js
  • CJS: .js.cjs

package.json 필드 수정

  • main: dist/index.jsdist/index.cjs (CJS 진입점)
  • module: dist/index.mjsdist/index.js (ESM 진입점)
  • exports["."].import: ./dist/index.mjs./dist/index.js
  • exports["."].require: ./dist/index.js./dist/index.cjs
  • exports["./client"]도 동일하게 적용

적용 대상

  • 진입점: index, client
  • 모든 서브모듈 자동 포함

기술 배경

  • .js 확장자: Next.js 13.5.6에서 webpack이 .mjs를 제대로 처리하지 못하는 버그 회피
  • .cjs 확장자: CommonJS 모듈 명시적 표시, Jest 호환성 강화

테스트 체크리스트

  • npm run build:lib 성공 (4개 파일 정상 생성)
    • dist/index.js (ESM)
    • dist/client.js (ESM)
    • dist/index.cjs (CJS)
    • dist/client.cjs (CJS)
  • npm run format 완료
  • npm run lint:fix 완료 (오류 없음)
  • npm run type-check 완료 (타입 오류 없음)
  • 파일 구조 검증 (npm pack 결과 정상)

참고

이 PR은 라이브러리 빌드 설정의 내부 구현을 변경하는 것으로, 타입 정의와 공개 API는 변경되지 않습니다. 소비자 프로젝트에서 기존대로 import/require를 사용할 수 있습니다.

🤖 Generated with Claude Code

- vite.config.ts: ESM .mjs → .js, CJS .js → .cjs로 변경
- package.json main/module/exports 필드 업데이트
  - main: dist/index.cjs (CJS)
  - module: dist/index.js (ESM)
  - exports: import "./dist/index.js", require "./dist/index.cjs"

Next.js 13.5.6 webpack 버그 회피 및 Jest 호환성 개선

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이 PR은 Vite 빌드 설정을 aioia-core 등 다른 라이브러리와 동일한 dual ESM/CJS 패턴으로 표준화하는 것을 목표로 하고 있습니다. package.jsonmain, module, exports 필드를 수정하고 vite.config.ts에서 빌드 결과물의 확장자를 .mjs -> .js (ESM), .js -> .cjs (CJS)로 변경하는 내용이 포함되어 있습니다.

전반적으로 변경 사항은 명확하고 PR의 목적에 잘 부합합니다. Next.js 버그 회피 및 Jest 호환성 개선이라는 목표를 효과적으로 달성할 것으로 보입니다.

한 가지 유지보수성 향상을 위한 제안을 vite.config.ts 파일에 남겼습니다. fileName 함수의 구현을 조금 더 견고하게 만들어 향후 발생할 수 있는 실수를 방지하는 내용입니다.

Comment thread frontend/vite.config.ts
@ywkim ywkim merged commit 70f921f into main Jan 4, 2026
3 checks passed
@ywkim ywkim deleted the fix/build-dual-esm-cjs-pattern branch January 4, 2026 08:23
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 4, 2026

🎉 This PR is included in version 0.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant