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

在被暴露的组件里面嵌入element-plus组件报错 #251

Open
lisering opened this issue Oct 9, 2022 · 4 comments
Open

在被暴露的组件里面嵌入element-plus组件报错 #251

lisering opened this issue Oct 9, 2022 · 4 comments

Comments

@lisering
Copy link

lisering commented Oct 9, 2022

Uncaught (in promise) TypeError: isObject is not a function
at buildProp (__federation_expose_Button.16438993.js:81:8)
at __federation_expose_Button.16438993.js:171:21

@lisering lisering changed the title remote component inline element-plus component 在被暴露的组件里面嵌入element-plus组件报错 Oct 9, 2022
@flyfishzy
Copy link
Member

I have the same problem in vue3-advanced-demo. The solution is to add the element-plus to the HOST project as well, even if you don't use it yet.
When I looked deeper into the problem, I found it interesting. Vue3 doesn't export the isObject function, so the chunk generated by shared doesn't export isObject either, that causes the probelm. Another interesting point is that element-plus will have no problem using vue via CDN, because using vue via CDN will define isObject globally.

const isObject = (val) => val ! == null && typeof val === 'object';

To summarize, I haven't found any other better solution, so for now try to make sure the host and remote dependency libraries are consistent.


我在vue3-advanced-demo也遇到了同样的问题。解决办法是把element-plus也添加到HOST项目中,即使还没有使用它。
当我深入研究这个问题时,发现了一个有趣的现象。 Vue3没有导出isObject函数,所以shared生成的chunk也没有导出isObject,从而导致了这个问题。另一个有趣的地方是,element-plus通过CDN使用vue不会有问题,因为通过CDN使用vue会全局定义isObject

const isObject = (val) => val ! == null && typeof val == 'object';

总结一下,我还没有找到其他更好的解决方案,所以现在要尽量确保主机和远程依赖库的一致性。

@dqdeep
Copy link

dqdeep commented Nov 29, 2022

在host工程中也使用 ElementUI 这样在 __federation_shared_vue.js 文件中就会导出 isObject 这个函数

@dadaguai-git
Copy link

我也遇到这种问题 当我remote模块依赖ui组件是 host端调用 样式总是丢失 除了在host端安装相同依赖还有其他办法么

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I also encountered this problem. When my remote module depends on ui components and is called on the host side, the styles are always lost. Is there any other way besides installing the same dependencies on the host side?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants