`web-component-analyzer` is a command-line interface (CLI) tool designed to analyze web component source code, including both JavaScript and TypeScript, to extract structured metadata. It parses code and JSDoc comments to identify and document `properties`, `attributes`, `methods`, `events`, `slots`, `CSS shadow parts`, and `CSS custom properties`. The tool supports vanilla web components and provides specialized analysis for components built with frameworks like LitElement, Polymer, Stencil (partial), and LWC. The current stable version is 2.0.0. While there isn't a strict regular release cadence, updates are made to enhance parsing logic, fix bugs, and add support for new Web Component features or framework nuances. Its primary differentiation lies in its comprehensive extraction capabilities across multiple web component ecosystems, outputting to formats like Markdown, JSON, and VS Code-specific schemas, making it useful for documentation generation and IDE tooling workflows. It explicitly handles complexities like mixins and JSDoc type definitions, improving accuracy over simple regex-based parsers, and ships with TypeScript types for programmatic integration.
npm install web-component-analyzerVerified import paths — ran on the pinned version, not inferred.
Demonstrates programmatic analysis of a single web component string using `analyzeText`, extracting its metadata including properties, attributes, events, slots, and CSS parts, then logging the structured output.
Consult the official GitHub repository for detailed 2.0.0 release notes, if available, or review the source code for changes to the analysis API and output format. Adapt programmatic integrations accordingly.
Always use the latest stable version of `web-component-analyzer` to ensure the most consistent JSON output, and robustify your parsing logic to handle potential schema evolution.
Update to `web-component-analyzer` version 1.0.2 or newer to resolve known globbing issues on Windows. If problems persist, consider providing explicit file paths instead of globs.
Ensure you are on `web-component-analyzer` v1.1.0 or newer for improved JSDoc parsing accuracy. Review your JSDoc comments to match supported formats.
Ensure your web component is correctly defined and registered (e.g., `customElements.define('my-element', MyElement);`) and that the analyzer's glob pattern or input text covers the definition.Always check if the analysis result is defined and not empty before attempting to access its properties. Use optional chaining (`?.`) for safer property access.
Verify CLI option spellings and casing against the documentation (`--outFile`, `--outDir`, `--format`). Most options use camelCase.
Check the specified file for syntax errors. Ensure your TypeScript configuration (if programmatic) or environment supports the language features used. Verify file paths and permissions.