fix: erase type-only imports in plain .ts files - #28
Merged
Conversation
Run esbuild's ts loader for plain TypeScript files too (previously only .tsx/.jsx), with verbatimModuleSyntax so only type-only imports are dropped and every value import is preserved. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
📖 Docs preview: https://maastrich.github.io/hashup/branches/pr-28/ |
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.
import type/export type/import { type X }in.ts/.mts/.ctsfiles were reaching es-module-lexer as real imports — walked, and reported as unresolved when the specifier is a types-only package export. Every TypeScript file now goes through esbuild first (as.tsxalready did), withverbatimModuleSyntaxso value imports — unused or side-effect — are never dropped.preprocess():tsloader for.ts/.mts/.cts,verbatimModuleSyntax: truefor all loaderstests/type-only-imports.test.ts(erasure per extension, unresolvable type specifier neither walked nor reported, unused/side-effect value imports kept)Context
After 0.10.0 one webapp in the reference monorepo had 3 unresolved edges left, all
import type { … } from "…/styled-system/types"— a package whose./typesexport points at adist/types/index.mjsthat is never emitted. Erased at compile time, irrelevant at runtime, should not block--fail-on-unresolved.Hash impact: entries whose
.tsgraph had type-only edges to real files change once (those files no longer contribute). The examples inline snapshot moved for that reason (examples/src/index.tshasimport type { User }).Not done: adding
.d.tsto resolver extensions (optional follow-up in the brief).Test plan
vp checkgreen;tests/type-only-imports.test.ts,examples,unknown-file-types,shared-cache,large-graph,circular,basic,debug-logs,unresolved-report,tsconfig-pathsrun individually, green.hashup -c ../../.config/hashup.json --fail-on-unresolved -l info→ 0 unresolved, exit 0, 3.0 s.🤖 Generated with Claude Code