From 1d220b274046aa5d3176d98f1e3b95c735b551ea Mon Sep 17 00:00:00 2001 From: bojiang Date: Fri, 2 Sep 2022 10:22:38 +0800 Subject: [PATCH 1/2] jiangbo91@huawei.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解决ets工程引用js文件watch模式下修改js文件内容预览器无法刷新 Signed-off-by: bojiang Change-Id: I7b0f2d9636cbe054fc12dd5283954cec357c169e --- compiler/src/compile_info.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compiler/src/compile_info.ts b/compiler/src/compile_info.ts index 681f5f6..16b2ba4 100644 --- a/compiler/src/compile_info.ts +++ b/compiler/src/compile_info.ts @@ -239,6 +239,17 @@ export class ResultStates { } this.printResult(); }); + + compiler.hooks.watchRun.tap('Listening State', (compiler: Compiler) => { + if (compiler.modifiedFiles) { + const isTsAndEtsFile: boolean = [...compiler.modifiedFiles].some((item: string) => { + return /.(ts|ets)$/.test(item); + }); + if (!isTsAndEtsFile) { + process.env.watchTs = 'end'; + } + } + }); } private printDiagnostic(diagnostic: ts.Diagnostic): void { From 024621f25fba4ac897c15eeb8317d713c0336b00 Mon Sep 17 00:00:00 2001 From: laibo102 Date: Fri, 2 Sep 2022 15:04:25 +0800 Subject: [PATCH 2/2] Bugfix: fiexd button with label parameter cannot have any child Signed-off-by: laibo102 Change-Id: Iae9c68672c09080d7098274e45876242a40610c3 --- compiler/src/process_component_build.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 3b59830..eea4651 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -60,7 +60,8 @@ import { BIND_POPUP_SET, $$, PROPERTIES_ADD_DOUBLE_DOLLAR, - ATTRIBUTE_ID + ATTRIBUTE_ID, + RESOURCE } from './pre_define'; import { INNER_COMPONENT_NAMES, @@ -413,6 +414,7 @@ function processInnerComponent(node: ts.ExpressionStatement, newStatements: ts.S } if (etsComponentResult.etsComponentNode.body && ts.isBlock(etsComponentResult.etsComponentNode.body)) { if (res.isButton) { + checkButtonParamHasLabel(etsComponentResult.etsComponentNode, log); if (projectConfig.isPreview) { newStatements.splice(-2, 1, createComponent(node, COMPONENT_CREATE_CHILD_FUNCTION).newNode); } else { @@ -1385,3 +1387,20 @@ function checkEtsComponent(node: ts.ExpressionStatement, log: LogInfo[]): void { ); } } + +function checkButtonParamHasLabel(node: ts.EtsComponentExpression, log: LogInfo[]): void { + if (node.arguments && node.arguments.length !== 0) { + for (let i = 0; i < node.arguments.length; i++) { + let argument: ts.Expression = node.arguments[i]; + if (ts.isStringLiteral(argument) || (ts.isCallExpression(argument) && ts.isIdentifier(argument.expression) && + (argument.expression.escapedText.toString() === RESOURCE))) { + log.push({ + type: LogType.ERROR, + message: "The Button component with a label parameter can not have any child.", + pos: node.getStart(), + }); + return; + } + } + } +}