core README

The project's README from github.com/stenciljs/core. As one markdown file: README.md.

stencil-logo

Stencil

A compiler for generating Web Components using technologies like TypeScript and JSX, built by the Ionic team.

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

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

Getting Started

Start a new project by following our quick Getting Started guide. We would love to hear from you! If you have any feedback or run into issues using Stencil, please file an issue on this repository.

Examples

A Stencil component looks a lot like a class-based React component, with the addition of TypeScript decorators:

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

@Component({
  tag: 'my-component',            // the name of the component's custom HTML tag
  styleUrl: 'my-component.css',   // css styles to apply to the component
  shadow: true,                   // this component uses the ShadowDOM
})
export class MyComponent {
  // The component accepts two arguments:
  @Prop() first: string;
  @Prop() last: string;

   //The following HTML is rendered when our component is used
  render() {
    return (
      <div>
        Hello, my name is {this.first} {this.last}
      </div>
    );
  }
}

The component above can be used like any other HTML element:

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

Since Stencil generates web components, 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 framework, though using it as such is certainly not required.

Contributing

Thanks for your interest in contributing! Please take a moment to read up on our guidelines for contributing. We've created comprehensive technical documentation for contributors that explains Stencil's internal architecture, including the compiler, runtime, build system, and other core components in the /docs directory. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

core (stenciljs/core)

Searching Database…

13.1K ·GitHub
这是什么?Stencil 是一个编译器,它使用 TypeScript 和 JSX 生成符合标准的 Web Components,让你只需构建一个组件库,就能在 React、Angular、Vue 以及普通网页应用中原生使用。
Stencil 是框架还是编译器?它是一个编译器/工具链,而不是运行时框架。它把你的组件编译成标准的 Web Components,不绑定任何框架,因此产物可以放进任何应用中使用,也可以不用于任何应用。
我该如何开始一个新的 Stencil 项目?你可以按照官方的 Getting Started 指南操作,它会为你生成一个新的 Stencil 组件项目。
我需要特定版本的 Node 或 npm 吗?需要。Stencil 要求 Node.js 16 或更高版本,以及 npm 7.10 或更高版本,才能进行构建和开发。
编写组件需要了解 TypeScript 装饰器和 JSX 吗?需要。Stencil 组件是用 TypeScript 类编写的,并使用 Stencil 装饰器,模板部分使用 JSX,风格上类似基于类的 React 组件。
Stencil 会取代 React 或 Angular 这类框架吗?不一定。Stencil 可以直接替代前端框架使用,但这并非必需,因为生成的组件也可以与现有框架一起工作。
用 Stencil 构建的组件可以在没有任何 JavaScript 框架的情况下使用吗?可以。由于它们编译为原生 Web Components,Stencil 组件可以直接运行在纯 HTML/JS 页面中,完全不需要任何框架。
Stencil 支持服务端渲染或静态站点生成吗?该项目的主题标签包括 SSR、SSG 和 static-site-generator,表明它可以为这些用途预渲染组件。
我为什么要选择 Stencil,而不是分别编写 React 或 Vue 组件?Stencil 让你只维护一套组件代码,并将其原生分发到 React、Angular、Vue 和原生 Web 应用中,避免为每个框架重复实现。
Creator
stenciljs
Size
88.3 MB
Stars
13.1K
Age
9y
Commits · 90 Days