fix(browser): omit erased type-only import-equals from source-map dependencies (#4165)

Source-map original-source parsing reported `import type X = require("m")`
as a require dependency, although TypeScript erases the declaration. The
fetcher re-derived import-equals targets instead of using the existing
value-only rule. That rule now lives with the other type-only module
declaration predicates in javascriptModuleDeclaration, and the fetcher,
static analysis, and semantic analysis all use it.

Fixes #3932

Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Kaoru0822andClaude Opus 5.5 authored and GitHub committed 2026-10-15 09:34:18 -07:00
1 parent 0cfced12ea
commit 8686b32209
6 files changed
+31 -24

No files matched your search

@@ -16,6 +16,19 @@ export const isTypeOnlyExportDeclaration = (
t.isTSTypeAliasDeclaration(node.declaration) ||
t.isTSDeclareFunction(node.declaration)));
/**
* Runtime external-module target for a value import-equals declaration;
* `import type X = require("m")` is erased and declares no dependency.
*/
export const semanticImportEqualsSpecifier = (
node: t.TSImportEqualsDeclaration,
): string | null =>
node.importKind !== "type" &&
t.isTSExternalModuleReference(node.moduleReference) &&
t.isStringLiteral(node.moduleReference.expression)
? node.moduleReference.expression.value
: null;
/** Whether this import binding is explicitly type-only. */
export const isTypeOnlyImportSpecifier = (node: t.ImportSpecifier): boolean =>
node.importKind === "type" || node.importKind === "typeof";