From 185b391499aaa5e0647531a25313861e2c5482ba Mon Sep 17 00:00:00 2001 From: houhaoyu Date: Wed, 20 Oct 2021 18:27:50 +0800 Subject: [PATCH] fixed 4ee1093 from https://gitee.com/houhaoyu/developtools_ace-ets2bundle/pulls/67 houhaoyu@huawei.com fix the problem of using absolute path Signed-off-by: houhaoyu Change-Id: Icfd58bf31ab996df656853fd1d403d8b11589bfc --- compiler/src/process_import.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler/src/process_import.ts b/compiler/src/process_import.ts index f475da2b5..82753ebb9 100644 --- a/compiler/src/process_import.ts +++ b/compiler/src/process_import.ts @@ -43,6 +43,7 @@ import { IComponentSet } from './validate_ui_syntax'; import { LogInfo } from './utils'; +import { projectConfig } from '../main'; export default function processImport(node: ts.ImportDeclaration | ts.ImportEqualsDeclaration | ts.ExportDeclaration, pagesDir: string, log: LogInfo[]): void { @@ -82,7 +83,7 @@ export default function processImport(node: ts.ImportDeclaration | ts.ImportEqua } else if (/^\//.test(filePath)) { fileResolvePath = filePath; } else { - fileResolvePath = getFileResolvePath(fileResolvePath, pagesDir, filePath); + fileResolvePath = getFileResolvePath(fileResolvePath, pagesDir, filePath, projectConfig.projectPath); } if (fs.existsSync(fileResolvePath) && fs.statSync(fileResolvePath).isFile()) { const content: string = preprocessNewExtend(preprocessExtend(processSystemApi( @@ -248,13 +249,14 @@ function getModuleFilePath(filePath: string): string { return filePath; } -function getFileResolvePath(fileResolvePath: string, pagesDir: string, filePath: string): string { +function getFileResolvePath(fileResolvePath: string, pagesDir: string, filePath: string, + projectPath: string): string { const moduleFilePath: string = getModuleFilePath(filePath); - const defaultModule: string = path.join(pagesDir, '../', moduleFilePath); + const defaultModule: string = path.join(projectPath, moduleFilePath); if (fs.existsSync(defaultModule)) { return defaultModule; } - const entryModule: string = path.join(pagesDir, '../../../../../../', moduleFilePath); + const entryModule: string = path.join(projectPath, '../../../../../', moduleFilePath); if (fs.existsSync(entryModule)) { return entryModule; } -- Gitee