Closed dimi-nk closed 6 years ago
Hey @dimi-nk , thanks for opening an issue with us. Have you seen these docs https://stenciljs.com/docs/angular-integration on how to use web components built with Stencil in an Angular project?
Also @dimi-nk , for why we have lazy loading built in I would recommend checking out https://www.youtube.com/watch?v=7vUs5yOuv-o&t=1021s . Just to explain a little bit about how it works. The tiny 5kb Stencil loader file registers what components might be used in your browser when it is loaded. Then, when and only when, that element hits the dom it loads the actual implementation of the component and renders. This means that if you use a component in your app, but its a few pages deep in the app, the JS for that component will not be loaded until the user goes to that page. This means that for the first view of your app, only the JS needed for components on that first page will be loaded. Hope this explains thing (:
@jgw96 as far as I can see, @kensodemann did the commit right after I posted this question. Either it was a diabolical coincidence or he used my solution for the guide (they do look quite similar). Either way it's fine, but on the time when I asked this question there was nothing on the guide. I had a chat on the slack channel about this and finally understood it. The issue was more so that others don't get the same question as I did ;)
BTW, when visiting the site again, I couldn't see the angular-integration
section (even though it worked on the direct link posted before). I had to clear clear my cache to see it. Maybe check your cache busting strategy.
@dimi-nk Sorry about that, didn't realize the timing on this issue. That doc was actually up before but was called something different. Ill check the cache strategy. Thanks for using Stencil!
I've recently found out about stencil and want to use it in an angular[5] application. Being used to webpack pre-bundling, the concept of lazy loading didn't resonate with me. Not that I don't like it, just not sure how that'll work with a bundled application.
In the current ditribution docs, it simply says:
That is not true when bundling and deploying the application, since
node_modules
won't exist. What should really happen is 'copy' thedist
folder of the stencil component to thedist
folder of the app.I think it'd worth explaining the concept of lazy loading a bit better and maybe provide better instruction for such a common use case.
For anyone interested, my angular5 solution is the following:
npm install
(ornpm link
during development) the stencil components dependency.angular-cli.json
, wheremy-name
is the dependency'spackage.json
name<script src='components/mycomponent.js'></script>
to yourindex.html
. The name ofmycomponent.js
comes from the actual setup of the stencil project.*The names used above are exactly the same names used in
stencil-component-starter