Skip to content

fix: erase type-only imports in plain .ts files - #28

Merged
maastrich merged 2 commits into
mainfrom
fix/erase-type-imports
Aug 20, 2026
Merged

fix: erase type-only imports in plain .ts files#28
maastrich merged 2 commits into
mainfrom
fix/erase-type-imports

Conversation

@maastrich

@maastrich maastrich commented Aug 20, 2026

Copy link
Copy Markdown
Owner

import type / export type / import { type X } in .ts / .mts / .cts files 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 .tsx already did), with verbatimModuleSyntax so value imports — unused or side-effect — are never dropped.

  • preprocess(): ts loader for .ts / .mts / .cts, verbatimModuleSyntax: true for all loaders
  • tests: tests/type-only-imports.test.ts (erasure per extension, unresolvable type specifier neither walked nor reported, unused/side-effect value imports kept)
  • docs + patch changeset
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 ./types export points at a dist/types/index.mjs that is never emitted. Erased at compile time, irrelevant at runtime, should not block --fail-on-unresolved.

Hash impact: entries whose .ts graph 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.ts has import type { User }).

Not done: adding .d.ts to resolver extensions (optional follow-up in the brief).

Test plan
  • vp check green; tests/type-only-imports.test.ts, examples, unknown-file-types, shared-cache, large-graph, circular, basic, debug-logs, unresolved-report, tsconfig-paths run individually, green.
  • Reference monorepo webapp: hashup -c ../../.config/hashup.json --fail-on-unresolved -l info → 0 unresolved, exit 0, 3.0 s.

🤖 Generated with Claude Code

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>
@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview: https://maastrich.github.io/hashup/branches/pr-28/

@maastrich
maastrich enabled auto-merge (squash) August 20, 2026 14:18
@maastrich
maastrich merged commit 2adf97b into main Aug 20, 2026
3 checks passed
@maastrich
maastrich deleted the fix/erase-type-imports branch August 20, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant