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

require('react-slick') 这种库的时候,由于 fis3-hook-component 插件的问题,会失败 #74

Closed
GilbertSun opened this issue Dec 20, 2015 · 5 comments

Comments

@GilbertSun
Copy link

react-slick 库的结构是这样的

image

component.json 里面是这样定义的

image

在 fis3-hook-components 里,查找文件代码是这样的

    if (subpath) {
      resolved = findResource('/' + componentsDir+ cName + '/' + subpath, file ? file.dirname : fis.project.getProjectPath());
    } else {
      resolved = findResource('/' + componentsDir + cName + '/' + (config.main || 'index'), file ? file.dirname : fis.project.getProjectPath());

      if (!resolved.file) {
        resolved = findResource('/' + componentsDir + cName + '/' + cName, file ? file.dirname : fis.project.getProjectPath());
      }
    }

对于 react-slick 来说,能命中的文件路径为

/component/react-slick/./lib
或者
/component/react-slick/react-slick

没有办法命中正确的路径

/component/react-slick/.lib/index

如果按照 commonjs 规范,应该是可以命中的

是不是考虑在 fis3-hook-component 中实现,或者修改 react-slick 的 main 属性

@2betop
Copy link
Contributor

2betop commented Dec 20, 2015

应该在 fis3-hook-commonents 里面实现,带我周一实现。

@2betop
Copy link
Contributor

2betop commented Dec 21, 2015

虽然已修复这个问题,但是要使用 react-slick 还存在其他问题。悲剧,他内部用了 react/lib/ 下面的模块。

@GilbertSun
Copy link
Author

对,我早上也发现了,这种用法其实不好,本来 commonjs 就是单一出口的,这个引用包内部的东西很容易不兼容,但是让 fis3-hook-components 支持这种用法有点太恶心了,不仅需要支持,而且还得让 react 的 lib 目录进到 fis 的包里

@2betop
Copy link
Contributor

2betop commented Dec 21, 2015

不过,我打算把这个项目特殊化一下,用他的 dist 版本好了

@2betop
Copy link
Contributor

2betop commented Dec 21, 2015

改成用 dist 了,应该就没问题了。https://github.com/fis-components/react-slick

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

2 participants