Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

taro使用webpack5进行开发时编译后, 报错找不到模板 WXMLRT_$gwx:./base.wxml:template:377:16: Template tmpl_0_21 not found. #12553

Closed
ymq001 opened this issue Sep 22, 2022 · 33 comments
Assignees
Labels
F-react Framework - React P-2 Medium, minor/patch T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@ymq001
Copy link

ymq001 commented Sep 22, 2022

相关平台

微信小程序

复现仓库

https://github.com/ymq001/taro-bug-repo
小程序基础库: 2.26.0
使用框架: React

复现步骤

运行 dev:weapp
在 page/index/index.tsx 中使用 AtButton 组件

  <AtButton
          className="nl-button"
          type="primary"
          circle={true}
          openType="getPhoneNumber"
          onGetPhoneNumber={this.handleGetPhoneNumber.bind(this)}
        >
          获取手机号
</AtButton>

报错:

VM1093:22 WXMLRT_$gwx:./base.wxml:template:205:16: Template `tmpl_0_21` not found.
[WXML Runtime warning] ./base.wxml
 Template `tmpl_0_21` not found.
  203 | 
  204 | <template name="tmpl_2_container">
> 205 |   <template is="{{xs.a(2, i.nn, l)}}" data="{{i:i,cid:2,l:xs.f(l,i.nn)}}" />
      |                ^
  206 | </template>
  207 | 
  208 | <template name="tmpl_3_0">

期望结果

运行 dev:weapp 命令时,不会出现报错,且组件无法正常使用的情况

实际结果

运行 dev:weapp 命令时,出现报错,且组件无法正常使用

环境信息

  Taro CLI 3.5.5 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 14.16.1 - D:\Program\nodejs\node.EXE
      Yarn: 1.19.0 - C:\Users\admin\AppData\Roaming\npm\yarn.CMD
      npm: 6.14.12 - D:\Program\nodejs\npm.CMD
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Sep 22, 2022
@kityandhero
Copy link

kityandhero commented Sep 22, 2022

taro 3.5.6 react框架下,通过 webpack5 构建小程序,首次运行正常,后续重复 build, 小程序将运行异常,类似问题提示 Template tmpl_0_custom-wrapper not found。将 cache 设为 false,该场景并不出现,感觉启用缓存后,重复构建会丢失某些东西。

@Chen-jj
Copy link
Contributor

Chen-jj commented Sep 22, 2022

taro 3.5.6 react框架下,通过 webpack5 构建小程序,首次运行正常,后续重复 build, 小程序将运行异常,类似问题提示 Template tmpl_0_custom-wrapper not found。将 cache 设为 false,该场景并不出现,感觉启用缓存后,重复构建会丢失某些东西。

开了 cache 后,命中缓存时 Webpack 的一些 hooks 不会运行,如解析模块 AST 的 parse 相关钩子等。导致 Taro 一些编译逻辑没能正常运行,这块需要看看怎样配合 Webpack cache 把 Taro 对应逻辑进行缓存与恢复。

@kityandhero
Copy link

@Chen-jj 经解释,问题原因已了解,期待此问题的修复

@b2nil
Copy link
Collaborator

b2nil commented Sep 28, 2022

@Chen-jj
需要解析 AST 来收集组件的第三方库,目前如果进行了 prebundle,后面就收集不到组件了;关了 cache 也不行。
现在只能在 prebundle 配置中 exclude 需要收集组件的第三方库。二次编译时,每次都要重新编译一下。

prebundle 时能不能先解析一次指定模块(手动在配置中标记) 的 AST?

@Chen-jj
Copy link
Contributor

Chen-jj commented Sep 28, 2022

@Chen-jj 需要解析 AST 来收集组件的第三方库,目前如果进行了 prebundle,后面就收集不到组件了;关了 cache 也不行。 现在只能在 prebundle 配置中 exclude 需要收集组件的第三方库。二次编译时,每次都要重新编译一下。

prebundle 时能不能先解析一次指定模块(手动在配置中标记) 的 AST?

可以的,在 prebundle 的 webpack 编译阶段的 parse 钩子中进行同样的收集处理。但 prebundle 的 webpack 编译也开了 cache,所以 watch 时还会遇到问题。

@Chen-jj
Copy link
Contributor

Chen-jj commented Sep 28, 2022

#12555

@Chen-jj Chen-jj self-assigned this Oct 16, 2022
@Chen-jj Chen-jj added the P-2 Medium, minor/patch label Oct 16, 2022
@taro-bot2 taro-bot2 bot modified the milestone: 3.6.0 Oct 16, 2022
@thetbw
Copy link

thetbw commented Oct 19, 2022

我现在用的是 taro 3.5.6,nutui-taro 3.2.3,也会存在这种报错。使用dev:weapp会出现,但是build:weapp不会出现。这个是开发和最终编译哪里不同吗

@h1orz
Copy link

h1orz commented Oct 24, 2022

同样的问题,dev:weapp时必现,build:weapp没问题。
@b2nil prebundle.exclude配置后可以解决,感谢!
但有副作用,Windows的小程序IDE自动编译失效了,每次都要手动点编译才能渲染最新的内容。

@tomnattle
Copy link

同样的问题,dev:weapp时必现,build:weapp没问题。

VM946:22 WXMLRT_$gwx:./base.wxml:template:477:16: Template `tmpl_0_31` not found.
_wp @ VM946:22
_w @ VM946:1024
d_.<computed>.tmpl_6_container @ VM946:5126
xC @ VM946:4736
wfor @ VM946:571
_2z @ VM946:714
d_.<computed>.tmpl_5_2 @ VM946:4744
d_.<computed>.tmpl_5_container @ VM946:4892
xC @ VM946:4467
wfor @ VM946:571
_2z @ VM946:714
d_.<computed>.tmpl_4_2 @ VM946:4475
d_.<computed>.tmpl_4_container @ VM946:4623
xC @ VM946:4114
wfor @ VM946:571
_2z @ VM946:714
d_.<computed>.tmpl_3_2 @ VM946:4122
d_.<computed>.tmpl_3_container @ VM946:4354
xC @ VM946:3761
wfor @ VM946:571
_2z @ VM946:714
d_.<computed>.tmpl_2_2 @ VM946:3769
d_.<computed>.tmpl_2_container @ VM946:4001
xC @ VM946:3408
wfor @ VM946:571
_2z @ VM946:714
d_.<computed>.tmpl_1_2 @ VM946:3416
d_.<computed>.tmpl_1_container @ VM946:3648
xC @ VM946:2802
wfor @ VM946:571
_2z @ VM946:714
d_.<computed>.tmpl_0_2 @ VM946:2810
d_.<computed>.tmpl_0_container @ VM946:3295
xC @ VM946:2684
wfor @ VM946:571
_2z @ VM946:714
d_.<computed>.taro_tmpl @ VM946:2692
m2 @ VM946:7070
(anonymous) @ VM946:7200
io @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
_updateValues @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
updateValues @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
u.doUpdates @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
y.setData @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ vendors-node_modules_taro_weapp_prebundle_chunk-E2COQYTW_js.js? [sm]:2960
f @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
p @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
setTimeout (async)
globalThis.setTimeout @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
globalThis.setTimeout @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
performUpdate @ vendors-node_modules_taro_weapp_prebundle_chunk-E2COQYTW_js.js? [sm]:2891
(anonymous) @ vendors-node_modules_taro_weapp_prebundle_chunk-E2COQYTW_js.js? [sm]:855
wd @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:1098
$g @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:3665
Yg @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:3642
Xg @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:3623
Th @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:4424
Nh @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:4387
Eh @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:4050
J @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:119
R @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:151
f @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
p @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
setTimeout (async)
globalThis.setTimeout @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
globalThis.setTimeout @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
S @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:168
I @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:174
exports.unstable_scheduleCallback @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:269
Dh @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:4821
Z @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:3965
Ad @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:3927
enqueueForceUpdate @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:1139
E.forceUpdate @ vendors-node_modules_taro_weapp_prebundle_chunk-LNJCN3VW_js.js? [sm]:58
mount @ vendors-node_modules_taro_weapp_prebundle_tarojs_plugin-framework-react_dist_runtime_js.js? [sm]:285
mount @ vendors-node_modules_taro_weapp_prebundle_tarojs_plugin-framework-react_dist_runtime_js.js? [sm]:325
mount @ vendors-node_modules_taro_weapp_prebundle_chunk-E2COQYTW_js.js? [sm]:848
(anonymous) @ vendors-node_modules_taro_weapp_prebundle_chunk-E2COQYTW_js.js? [sm]:862
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
u.__callPageLifeTime__ @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
xr @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
l.emit @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
emit @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
l.emit @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
emit @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
emit @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
c @ VM9 asdebug.js:10
u @ VM9 asdebug.js:10
(anonymous) @ VM9 asdebug.js:1
f @ VM9 asdebug.js:1
(anonymous) @ VM9 asdebug.js:1
t.setAppserviceReady @ VM9 asdebug.js:1
handleLoadDone @ VM9 asdebug.js:10
(anonymous) @ VM9 asdebug.js:10
setTimeout (async)
proxyAlert @ VM9 asdebug.js:10
doWhenAllScriptLoaded @ VM887:7351
(anonymous) @ VM887:15
loadBabelModules @ assubloader.js:1
async function (async)
loadBabelModules @ assubloader.js:1
window.loadBabelMod @ VM857:10
(anonymous) @ wrapNativeSuper.js:2
Show 67 more frames
[WXML Runtime warning] ./base.wxml
 Template `tmpl_0_31` not found.
  475 | 
  476 | <template name="tmpl_6_container">
