!908 fix thirdyparty module without 'index'

Merge pull request !908 from 卡哥/master
This commit is contained in:
openharmony_ci
2022-08-04 01:43:39 +00:00
committed by Gitee
+6 -2
View File
@@ -144,7 +144,7 @@ function resolveModuleNames(moduleNames: string[], containingFile: string): ts.R
} else {
resolvedModules.push(null);
}
} else if (/^@(system|ohos)/i.test(moduleName.trim())) {
} else if (/^@(system|ohos)\./i.test(moduleName.trim())) {
const modulePath: string = path.resolve(__dirname, '../../../api', moduleName + '.d.ts');
if (systemModules.includes(moduleName + '.d.ts') && ts.sys.fileExists(modulePath)) {
resolvedModules.push(getResolveModule(modulePath, '.d.ts'));
@@ -169,10 +169,14 @@ function resolveModuleNames(moduleNames: string[], containingFile: string): ts.R
const modulePath: string = path.resolve(__dirname, '../../../api', moduleName + '.d.ts');
const suffix: string = /\.js$/.test(moduleName) ? '' : '.js';
const jsModulePath: string = path.resolve(__dirname, '../node_modules', moduleName + suffix);
const fileModulePath: string =
path.resolve(__dirname, '../node_modules', moduleName + '/index.js');
if (ts.sys.fileExists(modulePath)) {
resolvedModules.push(getResolveModule(modulePath, '.d.ts'));
} else if (ts.sys.fileExists(jsModulePath)) {
resolvedModules.push(getResolveModule(modulePath, '.js'));
resolvedModules.push(getResolveModule(jsModulePath, '.js'));
} else if (ts.sys.fileExists(fileModulePath)) {
resolvedModules.push(getResolveModule(fileModulePath, '.js'));
} else {
resolvedModules.push(null);
}