Registry / web-framework / babylon-plugin-cssx

babylon-plugin-cssx

JSON →
library1.0.2jsnpmunverified

A plugin for the Babylon parser (fork of Babel parser) that enables parsing of CSSX syntax, allowing CSS to be embedded directly in JavaScript. Version 1.0.2 is the latest stable release. It is part of the CSSX family for transpiling CSS-in-JS. Provides integration with Babylon to handle CSS template literals.

npm install babylon-plugin-cssx
INSTALL
IMPORT
SIG · BABYLON-PLUGIN-CSS
B
babylon-plugin-cssx
web-frameworkjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import babylonPluginCSSX from 'babylon-plugin-cssx'
const babylonPluginCSSX = require('babylon-plugin-cssx')
The package is CommonJS but can be imported as default; using require is also valid but less common in modern JS.

Demonstrates registering the cssx plugin with Babylon to parse a CSSX tagged template literal.

import babylon from 'babylon'; import cssxPlugin from 'babylon-plugin-cssx'; const code = `const styles = cssx` .class { color: red; } ``; const ast = babylon.parse(code, { plugins: ['cssx'] }); console.log(JSON.stringify(ast, null, 2));
Debug
Known issues
deprecatedThe babylon package has been deprecated in favor of @babel/parser. This plugin likely only works with the deprecated babylon package.
fix
Migrate to @babel/parser and use @babel/plugin-syntax-cssx or equivalent.
affects: >=1.0.0
gotchaThe plugin must be activated by including 'cssx' in the plugins array of babylon.parse options, otherwise CSSX syntax will cause parse errors.
fix
Add 'cssx' to the plugins list: babylon.parse(code, { plugins: ['cssx'] }).
affects: *
Errors
Common errors & fixes
SyntaxError: Unexpected token (1:14)
The Babylon parser is not using the cssx plugin.
fix
Ensure you pass { plugins: ['cssx'] } as the second argument to babylon.parse().
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
babylonrequiredRequires the Babylon parser as a peer dependency.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
babylon-plugin-cssx — npm install babylon-plugin-cssx · libregistry