> 477 |   <template is="{{xs.a(6, i.nn, l)}}" data="{{i:i,cid:6,l:xs.f(l,i.nn)}}" />
      |                ^
  478 | </template>
  479 | 
  480 | <template name="tmpl_7_0">

同样的问题,dev:weapp时必现,build:weapp没问题。 @b2nil prebundle.exclude配置后可以解决,感谢! 但有副作用,Windows的小程序IDE自动编译失效了,每次都要手动点编译才能渲染最新的内容。

prebundle.exclude 怎么配置的,我用了一个taro-ui的组件,前期是没问题的,下午突然发现不能使用了,
import { AtSwipeAction } from "taro-ui"; 只要导入这个组件就报错 dev:weapp时必现,build:weapp没问题。

@tomnattle
Copy link

问题解决了

 compiler: {
    type: "webpack5",
    prebundle: {
      enable: false,
      force: true,
    },
  },

同样的问题,dev:weapp时必现,build:weapp没问题。

VM946:22 WXMLRT_$gwx:./base.wxml:template:477:16: Template `tmpl_0_31` not found.
_wp @ VM946:22
_w @ VM946:1024
d_.<computed>.tmpl_6_container @ VM946:5126
xC @ VM946:4736
wfor @ VM946:571
_2z @ VM946:714
d_.<computed>.tmpl_5_2 @ VM946:4744
d_.<computed>.tmpl_5_container @ VM946:4892
xC @ VM946:4467
wfor @ VM946:571
_2z @ VM946:714
d_.<computed>.tmpl_4_2 @ VM946:4475
d_.<computed>.tmpl_4_container @ VM946:4623
xC @ VM946:4114
wfor @ VM946:571
_2z @ VM946:714
d_.<computed>.tmpl_3_2 @ VM946:4122
d_.<computed>.tmpl_3_container @ VM946:4354
xC @ VM946:3761
wfor @ VM946:571
_2z @ VM946:714
d_.<computed>.tmpl_2_2 @ VM946:3769
d_.<computed>.tmpl_2_container @ VM946:4001
xC @ VM946:3408
wfor @ VM946:571
_2z @ VM946:714
d_.<computed>.tmpl_1_2 @ VM946:3416
d_.<computed>.tmpl_1_container @ VM946:3648
xC @ VM946:2802
wfor @ VM946:571
_2z @ VM946:714
d_.<computed>.tmpl_0_2 @ VM946:2810
d_.<computed>.tmpl_0_container @ VM946:3295
xC @ VM946:2684
wfor @ VM946:571
_2z @ VM946:714
d_.<computed>.taro_tmpl @ VM946:2692
m2 @ VM946:7070
(anonymous) @ VM946:7200
io @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
_updateValues @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
updateValues @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
u.doUpdates @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
y.setData @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ vendors-node_modules_taro_weapp_prebundle_chunk-E2COQYTW_js.js? [sm]:2960
f @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
p @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
setTimeout (async)
globalThis.setTimeout @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
globalThis.setTimeout @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
performUpdate @ vendors-node_modules_taro_weapp_prebundle_chunk-E2COQYTW_js.js? [sm]:2891
(anonymous) @ vendors-node_modules_taro_weapp_prebundle_chunk-E2COQYTW_js.js? [sm]:855
wd @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:1098
$g @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:3665
Yg @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:3642
Xg @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:3623
Th @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:4424
Nh @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:4387
Eh @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:4050
J @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:119
R @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:151
f @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
p @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
setTimeout (async)
globalThis.setTimeout @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
globalThis.setTimeout @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
S @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:168
I @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:174
exports.unstable_scheduleCallback @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:269
Dh @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:4821
Z @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:3965
Ad @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:3927
enqueueForceUpdate @ vendors-node_modules_taro_weapp_prebundle_react-dom_js.js? [sm]:1139
E.forceUpdate @ vendors-node_modules_taro_weapp_prebundle_chunk-LNJCN3VW_js.js? [sm]:58
mount @ vendors-node_modules_taro_weapp_prebundle_tarojs_plugin-framework-react_dist_runtime_js.js? [sm]:285
mount @ vendors-node_modules_taro_weapp_prebundle_tarojs_plugin-framework-react_dist_runtime_js.js? [sm]:325
mount @ vendors-node_modules_taro_weapp_prebundle_chunk-E2COQYTW_js.js? [sm]:848
(anonymous) @ vendors-node_modules_taro_weapp_prebundle_chunk-E2COQYTW_js.js? [sm]:862
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
u.__callPageLifeTime__ @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
xr @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1675063375877&v=2.29.1:1
l.emit @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
emit @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
l.emit @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
emit @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
emit @ WAServiceMainContext.js?t=wechat&s=1675063375877&v=2.29.1:1
c @ VM9 asdebug.js:10
u @ VM9 asdebug.js:10
(anonymous) @ VM9 asdebug.js:1
f @ VM9 asdebug.js:1
(anonymous) @ VM9 asdebug.js:1
t.setAppserviceReady @ VM9 asdebug.js:1
handleLoadDone @ VM9 asdebug.js:10
(anonymous) @ VM9 asdebug.js:10
setTimeout (async)
proxyAlert @ VM9 asdebug.js:10
doWhenAllScriptLoaded @ VM887:7351
(anonymous) @ VM887:15
loadBabelModules @ assubloader.js:1
async function (async)
loadBabelModules @ assubloader.js:1
window.loadBabelMod @ VM857:10
(anonymous) @ wrapNativeSuper.js:2
Show 67 more frames
[WXML Runtime warning] ./base.wxml
 Template `tmpl_0_31` not found.
  475 | 
  476 | <template name="tmpl_6_container">
