Signed-off-by: puyajun <puyajun@huawei.com>
This commit is contained in:
puyajun
2022-04-22 11:26:04 +08:00
parent f66108aa6f
commit 609f2ad6ab
3 changed files with 27 additions and 6 deletions
+11 -4
View File
@@ -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<string> = [
'*',
]
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'
+12 -1
View File
@@ -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);
+4 -1
View File
@@ -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, '../'));
}
}