windows环境微信小程序转Taro后再转RN运行会报TaroParseaTmpl.js文件找不到错误 #3569
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题描述
微信小程序转Taro后再转RN直接运行会报TaroParseaTmpl.js文件找不到错误:
Taro官方给出了解决方案
但是,问题并没有解决,经分析发现,是因为
taro convert
命令执行完成后会在taroConvert/src/imports/
目录下生成“TaroParse * Tmpl.js”文件,这些文件是基于微信小程序wxParse/wxParse.xml
文件转换而来。在windows系统下,因为windows不区分文件名字母大小写,TaroParseATmpl.js文件会与TaroParseaTmpl.js文件命名冲突,导致TaroParseaTmpl.js文件生成不了,代码运行时就会报TaroParseaTmpl.js文件找不到。分析taro-cli源码发现,tmpl文件的命名规则是从
a, b, c, d, e, f, g, h, i, j, z
的字符集中取值作为命名关键字以区分不同的tmpl文件。调整下字符集,去掉a
,加个k
就可以规避了。复现步骤
1.微信小程序项目中
wxParse/wxParse.xml
文件内容中循环模版只留wxParse1和wxParse2,1调2,2调1,其他wxParse2-10都去掉。2.在微信小程序根目录下执行taro转换指令
taro convert
3.进入taroConvert目录,执行
npm install
,安装完后执行npm run build:rn
4.构建出来的程序放到rn环境编译执行,报错
期望行为
希望windows下微信小程序转Taro时能生成正确的tmpl文件
报错信息
系统信息
这个 PR 是什么类型? (至少选择一个)
这个 PR 满足以下需求:
这个 PR 涉及以下平台:
其它需要 Reviewer 或社区知晓的内容: