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

Make it possible to register global components for use in defineCustomElement #4511

Closed
AlbertBrand opened this issue Sep 3, 2021 · 3 comments

Comments

@AlbertBrand
Copy link

What problem does this feature solve?

We have a large component that uses global components to lessen the burden of writing imports for components. We wrap this component in a web component for a while now with a piece of custom code, and we want to use the new defineCustomElement for it. However, the new API doesn't create an app context but 'simply' renders the root component. Which makes it impossible to have global components inside web components (it seems).

Is there a way to register global components for use inside web components, or a way of passing in an existing app context, or get a hold of an app context during creation?

What does the proposed API look like?

// this is inspired on how our current API looks like:
const customElement = defineCustomElement(VueComponent, (app) => {
  provideContexts(app);
  includeGlobalComponents(app);
});

window.customElements.define( // etc
@gnuletik
Copy link

Your issue seems to address two issues :

  • app context
  • global components

For app context, you can use provide in a root web component and use inject inside your child components.

However, if you use intermediate Vue components (which are not rendered as Custom Elements), the inject API would fail because the Provide/Inject API only works between Vue's Custom Elements. See #4476
Check my comment here for an example : #4476 (comment)

Being able to register global components would be nice though!

@Atlas-lili
Copy link

Can defineCustomElement accept a Vue App callback function. I need to export a large Vue project as a WebComponent to a React environment. The defineCustomElement is not ideal in terms of internal and external style isolation and the use of Vue middleware.

@yyx990803
Copy link
Member

Closing as duplicate / subset of #4635

@yyx990803 yyx990803 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 7, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants