Skip to content

cem-plugin

A plugin for @custom-elements-manifest/analyzer that teaches it to read wcb’s static props object.

import { wcbStaticProps } from 'web-component-base/cem-plugin'
// also available as the module's default export
import wcbStaticProps from 'web-component-base/cem-plugin'

See the CEM Analyzer Plugin guide for setup, Storybook and editor integration.

Takes no arguments and returns an analyzer plugin object.

FieldType
namestringthe plugin name
analyzePhase(ctx: any) => voidthe analyzer hook
custom-elements-manifest.config.mjs
import { wcbStaticProps } from 'web-component-base/cem-plugin'
export default {
globs: ['src/**/*.js'],
outdir: '.',
plugins: [wcbStaticProps()],
}

For each class that extends WebComponent, it reads the static props initializer and, for every key, records in the manifest:

  • the member under its camelCase name
  • the attribute under its kebab-case name, linked to that member
  • the type inferred from the default value — boolean, number, object or string
  • the default value as written

Without it the analyzer sees props as one opaque static field and emits no attributes, so editor completion and Storybook controls have nothing to read.

The static props object may be declared inline or as an identifier resolved from the same source file.