diff --git a/compiler/src/validate_ui_syntax.ts b/compiler/src/validate_ui_syntax.ts index 17e1032..6229fc5 100644 --- a/compiler/src/validate_ui_syntax.ts +++ b/compiler/src/validate_ui_syntax.ts @@ -1000,11 +1000,11 @@ export function processSystemApi(content: string, isProcessAllowList: boolean = const REG_IMPORT_DECL: RegExp = isProcessAllowList ? projectConfig.compileMode === ESMODULE ? /import\s+(.+)\s+from\s+['"]@(system|ohos)\.(\S+)['"]/g : /(import|const)\s+(.+)\s*=\s*(\_\_importDefault\()?require\(\s*['"]@(system|ohos)\.(\S+)['"]\s*\)(\))?/g : - /(import|export)\s+(.+)\s+from\s+['"](\S+)['"]|import\s+(.+)\s*=\s*require\(\s*['"](\S+)['"]\s*\)/g; + /(import|export)\s+(?:(.+)|\{([\s\S]+)\})\s+from\s+['"](\S+)['"]|import\s+(.+)\s*=\s*require\(\s*['"](\S+)['"]\s*\)/g; const systemValueCollection: Set = new Set(); - const processedContent: string = content.replace(REG_IMPORT_DECL, (item, item1, item2, item3, item4, item5) => { - const importValue: string = isProcessAllowList ? projectConfig.compileMode === ESMODULE ? item1 : item2 : item2 || item4; + const processedContent: string = content.replace(REG_IMPORT_DECL, (item, item1, item2, item3, item4, item5, item6) => { + const importValue: string = isProcessAllowList ? projectConfig.compileMode === ESMODULE ? item1 : item2 : item2 || item5; if (isProcessAllowList) { systemValueCollection.add(importValue); @@ -1016,7 +1016,7 @@ export function processSystemApi(content: string, isProcessAllowList: boolean = return replaceSystemApi(item, importValue, item2, item3); } - const moduleRequest: string = item3 || item5; + const moduleRequest: string = item4 || item6; if (isOhmUrl(moduleRequest)) { // ohmURL return replaceOhmUrl(isSystemModule, item, importValue, moduleRequest, sourcePath); } else if (/^@(system|ohos)\./.test(moduleRequest)) { // ohos/system.api