fix(jit): elide imports whose specifiers are all inline-type - #482
Merged
Brooooooklyn merged 1 commit intoSep 18, 2026
Merged
Brooooooklyn merged 1 commit into
Brooooooklyn merged 1 commit into
Conversation
In JIT mode, strip_typescript runs oxc's TS transform with
only_remove_type_imports, which drops inline-type specifiers but keeps
the emptied statement as a bare side-effect import. An import like
`import { type Get } from 'type-fest'` therefore survived as
`import "type-fest"`, failing Rolldown builds for types-only packages
and defeating tree-shaking for ordinary ones.
Promote any value import whose named specifiers all carry inline
`type` modifiers to `import type` before the transformer runs, so the
whole statement is elided. Mixed imports, default/namespace imports,
and explicit bare side-effect imports are untouched. This matches
Angular CLI's esbuild pipeline rather than tsc verbatimModuleSyntax,
which would keep `import {}` for side effects.
Brooooooklyn
approved these changes
Sep 18, 2026
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.
Problem
With
jit: true, an import statement whose bindings all carry inlinetypemodifiers is preserved as a bare side-effect import instead of being elided:emits
import "type-fest";at the top of the output. For a types-only package liketype-fest(nomain/exports), Rolldown fails the build outright; for an ordinary package it survives as a dead import that defeats tree-shaking.The file must contain an Angular decorator to reproduce, which points at the JIT transform:
strip_typescriptruns oxc's TS transform withonly_remove_type_imports, which drops the inline-typespecifiers but keeps the emptied statement as a side-effect import. Mixed imports (import { Pipe, type PipeTransform }) and wholeimport type { ... }statements were already handled correctly; only the all-inline-typecase leaked.Fix
Before the transformer runs, promote any value import whose named specifiers are all inline-
typetoimport type, soonly_remove_type_importselides the whole statement. Untouched: bare side-effect imports (import 'mod'), emptyimport {}, existingimport type, and any statement with a default or namespace specifier.Note this intentionally follows Angular CLI's esbuild pipeline rather than tsc
verbatimModuleSyntax, which would keepimport {}for side effects; code relying on side effects should use an explicitimport 'mod', which is preserved.AOT is unaffected: it uses the separate semantic-based elision pass and already elides these imports.
Testing
typeelided, mixed value+type keeps the value binding only, wholeimport typeelided, default import with inline-typesibling keeps the default, bare side-effect import preserved. Fails before the fix with the exact reported output, passes after.jit: trueandjit: falseon the repro above.