> 477 |   <template is="{{xs.a(6, i.nn, l)}}" data="{{i:i,cid:6,l:xs.f(l,i.nn)}}" />
      |                ^
  478 | </template>
  479 | 
  480 | <template name="tmpl_7_0">

同样的问题,dev:weapp时必现,build:weapp没问题。 @b2nil prebundle.exclude配置后可以解决,感谢! 但有副作用,Windows的小程序IDE自动编译失效了,每次都要手动点编译才能渲染最新的内容。

prebundle.exclude 怎么配置的,我用了一个taro-ui的组件,前期是没问题的,下午突然发现不能使用了, import { AtSwipeAction } from "taro-ui"; 只要导入这个组件就报错 dev:weapp时必现,build:weapp没问题。

@ZakaryCode ZakaryCode modified the milestones: 3.6.0, 3.6.1 Feb 1, 2023
@ZakaryCode ZakaryCode modified the milestones: 3.6.1, 3.6.2 Feb 10, 2023
@night-mao
Copy link

prebundle: {
enable: false,
force: true,
},

感谢感谢,我也解决了,♥️

@heiazu heiazu modified the milestones: 3.6.2, 3.6.3 Feb 24, 2023
@Chen-jj Chen-jj removed this from the 3.6.3 milestone Apr 3, 2023
@hefeilch
Copy link

@tomnattle 感谢恩人

@nevernet
Copy link

@tomnattle 感谢,我也是这个问题

@gooddaddy
Copy link

gooddaddy commented Apr 21, 2023

我的taro 3.6.2 的 没成功

usingComponents: {
contactCell: 'plugin://contactPlugin/cell',
},

[WXML Runtime warning] ./base.wxml
 Template `tmpl_0_contactcell` not found.
  479 |   
  480 | <template name="tmpl_5_container">
> 481 |   <template is="{{xs.a(5, i.nn, l)}}" data="{{i:i,cid:5,l:xs.f(l,i.nn)}}" />
      |                ^
  482 | </template>
  483 | 
  484 | <template name="tmpl_6_0">

@nevernet
Copy link

@gooddaddy 用前面的这个:

