fix(import-scanner): elide import { type A, type B } declaration (#2466)#2467
Conversation
…2466) per-spec individual `type` modifier 가 모든 specifier 에 붙은 import 는 babel typescript preset 처럼 statement 통째 제거. 이전엔 ImportRecord 가 생성되어 type-only re-export subpath (`react-native-screens/types` 등) 의 모듈 resolution 시도가 hard fail. declaration-level `import type { ... }` 는 parser 가 이미 elide. implicit type-only (값 형태 import 를 type position 에서만 사용) 는 analyzer 가 type body 자식을 walk 하지 않는 한계 (#3a parser PR 선행 필요) 때문에 본 PR 범위 외.
메모: #2466 의 부분 해결본 PR 은 #2466 케이스 중 explicit per-spec 처리 안 한 케이스 — implicit type-onlyimport { Foo } from './types';
const fn = (x: Foo) => x; // Foo 가 type position 에서만 사용이 케이스를 처리하려면 semantic analyzer 가 type body 안 식별자에
그래서 근본 fix 는 plan #3a — parser 가 type body 노드를 보존하도록 하는 것입니다. 이건 codegen native plugin (#2348) 의 prerequisite 이기도 해서 별도 PR (~4-5일 예상) 으로 진행 예정. 이후 본 PR 의 elision 을 implicit 케이스까지 확장할 수 있습니다. 검증 plan
|
Smoke Test Results (CI)Smoke Test Results
Size Comparison (ZTS vs smallest of esbuild/rolldown/rspack)
Average ratio (vs smallest): 0.87x | Smaller: 120 | Similar(±10%): 17 | Larger: 7
|
Benchmark Results (CI)macos-latesttranspile — small (100 lines)
transpile — medium (1K lines)
transpile — large (5K lines)
bundle — small (10 modules)
bundle — medium (50 modules)
bundle — large (200 modules)
small (100 lines)
medium (1K lines)
large (5K lines)
xlarge (10K lines)
ubuntu-latesttranspile — small (100 lines)
transpile — medium (1K lines)
transpile — large (5K lines)
bundle — small (10 modules)
bundle — medium (50 modules)
bundle — large (200 modules)
small (100 lines)
medium (1K lines)
large (5K lines)
xlarge (10K lines)
windows-latesttranspile — small (100 lines)
transpile — medium (1K lines)
transpile — large (5K lines)
bundle — small (10 modules)
bundle — medium (50 modules)
bundle — large (200 modules)
small (100 lines)
medium (1K lines)
large (5K lines)
xlarge (10K lines)
|
Summary
per-spec individual
typemodifier 가 모든 specifier 에 붙은 import 는 babel typescript preset 처럼 statement 통째 제거합니다. 이전엔ImportRecord가 생성되어 type-only re-export subpath (react-native-screens/types같이 .d.ts 만 export 하는 경로) 의 모듈 resolution 시도가 hard fail 했습니다.declaration-level
import type { ... }는 parser 가 이미 elide 하므로 변경 없음.범위 외 (의도)
implicit type-only —
import { Foo } from '...'; type X = Foo;처럼 binding 이 type position 에서만 쓰이는 패턴 — 은 본 PR 에서 처리하지 않습니다. 원인:ts_type_alias_declaration/ts_interface_declaration/ts_property_signature는child_offsets = &.{}로 선언되어 있어ast_walk.children으로 type body 의ts_type_reference에 도달 못합니다.Reference.flags.type_context가 type body 안 식별자에 붙지 않아 "type-only reference만 있는 binding" 판정 자체가 불가능.#2466 의 ExpoApp `prepareHeaderBarButtonItems.ts` 케이스는 `import { type A, type B }` 형태이므로 본 PR 로 해결됩니다. 향후 implicit 케이스는 #3a 머지 후 follow-up 으로 추가할 예정.
Test plan