JSPM

@stencil/core

2.15.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 750066
  • Score
    100M100P100Q182395F
  • License MIT

A Compiler for Web Components and Progressive Web Apps

Package Exports

  • @stencil/core
  • @stencil/core/compiler
  • @stencil/core/compiler/stencil.js
  • @stencil/core/internal
  • @stencil/core/internal/app-data
  • @stencil/core/internal/app-data/index.cjs
  • @stencil/core/internal/app-data/index.js
  • @stencil/core/internal/client
  • @stencil/core/internal/client/index.js
  • @stencil/core/internal/index.js
  • @stencil/core/internal/stencil-core/index.cjs
  • @stencil/core/internal/stencil-core/index.js
  • @stencil/core/mock-doc
  • @stencil/core/mock-doc/index.cjs
  • @stencil/core/mock-doc/index.js
  • @stencil/core/testing
  • @stencil/core/testing/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@stencil/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

stencil-logo

Stencil

A compiler for generating Web Components

StencilJS is released under the MIT license. StencilJS is released under the MIT license. PRs welcome! Follow @stenciljs

Quick Start · Documentation · Contribute · Blog
Community: Slack · Forums · Twitter

Stencil is a simple compiler for generating Web Components and static site generated progressive web apps (PWA). Stencil was built by the Ionic team for its next generation of performant mobile and desktop Web Components.

Stencil combines the best concepts of the most popular frontend frameworks into a compile-time rather than run-time tool. It combines TypeScript, JSX, an asynchronous rendering pipeline to ensure smooth running animations and lazy-loading, to generate 100% standards-based Web Components that run on both modern browsers and legacy browsers.

Stencil components are just Web Components, so they work in any major framework or with no framework at all. In many cases, Stencil can be used as a drop in replacement for traditional frontend frameworks given the capabilities now available in the browser, though using it as such is certainly not required.

Stencil also enables a number of key capabilities on top of Web Components, in particular Server Side Rendering (SSR) without the need to run a headless browser, pre-rendering, and objects-as-properties (instead of just strings).

Getting Started

To create a new project using an interactive cli, run:

npm init stencil

To start developing your new Stencil project, run:

npm start

Creating components

Stencil components are TypeScript classes with decorator metadata. The decorators themselves are purely build-time annotations so the compiler can read metadata about each component, and removed entirely for smaller efficient components.

Create new components by creating files with a .tsx extension, such as my-component.tsx, and place them in src/components.

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

@Component({
  tag: 'my-component',
  styleUrl: 'my-component.css'
})
export class MyComponent {

  @Prop() first: string;
  @Prop() last: string;

  render() {
    return (
      <div>
        Hello, my name is {this.first} {this.last}
      </div>
    );
  }
}

To use this component, just use it like any other HTML element:

<my-component first="Stencil" last="JS"></my-component>

Thanks

Stencil's internal testing suite is supported by the BrowserStack Open-Source Program