css-what is a robust and efficient JavaScript library designed for parsing CSS selectors into a structured, machine-readable format. It currently stands at version 8.0.0, which notably transitioned to an ESM-only distribution. The library's release cadence is somewhat irregular, with major versions introducing significant changes like ESM support and refinements to parsing logic. It provides a detailed tokenization of CSS selectors, representing elements, attributes, pseudos, and combinators as distinct objects with their respective properties. This detailed output makes it suitable for applications requiring granular analysis or manipulation of CSS selectors, such as styling engines, static analysis tools, or browser polyfills, differentiating it from simpler selector string processors by its deep structural representation.
npm install css-whatVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to parse CSS selectors into a tokenized array and how to stringify them back to a CSS string, covering basic and compound selectors.
Migrate all import statements from `const pkg = require('pkg');` to `import * as pkg from 'pkg';` or `import { symbol } from 'pkg';`. Ensure your project is configured for ESM.Refactor code to no longer pass an `options` object as a second argument to `CSSwhat.parse()`.
Review code that relies on specific casing behavior for tags and attributes, or on the default `ignoreCase` logic. Adjust expectations or implement manual casing/case-insensitivity if required by your application.
Avoid `css-what` versions `6.2.0` and `6.2.1`. Prefer `6.1.0` or `6.2.2` if you need features from that range, or upgrade to a newer major version.
If encountering build errors, explicitly configure your bundler (e.g., Webpack, Rollup) to prefer CJS or ESM resolution, or upgrade to v8.0.0 which is pure ESM.
Change `const CSSwhat = require("css-what");` to `import * as CSSwhat from "css-what";` or `import { parse, stringify } from "css-what";`. Ensure your `package.json` specifies `"type": "module"` if applicable, or use a bundler correctly configured for ESM.Use a namespace import: `import * as CSSwhat from 'css-what';` then access functions like `CSSwhat.parse()`. Alternatively, use named imports directly: `import { parse, stringify } from 'css-what';`.The `CSSwhat.parse()` function returns a two-dimensional array of token objects. Ensure your code correctly iterates over this array structure, as shown in the quickstart example, rather than attempting to `JSON.parse` the raw output.
No dependency data recorded yet.