prebundle: {
  enable: false,
  force: true,
},

@gooddaddy
Copy link

gooddaddy commented Apr 24, 2023

@nevernet

在V3.6.2中 使用小程序的客服插件的时候会报错的,使用了上面的配置也不行。降到3.5.*的版本就可以

@mdddj
Copy link

mdddj commented Jun 1, 2023

有什么解决方案吗,配置后没生效

dev.js

  prebundle: {
    enable: false,
    force: true,
  }
{
    "@nutui/nutui-react": "^1.5.7"
}

@h1orz
Copy link

h1orz commented Jun 1, 2023

试试prebundle.exclude

...,
compiler: {
  ...,
  prebundle: {
    ...,
    exclude: ['taro-ui'], // 'taro-ui' 可以替换成其他你需要排除的库
  },
},

@mdddj
Copy link

mdddj commented Jun 1, 2023

试试prebundle.exclude

...,
compiler: {
  ...,
  prebundle: {
    ...,
    exclude: ['taro-ui'], // 'taro-ui' 可以替换成其他你需要排除的库
  },
},

测试后没有效果

  compiler: {
    type: 'webpack5',
    prebundle: {
      enable: false,
      force: true,
      exclude: ['nutui/nutui-react']
    }
  },
image

@h1orz
Copy link

h1orz commented Jun 2, 2023

测试后没有效果

  compiler: {
    type: 'webpack5',
    prebundle: {
      enable: false,
      force: true,
      exclude: ['nutui/nutui-react']
    }
  },
image

@mdddj 如果要排除@nutui/nutui-react,包名应该是@nutui/nutui-react,不是nutui/nutui-react。😄

@mdddj
Copy link

mdddj commented Jun 2, 2023

如果要排除@nutui/nutui-react,包名应该是@nutui/nutui-react,不是nutui/nutui-react。😄

多谢大佬回复,我已经用nutui 的模板新建项目解决了🙏

@night-mao
Copy link

@shaobeichen
Copy link

我们在taro使用原生组件时遇到这个问题。

@Chen-jj
Copy link
Contributor

Chen-jj commented Jul 28, 2023

Taro v3.6.9 后,修复了开启 webpack5 cache 后,二次编译报错找不到模板的问题。相关 PR:#14117

@llxcyzgh
Copy link

我用 taroui 也出现该问题, 使用

// compiler: 'webpack5',
    compiler: {
      type: 'webpack5',
      prebundle: {
        enable: false,
        force: true,
      },
    },

解决

@Airkro
Copy link

Airkro commented Oct 27, 2023

已确认该问题在 3.6.18 依然存在

关闭 prebundle,关闭 cache,手动删除 node_mdoules/.cache / node_mdoules/.taro ,均无法解决

@31231313131fdsf
Copy link

31231313131fdsf commented Oct 31, 2023

已确认该问题在 3.6.18 依然存在

关闭 prebundle,关闭 cache,手动删除 node_mdoules/.cache / node_mdoules/.taro ,均无法解决

我的解决了,是在dev.ts中写的吗 @Airkro

@starInEcust
Copy link

starInEcust commented Feb 21, 2024

我的3.6.23加taro-ui-3.3.0 也有问题,过年还好好的,坐个飞机代码被辐射了?
改成这样也不行

    cache: {
      enable: false, // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
    },
    prebundle: {
      enable: false,
      force: true,
      exclude: ['taro-ui'], // 'taro-ui' 可以替换成其他你需要排除的库
    },

@ricksunxxx
Copy link

3.6.26版本依然无效
compiler: {
type: 'webpack5',
prebundle: {
enable: false,
force: true
}
},
cache: {
enable: true
}

第一次打包还是会报模板找不到

@qq31311137
Copy link

这个其实是开启了 webpack5 的 prebundle ,只要引入了 @taro/components 的 Button 组件的页面都会报这个警告,有时候热更新几次后警告又没有了,会不会是 Button 组件开发的问题

@whinc
Copy link

whinc commented Apr 21, 2024

可以试试删除这个目录[项目路径]/node_modules/.taro,然后再启动构建

@oddguan
Copy link

oddguan commented Jun 3, 2024

今天碰到同样的问题。lock 删了重装以后好了

@rainlf
Copy link

rainlf commented Jun 16, 2024

@gooddaddy 用前面的这个:

prebundle: {
  enable: false,
  force: true,
},

It works for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React P-2 Medium, minor/patch T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests