feat(config): .ts/.js config self-compile loader#2113
Merged
Conversation
Closes #2100. Phase 1-1 of #2099. zts.config.{ts,mts,cts,mjs,js,cjs,json} 7종 확장자 로드 지원. - `.ts/.mts/.cts` 는 NAPI `transpile()` 로 self-compile 후 dynamic import - `.mjs/.js/.cjs` 는 직접 dynamic import (Bun/Node 표준) - `.json` 은 readFileSync + JSON.parse - tmp 파일은 config 옆에 작성해 user 의 node_modules resolution 보존 (esbuild `*.bundled-*.mjs` 패턴) - `.cts` 는 ZTS 가 CJS-only 로 취급해 ESM 구문을 거부하므로 파싱 단계에서만 `.ts` 로 가장 (에러 메시지에는 실제 경로 사용) 비범위: 자동 탐색 (#2102), BuildOptions 머지 (#2101), 함수형 config (#2103). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Smoke Test Results (CI)Smoke Test Results
Size Comparison (ZTS vs smallest of esbuild/rolldown/rspack)
Average ratio (vs smallest): 0.89x | Smaller: 113 | Similar(±10%): 20 | Larger: 11
|
- existsSync precheck 제거 (TOCTOU 회피 + syscall 절감) — readFileSync /
import() 의 ENOENT 를 catch 해 동일 메시지 throw.
- 죽은 cache-bust query (`?t=${Date.now()}`) 제거 — Phase 1 scope 에서 같은
프로세스 다중 reload 가 없음. watch reload 는 #2107 에서 별도 처리.
- unlinkSync 실패 시 console.warn — silent swallow 방지.
- `.cts` parser 우회 주석에 `parser.zig` 위치 + `transpile()` follow-up
FIXME 추가.
- 테스트의 `resolveImportPath()` 헬퍼를 단일 호출 지점에 inline.
Part of #2099 / #2100.
Co-Authored-By: Claude Opus 4.7 (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.
요약
zts.config.{ts,mts,cts,mjs,js,cjs,json}7종 확장자 로드..ts/.mts/.cts는 NAPItranspile()로 self-compile 후 dynamic import.node_modulesresolution 을 보존 (esbuild*.bundled-*.mjs패턴)..cts는 ZTS 가 CJS-only 로 취급하므로 파싱 단계에서만.ts로 가장 (에러 메시지에는 실제 경로 유지).비범위
테스트
bun test packages/core/src/config-loader.test.ts— 15 passzig build test— 4016/4016 passbun run lint/bun run fmt:check— 통과Closes #2100. Part of #2099.