liveBook · Manning

@custom-elements-manifest/analyzer

As explained in Web Component Development with Modern Libraries and Tooling

@custom-elements-manifest/analyzer is a tool that analyzes web-component source files and generates Custom Elements Manifest data.

@custom-elements-manifest/analyzer generates Custom Elements Manifest data from web-component source files, avoiding the tedious and error-prone work of writing manifests manually. The generated file records component tag names, attributes, properties, slots, CSS custom properties, and CSS parts for use by documentation and developer tools. section 10.0 section 1.5

npm install -D @custom-elements-manifest/analyzer

Install the analyzer as a development dependency before adding generation scripts. section 10.1

A typical project workflow is:

  • Add `cem analyze` and `cem analyze --watch` scripts to package.json. section 10.1
  • Run the command to create `custom-elements.json` in the project root, and regenerate it whenever a component API changes. section 10.1
  • Limit analysis with `globs` and omit irrelevant paths with `exclude`; node_modules is excluded automatically. section 10.1
  • Enable library support for FAST, Lit, or Stencil through configuration, and add a plugin when a library is not natively supported. section 10.1

A focused project configuration

A project whose components live under src can configure `globs: ["src/**/*.{js,ts}"]` and exclude Storybook directories such as `stories` and `storybook-static`. A project combining FAST, Lit, and Stencil can enable those integrations, while another library can be connected through a package-specific plugin. section 10.1

How Web Component Development with Modern Libraries and Tooling covers it

How deep it goes
Explains installation, scripts, watch mode, file selection, exclusions, library flags, and plugins, but not analyzer internals.
Examples
Uses npm scripts, custom-elements.json, src globs, Storybook exclusions, and FAST, Lit, Stencil, and plugin configurations.
What it assumes
Assumes a project containing web-component source files and package.json, while explaining manifest generation from setup onward.
What you can do after
Operate/configure it to generate and watch a project's Custom Elements Manifest, including sources from supported component libraries.
How it connects
Connects web components with Custom Elements Manifest, Storybook, VS Code, FAST, Lit, Stencil, and analyzer plugins.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Component Development with Modern Libraries and Tooling. The section links point to the parts of the book it draws on.