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 build ui,h5 生成 js 正常,weapp 仍然为 ts 文件 #1776

Closed
lbb00 opened this issue Jan 2, 2019 · 9 comments
Closed

taro build ui,h5 生成 js 正常,weapp 仍然为 ts 文件 #1776

lbb00 opened this issue Jan 2, 2019 · 9 comments
Assignees

Comments

@lbb00
Copy link

lbb00 commented Jan 2, 2019

开发了一个组件库,使用了typescript,在taro build ui后发现h5端的代码构建为js正常,但是weapp端的代码构建后仍然为.tsx、.ts文件。
不清楚是否是正常的情况。

@taro-bot
Copy link

taro-bot bot commented Jan 2, 2019

欢迎提交 Issue~

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

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

Good luck and happy coding~

@lbb00
Copy link
Author

lbb00 commented Jan 2, 2019

并且在使用自己打包的UI库时,报了这个错误

./node_modules/[email protected]@xcandy/dist/h5/components/Arrow/index.js 31:11
Module parse failed: Unexpected token (31:11)
You may need an appropriate loader to handle this file type.
|       transform: trans
|     };
>     return <View style={finalStyle} className={className} />;
|   }
| }

@luckyadam
Copy link
Member

因为 weapp 用的是源码,H5 用的处理后的代码

报错的问题,你要增加这个配置
https://nervjs.github.io/taro/docs/config-detail.html#h5esnextmodules

@lbb00
Copy link
Author

lbb00 commented Jan 2, 2019

@luckyadam
我添加了配置,但是仍然没有生效,我做了一个demo:

https://github.com/loveonelong/x-candy-test-demo
麻烦大佬可以帮忙定位一下原因。

@luckyadam
Copy link
Member

cli 和依赖都升级到最新版本

@lbb00
Copy link
Author

lbb00 commented Jan 3, 2019

@luckyadam 找到问题了。
使用cnpm的包会在moduleName开头加一个_
注意下面这行报错,例如xcandy实际引用为[email protected]@xcandy

./node_modules/[email protected]@xcandy/dist/h5/components/Arrow/index.js 31:11

不知道能否兼容一下。
设置 esnextModules: ['xcandy'] 无效,但是改为'_xcandy'就没问题了

@lbb00
Copy link
Author

lbb00 commented Jan 3, 2019

我稍后提一个pr

@luckyadam luckyadam added the H5 label Jan 3, 2019
@taro-bot taro-bot bot assigned Littly Jan 3, 2019
@taro-bot
Copy link

taro-bot bot commented Jan 3, 2019

CC @Littly

@lbb00
Copy link
Author

lbb00 commented Jan 3, 2019

#1796

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