Skip to content

Vite 模式下对小程序原生组件的模板语法 {{}} 解析问题 #16982

Open
@linzhou559

Description

@linzhou559

相关平台

微信小程序

复现仓库

https://github.com/linzhou559/taro-vite-wxml-template-bug.git
小程序基础库: 3.4.6
使用框架: React

复现步骤

在 Vite 模式下,小程序原生组件的 wxml 模板中使用 {{}} 语法会导致编译错误。Webpack 模式下同样的代码可以正常工作。

期望结果

vite下可以正常解析

实际结果

报错

[Error: ENOENT: no such file or directory, open '/Users/kl/jlz/Code/myApp/src/components/native-test/{{src}}'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/kl/jlz/Code/myApp/src/components/native-test/{{src}}'
}

环境信息

👽 Taro v3.6.19


  Taro CLI 3.6.19 environment info:
    System:
      OS: macOS 14.2.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
      Yarn: 1.22.19 - /opt/homebrew/bin/yarn
      npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
    npmPackages:
      @tarojs/cli: 4.0.7 => 4.0.7 
      @tarojs/components: 4.0.7 => 4.0.7 
      @tarojs/helper: 4.0.7 => 4.0.7 
      @tarojs/plugin-framework-react: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-alipay: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-h5: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-jd: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-qq: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-swan: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-tt: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-weapp: 4.0.7 => 4.0.7 
      @tarojs/react: 4.0.7 => 4.0.7 
      @tarojs/runtime: 4.0.7 => 4.0.7 
      @tarojs/shared: 4.0.7 => 4.0.7 
      @tarojs/taro: 4.0.7 => 4.0.7 
      babel-preset-taro: 4.0.7 => 4.0.7 
      eslint-config-taro: 4.0.7 => 4.0.7 
      react: ^18.0.0 => 18.3.1 

Metadata

Metadata

Assignees

No one assigned

    Labels

    F-reactFramework - ReactT-weappTarget - 编译到微信小程序V-4Version - 4.x

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions