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 组件编译问题 #4445

Closed
SzHeJason opened this issue Sep 11, 2019 · 7 comments
Closed

Taro 组件编译问题 #4445

SzHeJason opened this issue Sep 11, 2019 · 7 comments
Assignees

Comments

@SzHeJason
Copy link

SzHeJason commented Sep 11, 2019

问题描述

  1. 目前有项目使用了 Taro + lerna 的形式开发多组件方案,但是 Taro 的 UI 打包机制过于约束,无法让每个 package 各自打包组件,希望能支持通过传递参数来让指定文件编译成 Taro 包 , 让打包更加自由,(或则能通过babel、rollup、webpack 插件实现这种功能)

    image

  2. 不可通过第三方组件实现继承的效果,但是把第三方组件代码放到当前项目就好了

    image2

  3. 如果在 scss 文件下引用了第三方模块,会导致 UI 组件编译失败

@import "~taro-ui/dist/style/index.scss";
// 或者使用 alias 也会导致编译失败
@import "@common/taro-ui/dist/style/index.scss"
  1. 编译 UI 时,组件在 h5 下会自动添加不必要的代码
    image

  2. 编译UI之后, weapp 目录下的 alias 路径没有经过处理 (h5会转变成相对路径处理),导致项目引用组件时报错

// 编译前
import Base from '@common/base'

// 编译后的 weapp 文件下
import Base from '@common/base'

// 编译后的 h5 文件下
import BaseComponent from "../../../../common/base";

期望行为

  1. 编译指定组件为 Taro 组件

     # 编译指定组件为 Taro 组件
     taro build --ui --config ../config/index.js
  2. 可以继承第三方组件

  3. 正常编译通过

系统信息
image

@taro-bot
Copy link

taro-bot bot commented Sep 11, 2019

欢迎提交 Issue~

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

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

Good luck and happy coding~

@taro-bot
Copy link

taro-bot bot commented Sep 16, 2019

CC @luckyadam

@SzHeJason
Copy link
Author

https://github.com/SzHeJason/taro-bug-demo 写了一个示例库

@SzHeJason
Copy link
Author

SzHeJason commented Nov 4, 2019

用以下方式打包失败

import Taro from '@tarojs/taro'

import component from './components/a-x/ui/component/index'

// 失败
export default component

// 成功
export { default as component }

@SzHeJason
Copy link
Author

css module 无法编译 UI 组件
image

@kyjo2014
Copy link

当前行为

缺少对import { component as xxxx} from 'xxxx' 的支持
当使用 export { default as xxxx } from 语法导出组件,编译时会报
“路径错误,请检查!(可能原因是导出的组件名不正确”

期望行为

正常引入组件

@luckyadam
Copy link
Member

75f8d11

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

4 participants