NervJS/taro

taro 3.5.1 缓存导致 base.wxml 里丢失原生组件的 props

Open

#12205 opened on Aug 3, 2022

View on GitHub
 (2 comments) (0 reactions) (0 assignees)TypeScript (37,306 stars) (4,897 forks)batch import
F-reactP-2T-weappV-3buggood first issue

Description

相关平台

微信小程序

小程序基础库: 无关 使用框架: React

复现步骤

  1. 项目中创建/引入一个原生的自定义组件, 比如 iconfont (直播组件 pendant, etc)

  2. 项目设置开启缓存:
    { compiler: 'webpack5', cache: { enable: true } }

  3. npm run build 首次编译 base.wxml 里面 带有 name="{{i.name}}" size="{{i.size}}" color="{{i.color}}" style="{{i.st}}" 这些自定义属性

  4. 再次 npm run build, 上述属性丢失, 界面无展示.

期望结果

实际结果

环境信息

 npx taro info                           
👽 Taro v3.5.1


  Taro CLI 3.5.1 environment info:
    System:
      OS: macOS 12.5
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 14.19.3 - ~/.nvm/versions/node/v14.19.3/bin/node
      npm: 7.24.2 - ~/.nvm/versions/node/v14.19.3/bin/npm
    npmPackages:
      @tarojs/cli: 3.5.1 => 3.5.1 
      @tarojs/components: 3.5.1 => 3.5.1 
      @tarojs/helper: 3.5.1 => 3.5.1 
      @tarojs/plugin-framework-react: 3.5.1 => 3.5.1 
      @tarojs/plugin-platform-alipay: 3.5.1 => 3.5.1 
      @tarojs/plugin-platform-weapp: 3.5.1 => 3.5.1 
      @tarojs/react: 3.5.1 => 3.5.1 
      @tarojs/router: 3.5.1 => 3.5.1 
      @tarojs/runtime: 3.5.1 => 3.5.1 
      @tarojs/shared: 3.5.1 => 3.5.1 
      @tarojs/taro: 3.5.1 => 3.5.1 
      @tarojs/taro-h5: 3.5.1 => 3.5.1 
      babel-preset-taro: 3.5.1 => 3.5.1 
      eslint-config-taro: 3.5.1 => 3.5.1 
      react: ^18.0.0 => 18.2.0 
      taro-ui: ^3.0.0-alpha.10 => 3.0.0-alpha.10 


补充信息

/packages/taro-webpack5-runner/src/plugins/TaroNormalModulesPlugin.ts line 65-67 prop.properties .filter(p => p.type === 'Property' && p.key.type === 'Identifier' && p.key.name !== 'children') .forEach(p => attrs.add(p.key.name))

首次build时, 这里生成了这些组件的 props 信息, 合并到 componentConfig.thirdPartyComponents 里; 后续build时, 这些信息没有缓存, 也没有重新执行这些代码, 就丢失了.

Contributor guide