Skip to content

Component library with component that is composed of another does not render the base component #5851

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

Closed
lukef opened this issue Sep 5, 2020 · 6 comments

Comments

@lukef
Copy link

lukef commented Sep 5, 2020

Version

3.0.0-rc.10

Reproduction link

https://github.com/lukef/vue-component-repro

https://stackoverflow.com/questions/63758716/vue-3-component-library-with-component-that-is-composed-of-another-does-not-ren

Steps to reproduce

I have included a project that will demonstrate the issue. Instructions in README.

What is expected?

<cool-component> is derived from <base-component>. My expectation is that when <cool-component> is rendered that it should also render the base component as well. That isn't happening.

What is actually happening?

What happens is that <cool-component> is rendered but <base-component> (in this case <BaseComponent>) is not being rendered and is being translated to the literal tag <basecomponent> (no hyphen).


The console contains the following warning: [Vue warn]: resolveComponent can only be used in render() or setup().

Not really sure what I've done wrong with setup or whether this is a bug.

@posva posva transferred this issue from vuejs/core Sep 7, 2020
@posva
Copy link
Member

posva commented Sep 7, 2020

@lukef transferred to vue-cli as it seems related to how the build service is used

@posva
Copy link
Member

posva commented Sep 7, 2020

I think the issue actually comes from vue-next. Someone also opened vuejs/core#2064. Closing in favor of that one because the reproduction is much simpler

@posva posva closed this as completed Sep 7, 2020
@posva
Copy link
Member

posva commented Sep 7, 2020

See vuejs/core#2064 (comment). You also need to make sure your lib and app are using the same vue instance because right now they are both importing Vue from different files

@lukef
Copy link
Author

lukef commented Sep 7, 2020

I still don't see a solution to the issue in that other issue that resolves this one so I'm not really sure it is closed. I tried modifying the webpack config in my vue.config.js file to include:

vue$: path.resolve("./node_modules/vue/dist/vue.runtime.esm.js")

But this create a myriad of other issues if you're using vuex, vue-router, etc in the consuming project.

It shouldn't be this hard to make a component library for vue.

@lukef
Copy link
Author

lukef commented Sep 7, 2020

I also tried converting my plugin to use rollup via https://github.com/team-innovation/vue-sfc-rollup (4.0-beta) and I get the exact same issue. I made sure vue is a peerDependency and that it is external as per the ticket you linked.

@alvarosabu
Copy link

alvarosabu commented Sep 17, 2020

I'm having the same issue that @lukef in my library https://github.com/alvarosaburido/vue-dynamic-forms. If I use it on a typescript vue3 app like the. one in dev/typescript it works, but in a javascript one dev/vue, it doesn't

The console also output the following warnings:

[Vue warn]: resolveComponent can only be used in render() or setup().
[Vue warn]: Invalid VNode type: Symbol(Fragment) (symbol) at <AsDynamicForm form= {id: "example-form", fields: Array(4)} onSubmited=fn<handleSubmit> onChanged=fn<valueChanged> ... > at <App>

Screenshot 2020-09-17 at 08 06 19

@posva Is there a workaround that doesn't require changing to rollup?

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