Draft:StencilJS

From Wikipedia, the free encyclopedia
  • Comment: Issues raised at the AfD have not been addressed. Please stop continually repasting this content. That is not a path to approval. Star Mississippi 11:26, 9 April 2024 (UTC)

StencilJS
Original author(s)Adam Bradley
Developer(s)Ionic (mobile app framework)
Initial releaseMay 20, 2017; 7 years ago (2017-05-20)
RepositoryStencilJS Repository
Written inTypeScript
PlatformJavaScript engine
Size16.5 KB[1]
TypeWeb framework
LicenseMIT License[2]
Websitestenciljs.com

StencilJS is a JavaScript compiler that creates custom element (web components).[3] It takes in TSX files, (which are basically JSX with TypeScript) a tiny virtual DOM layer, efficient one-way data binding, an asynchronous rendering pipeline (similar to React Fiber), and lazy-loading out of the box, and then generate 100% standards-based Web Components that run on both modern browsers and legacy browsers supporting the Custom Elements v1 spec, usable with any web framework including Angular, React, and Vue.js.[4][5] StencilJS relies primarily on the power of browsers and the web component specification.

StencilJS helps developers and teams build and share custom components (Microfrontend), that are web framework agnostic.[6][7] Since StencilJS generates standards-compliant Web Components, the components built with StencilJS work with many popular frameworks. While Web Components can be paired with any JavaScript framework, StencilJS has built-in special-purpose bindings to deliver the more advanced features, enterprise teams expect when building applications in Angular, React, and Vue.js. StencilJS generate automatically-updated documentation from JSDoc comments used with code. Its source code is licensed under MIT License and hosted on GitHub.[8]

StencilJS provides a build-time abstraction with framework-level productivity. StencilJS is not a library or a framework, instead it is a building tool that allows to use a high-level abstraction to define UI components and to generate pure JavaScript code implementing standard-based Web Components. The compiled code runs in all major browsers. StencilJS generates framework-specific wrappers that allow custom elements developed, to be used with any framework, whether its Angular, React, or Vue.js.[9]

History[edit]

StencilJS was built by the Ionic (mobile app framework) team.[10][11] The beta version of StencilJS was released in 2017.[12] Stencil version one was officially released on 3 June 2019. Ionic 4 was built using StencilJS.[13]

Design Systems[edit]

The main goal of enterprise teams to use StencilJS is, to build design systems and component libraries,[14][15] that are web framework agnostic.[16][17] StencilJS can be used to build Progressive web app (PWA).[18][19] Several companies like Upwork, Volkswagen, Porsche, MasterCard, Amazon, Adidas, Panera etc. have built their design systems based on Stencil-based Web Components.[20][21] Liberty Mutual Ins. Group's Design System FLUID (Frontend Library for User Interface Development) is built using StencilJS.[22] The music streaming platform Amazon Music is built using StencilJS.

Basic usage[edit]

A StencilJS component looks similar to a class-based React component, with the addition of TypeScript decorators.

import { Component, h, Prop, State } from '@stencil/core';

@Component({
  tag: 'my-component',
  styleUrl: 'my-component.css',
  shadow: true // Enable Shadow DOM
})
export class MyComponent {
  @Prop() name: string;
  @State() count: number = 0;

  increment() {
    this.count++;
  }
  render() {
    return (
      <div>
        <p>Hello, {this.name}!</p>
       <p>Count: {this.count}</p>
        <button onClick={() => this.increment()}>Increment</button>
      </div>
    );
  }
}

Notable features[edit]

Web Components[edit]

StencilJS is centered around the Web Components standard, which comprises Custom Elements, Shadow DOM and HTML Templates.

Framework Agnostic[edit]

StencilJS is framework agnostic, that means it can be used with any JavaScript framework or library, including Angular, React, Vue.js, or even vanilla JavaScript. This flexibility allows developers to leverage StencilJS in their existing projects without being tied to a specific framework.

Built-in Routing and State Management[edit]

An entire single-page application (SPA) can be built with StencilJS without relying on external libraries, as StencilJS provides built-in routing and state management capabilities.

Shadow DOM[edit]

Each StencilJS component has its own Shadow DOM, which encapsulates the component's HTML structure, styles, and behavior, isolating it from the surrounding document. It also avoids CSS conflicts and specificity issues.

See also[edit]

References[edit]

  1. ^ "Stencil/core@3.2.2". BundlePhobia. May 8, 2023.
  2. ^ "Stencil Maintenance and Support Status".
  3. ^ "CSS-in-JS with StencilJs". 31 January 2020.
  4. ^ "Stencil.js: it's finally time for vanilla web components!". 19 July 2019.
  5. ^ "Publishing and Integrating a StencilJS Web Component in React". 3 October 2019.
  6. ^ "Web Components & Stencil.js - Build Custom HTML Elements".
  7. ^ Yasmin, Afroza (8 March 2020). "My First Experience with StencilJS". Medium.
  8. ^ "GitHub - StencilJS Repository/stenciljs: toolchain for building scalable, enterprise-ready component system". January 11, 2020 – via GitHub.
  9. ^ "Framework agnostic component libraries with StencilJs and Nx". 7 February 2022.
  10. ^ "Building Micro Frontends with Stencil Web Components". 9 February 2022.
  11. ^ "Stencil Readme". 23 May 2023.
  12. ^ Hawkins, Tyler (April 2021). "Web Component Solutions: A Comparison". Medium.
  13. ^ "Introduction to Stenciljs". 9 August 2018.
  14. ^ "Orgenic Github". GitHub.
  15. ^ "DOCS".
  16. ^ "Design Systems: Building a Cross-Functional UI Library with Stencil.js". 10 March 2021.
  17. ^ "Creating a Reusable Web Component with StencilJS". 3 October 2019.
  18. ^ "Building a PWA with Stencil: An Introduction to StencilJS". 3 September 2019.
  19. ^ "Build A Fast Offline-First PWA with StencilJs". 12 October 2017.
  20. ^ "github porsche". GitHub.
  21. ^ "Welcome to new digitl".
  22. ^ "FLUID CDN".

External links[edit]

Category:2017 software Category:Compilers Category:Web development Category:Software using the MIT license