From 140ec9eda59510610d5935372de53c9fb472f3f0 Mon Sep 17 00:00:00 2001 From: puyajun Date: Thu, 12 May 2022 21:07:39 +0800 Subject: [PATCH] puyajun@huawei.com add node_module path Signed-off-by: puyajun --- compiler/src/process_import.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/src/process_import.ts b/compiler/src/process_import.ts index 3e8d617..e80549f 100644 --- a/compiler/src/process_import.ts +++ b/compiler/src/process_import.ts @@ -79,9 +79,9 @@ export default function processImport(node: ts.ImportDeclaration | ts.ImportEqua } try { let fileResolvePath: string; - if (/^(\.|\.\.)\//.test(filePath)) { + if (/^(\.|\.\.)\//.test(filePath) && filePath.indexOf(NODE_MODULES) < 0) { fileResolvePath = path.resolve(pagesDir, filePath); - } else if (/^\//.test(filePath)) { + } else if (/^\//.test(filePath) && filePath.indexOf(NODE_MODULES) < 0) { fileResolvePath = filePath; } else { fileResolvePath = getFileResolvePath(fileResolvePath, pagesDir, filePath, projectConfig.projectPath); @@ -257,7 +257,7 @@ function hasCollection(node: ts.Identifier): boolean { } function isModule(filePath: string): boolean { - return !/^(\.|\.\.)?\//.test(filePath); + return !/^(\.|\.\.)?\//.test(filePath) || filePath.indexOf(NODE_MODULES) > -1; } function isCustomComponent(node: ts.ClassDeclaration): boolean { @@ -323,7 +323,11 @@ function getFileResolvePath(fileResolvePath: string, pagesDir: string, filePath: } let curPageDir: string = pagesDir; while (!fs.existsSync(fileResolvePath)) { - fileResolvePath = path.join(curPageDir, NODE_MODULES, filePath); + if (filePath.indexOf(NODE_MODULES) > -1) { + fileResolvePath = path.join(curPageDir, filePath); + } else { + fileResolvePath = path.join(curPageDir, NODE_MODULES, filePath); + } if (fs.existsSync(fileResolvePath + EXTNAME_ETS)) { fileResolvePath = fileResolvePath + EXTNAME_ETS; } else if (isPackageJsonEntry(fileResolvePath)) {