Registry / http-networking / babel-plugin-treat

babel-plugin-treat

JSON →
library1.6.2jsnpmunverified

Babel plugin for treat, a CSS-in-JS library that compiles out all runtime style definitions to static CSS files at build time. Version 1.6.2 is the latest, with treat itself at v2.x. The plugin is required for Babel-based setups (alternative to treat webpack loader). Key differentiator: treat is build-time only, unlike runtime CSS-in-JS libraries. The plugin handles extraction of themed styles and local scope. Active maintenance, integrated into treat monorepo.

npm install babel-plugin-treat
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TREAT
B
babel-plugin-treat
http-networkingjavascriptv1.6.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default
module.exports = { presets: [['treat', { theme: 'src/theme.js' }]] }
import treat from 'babel-plugin-treat'
CommonJS in .babelrc; treat plugin invoked as a preset or plugin in Babel config
treat
plugins: ['babel-plugin-treat']
plugins: [['treat', {}]]
If using plugin format, use full package name; treat is not a scoped package
N/A (no named exports)
// .babelrc { "plugins": [ ["babel-plugin-treat", { "theme": "./path/to/theme.js" }] ] }
The plugin has no JavaScript export; it's configured in Babel config

Shows minimal Babel config to enable treat plugin with optional theming.

// babel.config.js module.exports = { plugins: [ ['babel-plugin-treat', { theme: './src/theme.js', // optional: path to treat theme alias: { // optional: module aliases '~styles': './src/styles' } }] ] }; // src/theme.js export const theme = { colors: { brand: 'blue' } };
Debug
Known issues
breakingtreat v2 changed plugin options; 'theme' object structure changed from v1.
fix
Update theme export to match treat v2 format (e.g., use createTheme or treatTheme).
affects: >=2.0.0
gotchaPlugin requires Babel 7+; not compatible with Babel 6.
fix
Upgrade to Babel 7.
affects: >=1.0.0
gotchaTreat plugin must be applied before other transforms that touch JSX or modules; order matters.
fix
Place 'babel-plugin-treat' early in plugins array, typically before React or module transform plugins.
affects: >=1.0.0
deprecatedTreat v2 deprecated 'createThemedStyles' in favor of 'makeStyles' with theme context.
fix
Use 'makeStyles' from 'treat' directly; remove 'createThemedStyles' imports.
affects: >=2.0.0
Errors
Common errors & fixes
Error: .babelrc is not a valid configuration
Using JSON without proper quoting or incorrect plugin format.
fix
Use ["babel-plugin-treat", {}] array syntax in the plugins list.
Error: Cannot find module 'babel-plugin-treat'
Package not installed or npm dependency missing.
fix
Run 'npm install --save-dev babel-plugin-treat' (or yarn add).
TypeError: treat is not a function
Incorrect import of treat module; treat exports are not a function.
fix
Use the plugin in Babel config only; do not import 'babel-plugin-treat' in source code.
Upgrade
Version history
1.6.2latest on npm
Audit
Dependencies
treatrequiredpeer dependency; the plugin transforms treat style definitions
@babel/corerequiredpeer dependency; plugin runs as Babel transform
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
babel-plugin-treat — npm install babel-plugin-treat · libregistry