From 4fdddced1942acae9517479cc953f36d5cb0a536 Mon Sep 17 00:00:00 2001 From: hufeng Date: Tue, 9 Aug 2022 10:57:09 +0800 Subject: [PATCH] Fix multiline import declaration's ohmUrl replacement ISSUE:https://gitee.com/openharmony/developtools_ace-ets2bundle/issues/I5LDIX Signed-off-by: hufeng Change-Id: I033760dd66d5c3b340be01e258d6c5b4a5bb1e3a --- compiler/src/validate_ui_syntax.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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