Signed-off-by: lizhouze <lizhouze@huawei.com>
This commit is contained in:
lizhouze
2022-08-03 17:38:07 +08:00
parent 0a19a6c920
commit 3e80bee2d2
+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);
}