ionic-team / stencil

A toolchain for building scalable, enterprise-ready component systems on top of TypeScript and Web Component standards. Stencil components can be distributed natively to React, Angular, Vue, and traditional web developers from a single, framework-agnostic codebase.
https://stenciljs.com
Other
12.52k stars 782 forks source link

Cannot use defineCustomElements to integrate an external Stencil component into my current component #1815

Closed TommiChi closed 2 years ago

TommiChi commented 5 years ago

Stencil version:

 @stencil/core@1.1.7

I'm submitting a: [x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior: Javascript error "TypeError: Cannot read property '$instanceValues$' of undefined"

Expected behavior: External Stencil component successfully renders

Steps to reproduce:

  1. Import the "defineCustomElements" method from the required external Stencil component eg. import { defineCustomElements } from 'external-component/loader';
  2. Execute "defineCustomElements(window)"

Related code:

import { defineCustomElements } from 'external-component/loader';
defineCustomElements(window);

Other information: defineCustomElements works as expected when used in other frameworks such as Angular, but not when called inside of a Stencil component (.tsx file)

TommiChi commented 5 years ago

Updating my version of Stencil to 1.2.5 yields the same behaviour

TommiChi commented 5 years ago

Hi guys,

Does anyone have some feedback for me? Do you need more information? Are there additional details I need to add to the ticket?

Thanks!

arjunyel commented 5 years ago

When using stencil in stencil instead of using that defineCustomElements function try to just import the library of the other component. Examples:

https://github.com/ionic-team/ionic-pwa-toolkit/blob/master/src/global/app.ts

https://stenciljs.com/docs/distribution#in-a-stencil-app-starter-app

splitinfinities commented 2 years ago

Hey folks! This is on an old version of Stencil. If you are still having this issue on latest versions, please make a new ticket!