Skip to content

Commit 379db84

Browse files
Sebastian WendorfSebastian Wendorf
authored andcommitted
Improved import declaration resolution
1 parent e5af27e commit 379db84

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

typescript/src/core/processors/import-declaration.processor.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ export class ImportDeclarationProcessor extends Processor {
4747
globalContext.sourceFilePathAbsolute,
4848
);
4949
const targetDeclName = ModulePathUtils.extractFQNIdentifier(target.globalFqn);
50-
const packageName = NodeUtils.getPackageNameForPath(globalContext.projectInfo.rootPath, resolvedModulePath);
50+
51+
let packageName: string | undefined = undefined;
52+
if(resolvedModulePath.startsWith(globalContext.projectInfo.rootPath + "/node_modules")) {
53+
// only resolve node package name, if it's an actual node module, not some re-mapped source file (see tsconfig.json -> "paths" option)
54+
packageName = NodeUtils.getPackageNameForPath(globalContext.projectInfo.rootPath, resolvedModulePath);
55+
}
56+
5157
if (packageName) {
5258
target = FQN.id(`"${packageName}".${targetDeclName}`);
5359
} else {

0 commit comments

Comments
 (0)