diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 259761d..428a147 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -50,6 +50,16 @@ function readDeaclareFiles(): string[] { const compilerOptions: ts.CompilerOptions = ts.readConfigFile( path.resolve(__dirname, '../tsconfig.json'), ts.sys.readFile).config.compilerOptions; function setCompilerOptions() { + const allPath: Array = [ + '*', + ] + if (!projectConfig.aceModuleJsonPath) { + allPath.push('../../../../../*'); + allPath.push('../../*'); + } else { + allPath.push('../../../../*'); + allPath.push('../*'); + } Object.assign(compilerOptions, { 'allowJs': false, 'importsNotUsedAsValues': ts.ImportsNotUsedAsValues.Preserve, @@ -59,10 +69,7 @@ function setCompilerOptions() { 'target': ts.ScriptTarget.ES2017, 'baseUrl': path.resolve(projectConfig.projectPath), 'paths': { - '*': [ - '*', - '../../../../../*' - ] + '*': allPath }, 'lib': [ 'lib.es2020.d.ts' diff --git a/compiler/src/process_import.ts b/compiler/src/process_import.ts index 8d6c713..ea057a6 100644 --- a/compiler/src/process_import.ts +++ b/compiler/src/process_import.ts @@ -305,10 +305,21 @@ function getFileResolvePath(fileResolvePath: string, pagesDir: string, filePath: if (fs.existsSync(defaultModule)) { return defaultModule; } - const entryModule: string = path.join(projectPath, '../../../../../', moduleFilePath); + let entryModule: string; + let etsModule: string; + if (!projectConfig.aceModuleJsonPath) { + entryModule = path.join(projectPath, '../../../../../', moduleFilePath); + etsModule = path.join(projectPath, '../../', moduleFilePath); + } else { + entryModule = path.join(projectPath, '../../../../', moduleFilePath); + etsModule = path.join(projectPath, '../', moduleFilePath); + } if (fs.existsSync(entryModule)) { return entryModule; } + if (fs.existsSync(etsModule)) { + return etsModule; + } let curPageDir: string = pagesDir; while (!fs.existsSync(fileResolvePath)) { fileResolvePath = path.join(curPageDir, NODE_MODULES, filePath); diff --git a/compiler/webpack.config.js b/compiler/webpack.config.js index 8df5f35..25ed6f8 100644 --- a/compiler/webpack.config.js +++ b/compiler/webpack.config.js @@ -102,7 +102,6 @@ function initConfig(config) { extensions: ['.js', '.ets', '.ts', '.d.ts'], modules: [ projectPath, - path.join(projectPath, '../../../../../'), './node_modules', path.join(__dirname, 'node_modules'), path.join(__dirname, '../../api') @@ -125,11 +124,15 @@ function initConfig(config) { }; } if (!projectConfig.aceModuleJsonPath) { + config.resolve.modules.push(path.join(projectPath, '../../../../../')); config.resolve.modules.push(path.resolve(projectPath, '../../../../node_modules')); config.resolve.modules.push(path.resolve(projectPath, '../../../../../node_modules')); + config.resolve.modules.push(path.resolve(projectPath, '../../')); } else { + config.resolve.modules.push(path.join(projectPath, '../../../../')); config.resolve.modules.push(path.resolve(projectPath, '../../../node_modules')); config.resolve.modules.push(path.resolve(projectPath, '../../../../node_modules')); + config.resolve.modules.push(path.resolve(projectPath, '../')); } }