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

原生混写模版中import的依赖没有全部编译输出 #5824

Closed
eriklynd opened this issue Mar 27, 2020 · 3 comments
Closed

原生混写模版中import的依赖没有全部编译输出 #5824

eriklynd opened this issue Mar 27, 2020 · 3 comments
Assignees

Comments

@eriklynd
Copy link

问题描述

Taro 代码与小程序代码混写时,模版xml有多个一级节点时,模版中的依赖没有正确编译输出。

复现步骤

  1. 使用小程序原生模版语法,模版最开始写多个<import src="..." />
  2. build
  3. 结果只有第一个import的依赖被输出,其余依赖没有输出

示例问题模版,仅有a.swan会被输出:

<import src="./a.swan" />
<import src="./b.swan" />
<import src="./c.swan" />
<import src="./d.swan" />

<view>
  <text>123</text>
</view>

期望行为

import的依赖都被编译输出

报错信息

无报错信息,编译产物缺失

系统信息

Taro CLI 2.0.7 environment info:
System:
OS: macOS 10.15.3
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm
npmPackages:
@tarojs/components: 2.0.7 => 2.0.7
@tarojs/components-qa: 2.0.7 => 2.0.7
@tarojs/mini-runner: 2.0.7 => 2.0.7
@tarojs/router: 2.0.7 => 2.0.7
@tarojs/taro: 2.0.7 => 2.0.7
@tarojs/taro-alipay: 2.0.7 => 2.0.7
@tarojs/taro-h5: 2.0.7 => 2.0.7
@tarojs/taro-qq: 2.0.7 => 2.0.7
@tarojs/taro-quickapp: 2.0.7 => 2.0.7
@tarojs/taro-rn: 2.0.7 => 2.0.7
@tarojs/taro-swan: 2.0.7 => 2.0.7
@tarojs/taro-tt: 2.0.7 => 2.0.7
@tarojs/taro-weapp: 2.0.7 => 2.0.7
@tarojs/webpack-runner: 2.0.7 => 2.0.7
eslint-config-taro: 2.0.7 => 2.0.7
eslint-plugin-taro: 2.0.7 => 2.0.7
nerv-devtools: ^1.5.5 => 1.5.6
nervjs: ^1.5.5 => 1.5.6
stylelint-config-taro-rn: 2.0.7 => 2.0.7
stylelint-taro-rn: 2.0.7 => 2.0.7

补充信息

parser.onattribute = ({ name, value }) => {
依赖的sax模块onattribute只被触发了一次。原因是sax仅会解析第一个一级节点,可能是sax的bug。

需要替换sax模块,或者将source整体包装在一个根节点中:

parser.write(source).close()

改为

parser.write(`<fakeroot>${source}</fakeroot>`).close()

如果您有功能上的建议,可以提到 FeatHub

使用上的问题,欢迎在「Taro 社区」一起交流

@taro-bot
Copy link

taro-bot bot commented Mar 27, 2020

CC @luckyadam

@taro-bot
Copy link

taro-bot bot commented Mar 27, 2020

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@wzono
Copy link
Contributor

wzono commented Aug 25, 2020

这么久了都不解决一下吗。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants