npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@stencil/templates

v5.0.0-alpha.28

Published

Project and generate templates for Stencil

Downloads

2,152

Readme

@stencil/templates

Boilerplate generators and project templates for Stencil — used internally by stencil generate and stencil init.

Install

npm install --save-dev @stencil/templates

API

getComponentBoilerplate(tagName, styleExtension?) — component TSX

Generates the .tsx file content for a new Stencil component:

import { getComponentBoilerplate } from '@stencil/templates';

// With a stylesheet
const tsx = getComponentBoilerplate('my-button', 'css');

// Without (no styleUrl in @Component decorator)
const bare = getComponentBoilerplate('my-button');

styleExtension accepts 'css', 'scss', 'sass', or 'less'.

Output for getComponentBoilerplate('my-button', 'css'):

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

@Component({
  tag: 'my-button',
  styleUrl: 'my-button.css',
  encapsulation: { type: 'shadow' },
})
export class MyButton {
  render() {
    return (
      <Host>
        <slot></slot>
      </Host>
    );
  }
}

getStyleBoilerplate(ext) — stylesheet

Generates the initial stylesheet content. Pass the file extension — not the tag name:

import { getStyleBoilerplate } from '@stencil/templates';

const css  = getStyleBoilerplate('css');   // :host {\n  display: block;\n}
const scss = getStyleBoilerplate('scss');  // same, brace syntax
const sass = getStyleBoilerplate('sass'); // :host\n  display: block  (indented syntax)

toPascalCase(str) — tag name to class name

Converts a dash-case tag name to a PascalCase class name:

import { toPascalCase } from '@stencil/templates';

toPascalCase('my-button');       // 'MyButton'
toPascalCase('ui-card-header');  // 'UiCardHeader'

generateStencilConfig(selections)stencil.config.ts source

Generates the content for a stencil.config.ts file based on wizard selections. Returns null when the default zero-config covers everything (loader-bundle only, no signals, no docs):

import { generateStencilConfig } from '@stencil/templates';
import type { ConfigSelections } from '@stencil/templates';

const sel: ConfigSelections = {
  namespace: 'MyLib',
  outputs: ['loader', 'standalone'],
  signals: false,
  docs: ['cem'],
};

const src = generateStencilConfig(sel);
// null if only loader + no signals + no docs (zero-config case)
// otherwise: TypeScript source string ready to write to stencil.config.ts

ConfigSelections shape:

| Field | Type | Description | |---|---|---| | namespace | string | Component library namespace (e.g. 'MyLib') | | outputs | OutputKey[] | Output targets to enable | | signals | boolean | Enable signalBacking: true | | docs | DocKey[] | Documentation targets to include |

OutputKey values: 'loader' | 'standalone' | 'ssr' | 'ssr-wasm' | 'www'

DocKey values: 'cem' | 'json' | 'vscode'


generatePackageJsonFields(outputs)package.json distributable fields

Returns the module, types, and type fields to merge into package.json for a given set of output targets. Returns an empty object for 'www'-only (non-publishable app mode):

import { generatePackageJsonFields } from '@stencil/templates';

generatePackageJsonFields([]);             // loader-bundle (default)
// { type: 'module', module: './dist/loader-bundle/index.js', types: './dist/types/loader.d.ts' }

generatePackageJsonFields(['standalone']);
// { type: 'module', module: './dist/standalone/index.js', types: './dist/types/standalone.d.ts' }

generatePackageJsonFields(['www']);
// {}  — www is an app, not a publishable package

Priority when multiple outputs are selected: loader > standalone > ssr > ssr-wasm.


getTemplatePath(templateId) — project template directory

Returns the absolute path to a project template directory, ready to copy into a new project:

import { getTemplatePath, PROJECT_TEMPLATES } from '@stencil/templates';

// Currently: ['component-starter']
console.log(PROJECT_TEMPLATES);

const dir = getTemplatePath('component-starter');
// → /absolute/path/to/@stencil/templates/templates/project/component-starter

The component-starter template includes a stencil.config.ts, tsconfig.json, package.json, .gitignore, a sample component, and a utility file.