skeepers

Skeepers Tech

Follow publication

StencilJS: A Deep dive into the inner workings of output targets

Alexandre Olive
skeepers
Published in
8 min readAug 29, 2023

--

StencilJS logo

Introduction on output targets

Possible output target results

Different types of output targets just for web components

3 different output target types

In your react/angular/vue app when you import your component, it’s using a web component in the background.

Every framework output is a wrapper for standard web component

1 — Webapp Output Target: WWW

stencil.config.ts file with only the Webapp Output Target
Live reload between index.html and component file (using npm start)
build result of the www output target (3 components in the library)

2— Distribution Output Target: dist

Most basic configuration for dist output target
Build result
Example of importing the component library from the head tag with browser ready folder
All 3 components are registred to the customElement registry
output-target-stencils.esm.js: entryfile with almost nothing inside. Second file is the stencil core file that is always loaded and last one is the used component file
Using the loader instead of the brower ready files

3 — Custom Elements: dist-custom-elements

Minimal config for dist-custom-elements output target
build result with just the components in separated files
CSS added at the top of the components file
Initialization of the component extending the HTMLElement
Only the component defined on the index.html is registred to the customElements
The defineCustomElement at the top is directly called after definition so just importing the js file is enough in the index.html
New function created by the bundle configuration
All components are exported from the index.js file

Conclusion

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Responses (1)

Write a response