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
index.js in dist/esm folder is empty and will cause component not being load in html pages #2826
Comments
Any news on this? |
Just wanted to share my experience running into this issue as well. Was looking to use web-social-share, which is generated by Stencil but found too that all its ESM entry points are empty. The As an interim solution / work around for anyone curious, I forked the library and changed its import(`./${n}.entry.js`).then(...) I had to add the dynamic-import-vars plugin, then things worked. 🙌 Hope this could get fixed for creators and consumers alike! ✌️ |
Just ran into this issue, and figured out that I need to export the components from
|
@mlynch, would you know why this happens? What's the documentation missing in this regard? |
Hi @RezaRahmati and everyone else experiencing this 👋 So sorry this has sat so long. I was able to quickly verify this is a problem with the latest version of Stencil. It appears @wolthers found a workaround, but I'll still go ahead and get this labeled so the team can take a look at what's going on and see what we can do on our end. Thanks again for the issue! |
Thanks for your hard work @tanner-reits! I'm experiencing this issue also, but @wolthers' workaround only got me one step further before something else impeded me. When I import the component class from the dist folder into my demo, I get this error message: |
What was the last version where this was working? I've tried all the way back to 2.12 and all indexes are empty. |
Still valid in 4.0.0. |
We ran into this at version 4.7 as well. |
Yeap this is still an issue |
I don't remember if I got to this place by my own mistakes, but I see a few things:
Edit
Where
but doesn't seem to execute anything, relevant? The usage documentation for |
Hey you all 👋 I looked into the issue and hope I can shed some light into this. We have internal discussions within the Stencil team and work on creating and prioritising tickets to tackle this. I can't speak much about the issue from the OP since I don't have a reproducible example and I can't say for sure if the issue has been solved since To @thescientist13 comment:
I looked into the project and was able to get an ESM export working after some tweaks summarized in peterpeterparker/web-social-share#63
@wolthers I would not recommend doing this. I would consider code within {
type: 'dist-custom-elements',
customElementsExportBehavior: 'single-export-module',
externalRuntime: false
} This creates a standalone ESM component in
@jonathandewitt-dev I assume you tried to manually register the component from
@alevilar this is "kinda" expected behavior since this file is suppose to be for your package code (stuff that doesn't need rendering like utility functions etc.). This is very confusing and we intend to clean up this confusion.
@mattclough1 there are basically two ways to distribute Stencil components right now: 1. Through CDN or Custom Static Host This makes it technically very easy to distribute components of a design system. You just push it to NPM and use any CDN to pull Stencils lazy loading mechanism, access any component but only load the ones you need. For example if I create a “foobar-design-system” through the component starter utility and push it to NPM. All I need to do, to access the components in my web app is injecting a script into the page, e.g.: <script type="module" src="https://unpkg.com/foobar-design-system@0.0.1/dist/foobar-design-system/foobar-design-system.esm.js"></script> This loads a minified version of the bootstrap logic that knows about all components but only loads the ones that are initiated in my application. 2. As Component Library The other way of integrating Stencil components in any arbitrary project is through importing them directly. Stencil currently allows you either import the component directly and have you register it to the Custom Element Registry: import { AnotherComponent } from 'foobar-design-system/dist/components/another-component.js'
import { MyComponent } from 'foobar-design-system/dist/components/my-component.js'
customElements.define('my-component', MyComponent)
customElements.define('another-component', AnotherComponent) or import a helper do that for you: import { defineCustomElement as defineAnotherComponent } from 'foobar-design-system/dist/components/another-component.js'
import { defineCustomElement as defineMyComponent } from 'foobar-design-system/dist/components/my-component.js'
defineAnotherComponent()
defineMyComponent() Again, this is not very clear based from our docs and the component starter tool. We intend to clear up this confusion. |
@christian-bromann thanks! Yeah the
For my own purposes I've actually gone ahead and just made the |
@mattclough1 thanks for the feedback. I have ingested separate tickets into our team backlog to:
I will go ahead and close this issue. I am happy to answer any questions in case folks have more questions. Thanks for all your input 🙏 |
need to use the components/index.js file for the time being. there is a known bug and Stencil is currently working on it. you can find more out [here](ionic-team/stencil#2826)
need to use the components/index.js file for the time being. there is a known bug and Stencil is currently working on it. you can find more out [here](ionic-team/stencil#2826)
you can find more info at ionic-team/stencil#2826
Stencil version:
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:
in the dist folder, index.js content is
Then in the esm folder, content of index.js is empty
Expected behavior:
There should be something is index.js otherwise nothing will be loaded when referencing like
https://cdn.jsdelivr.net/npm/@zoot-ai/widget@0.1.31/dist/index.js
Steps to reproduce:
npm init stencil
and choosecomponent
npm install
npm build
dist
folderRelated code:
I tried to load my component in jsfiddle by this code, but
whenDefined
is never resolved(I added https://cdn.jsdelivr.net/npm/@zoot-ai/widget@0.1.31/dist/index.js as reference in my jsfiddle)
// insert any relevant code here
Other information:
I take a look at ionic, and seems file is not empty
https://cdn.jsdelivr.net/npm/@ionic/core/dist/index.js
and
https://cdn.jsdelivr.net/npm/@ionic/core/dist/esm-es5/index.js
The text was updated successfully, but these errors were encountered: