From 9e9b017b3348274540ac2ff2cfc7603ea7d57e0f Mon Sep 17 00:00:00 2001 From: xiaolei <1017653702@qq.com> Date: Thu, 4 Jul 2024 15:00:53 +0800 Subject: [PATCH 1/3] [feat]support wxs for rn --- packages/webpack-plugin/lib/template-compiler/compiler.js | 3 ++- .../webpack-plugin/lib/template-compiler/gen-node-react.js | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/webpack-plugin/lib/template-compiler/compiler.js b/packages/webpack-plugin/lib/template-compiler/compiler.js index 251661627b..539c6c6412 100644 --- a/packages/webpack-plugin/lib/template-compiler/compiler.js +++ b/packages/webpack-plugin/lib/template-compiler/compiler.js @@ -1949,7 +1949,7 @@ function processText (el) { // RN中文字需被Text包裹 function processWrapTextReact (el) { const parentTag = el.parent.tag - if (parentTag !== 'mpx-text' && parentTag !== 'Text') { + if (parentTag !== 'mpx-text' && parentTag !== 'Text' && parentTag !== 'wxs') { const wrapper = createASTElement('Text') replaceNode(el, wrapper, true) addChild(wrapper, el) @@ -2579,6 +2579,7 @@ function closeElement (el, meta, options) { return } if (isReact(mode)) { + postProcessWxs(el, meta) postProcessForReact(el) postProcessIfReact(el) // flag component for react diff --git a/packages/webpack-plugin/lib/template-compiler/gen-node-react.js b/packages/webpack-plugin/lib/template-compiler/gen-node-react.js index 107925d958..889f0674de 100644 --- a/packages/webpack-plugin/lib/template-compiler/gen-node-react.js +++ b/packages/webpack-plugin/lib/template-compiler/gen-node-react.js @@ -42,6 +42,9 @@ function genNode (node) { } } } + if (node.tag === 'wxs') { + return '""' + } if (node.type === 1) { if (node.tag !== 'temp-node') { if (node.for && !node.forProcessed) { From 9ac37caefa55d19cefe554fc0abbb0e94d5e0cc0 Mon Sep 17 00:00:00 2001 From: xiaolei <1017653702@qq.com> Date: Wed, 10 Jul 2024 10:42:50 +0800 Subject: [PATCH 2/3] [update]return null of wxs tag --- packages/webpack-plugin/lib/template-compiler/gen-node-react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack-plugin/lib/template-compiler/gen-node-react.js b/packages/webpack-plugin/lib/template-compiler/gen-node-react.js index 889f0674de..f8c3a94748 100644 --- a/packages/webpack-plugin/lib/template-compiler/gen-node-react.js +++ b/packages/webpack-plugin/lib/template-compiler/gen-node-react.js @@ -43,7 +43,7 @@ function genNode (node) { } } if (node.tag === 'wxs') { - return '""' + return 'null' } if (node.type === 1) { if (node.tag !== 'temp-node') { From e873f443f928b418815b9fe335d446eff3c6ba97 Mon Sep 17 00:00:00 2001 From: xiaolei <1017653702@qq.com> Date: Fri, 19 Jul 2024 10:16:38 +0800 Subject: [PATCH 3/3] [optimize]no need to inject wxs node --- packages/webpack-plugin/lib/template-compiler/compiler.js | 2 +- .../webpack-plugin/lib/template-compiler/gen-node-react.js | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/webpack-plugin/lib/template-compiler/compiler.js b/packages/webpack-plugin/lib/template-compiler/compiler.js index 539c6c6412..87f3dcb05d 100644 --- a/packages/webpack-plugin/lib/template-compiler/compiler.js +++ b/packages/webpack-plugin/lib/template-compiler/compiler.js @@ -1970,7 +1970,7 @@ function processWrapTextReact (el) { // } function injectWxs (meta, module, src) { - if (runtimeCompile || addWxsModule(meta, module, src)) { + if (runtimeCompile || addWxsModule(meta, module, src) || isReact(mode)) { return } diff --git a/packages/webpack-plugin/lib/template-compiler/gen-node-react.js b/packages/webpack-plugin/lib/template-compiler/gen-node-react.js index f8c3a94748..107925d958 100644 --- a/packages/webpack-plugin/lib/template-compiler/gen-node-react.js +++ b/packages/webpack-plugin/lib/template-compiler/gen-node-react.js @@ -42,9 +42,6 @@ function genNode (node) { } } } - if (node.tag === 'wxs') { - return 'null' - } if (node.type === 1) { if (node.tag !== 'temp-node') { if (node.for && !node.forProcessed) {