From 06a0eba9ceaa623d26196501c4cd9b9f82d255ec Mon Sep 17 00:00:00 2001 From: lihong Date: Thu, 23 Jun 2022 11:55:58 +0800 Subject: [PATCH] fixed de04351 from https://gitee.com/lihong67/developtools_ace-ets2bundle/pulls/768 lihong67@huawei.com fix system module name case sensitive. Signed-off-by: lihong Change-Id: I7cacd2c618a000215d21049fc6098860c0472ad0 --- compiler/src/process_system_module.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/compiler/src/process_system_module.ts b/compiler/src/process_system_module.ts index 505bfdd..858f2bf 100644 --- a/compiler/src/process_system_module.ts +++ b/compiler/src/process_system_module.ts @@ -14,7 +14,22 @@ */ import { processSystemApi } from './validate_ui_syntax'; +import { systemModules } from '../main'; module.exports = function processSystemModule(source: string): string { - return processSystemApi(source, false, this.resourcePath, true); + const REG_IMPORT: RegExp = + /(import|export)\s+(.+)\s+from\s+['"](\S+)['"]|import\s+(.+)\s*=\s*require\(\s*['"](\S+)['"]\s*\)/g; + source.replace(REG_IMPORT, (item, item1, item2, item3, item4, item5) => { + const moduleRequest: string = item3 || item5; + if (/^@(system|ohos)\./i.test(moduleRequest.trim())) { + if (!systemModules.includes(moduleRequest.trim() + '.d.ts')) { + const message: string = + `Cannot find module '${moduleRequest}' or its corresponding type declarations.`; + this.emitError(`BUILDERROR File: ${this.resourcePath}\n ${message}`); + } + } + return item; + }); + source = processSystemApi(source, false, this.resourcePath, true); + return source; };