We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 对象,该如何构建才能再 h5 和 weapp 中运行?
import Taro from '@tarojs/taro';
因为 @tarojs/taro 在 h5 下需要替换成 @tarojs/taro-h5 才行,但是 taro cli 编译过程中,把 node_modules 中非包含 ‘taro’ 关键字的的包排除了, 导致第三方包没有被替换,运行就会报错。
@tarojs/taro
@tarojs/taro-h5
个人觉得有两种方案:
The text was updated successfully, but these errors were encountered:
https://github.com/NervJS/taro/blob/c171ddaedb413bac1f93a92f038f3a09a3e01e3b/packages/taro-webpack-runner/src/config/base.conf.ts#L22
由 webpack mainFields 决定的,@tarojs/taro 指向的 main-h5 导出引用的就是 @tarojs/taro-h5 包。
main-h5
CLI 排除的只是非 'taro' 关键词的包不走 babel-loader 而已(这个你也可以配 webpack chain 改一下 bable-loader 的参数,让它编译特定的包),和 webpack resolve 应该没关系。
babel-loader
Sorry, something went wrong.
这个具体的配置怎么配置?有点没看懂
我也遇到了,改了bable-loader之后引用其他文件的时候会出错 目前只能在调用的时候传入Taro
No branches or pull requests
我的组件 需要使用 Taro 对象,该如何构建才能再 h5 和 weapp 中运行?
import Taro from '@tarojs/taro';
因为
@tarojs/taro
在 h5 下需要替换成@tarojs/taro-h5
才行,但是 taro cli 编译过程中,把 node_modules 中非包含 ‘taro’ 关键字的的包排除了, 导致第三方包没有被替换,运行就会报错。个人觉得有两种方案:
@tarojs/taro
编译阶段动态根据平台引用@tarojs/taro-h5
The text was updated successfully, but these errors were encountered: