Gathering detailed insights and metrics for @maccman/babel-plugin-transform-jsx-classnames
Gathering detailed insights and metrics for @maccman/babel-plugin-transform-jsx-classnames
npm install @maccman/babel-plugin-transform-jsx-classnames
Typescript
Module System
Min. Node Version
Node Version
NPM Version
77.2
Supply Chain
99.5
Quality
75
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
1,274
Last Day
2
Last Week
4
Last Month
18
Last Year
564
5 Stars
8 Commits
1 Forks
3 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.1.1
Package Id
@maccman/babel-plugin-transform-jsx-classnames@1.1.1
Unpacked Size
362.74 kB
Size
86.30 kB
File Count
24
NPM Version
6.14.6
Node Version
12.18.3
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
300%
4
Compared to previous week
Last month
350%
18
Compared to previous month
Last year
109.7%
564
Compared to previous year
className and styleName on steroids 💪
Allow you to write jsx classNamess in a simpler way, without having to worry about importing a helper (like classnames). classNames
or styleNames
attributes take any number of arguments which can be a string, an array or an object (if the value associated with a given key is falsy, that key won't be included in the output). See examples
When babel-plugin-transform-jsx-classnames cannot resolve classNames
/ styleNames
during compilation, it imports a helper function (read build time resolution). Therefore, you must install babel-plugin-react-css-modules as a direct dependency of the project.
1$ npm install babel-plugin-transform-jsx-classnames --save
Add to .babelrc
:
1{ 2 plugins: ['transform-jsx-classnames'] 3}
Note: ⚠️ If you're using
babel-plugin-react-css-modules
, ensure you're addingtransform-jsx-classnames
before
The plugin will try to resolve the classNames
/ styleNames
during the compilation (classNames={"foo", { active: true }}
) and fallback to runtime if not possible (classNames={_cx("foo", { active: props.active })}
- a tiny helper (~0.3Ko) will be included automatically.
The runtime helper is very similar to the classnames package. It actually behaves like its dedupe version.
The only difference you'll find will be with full numeric classNamess: output will always spit numbers first (ex: classNames={"a", 12}
=> classNames="12 a"
). It shouldn't be a big deal though, as using numeric values for classNamess is pretty rare and order only matters in a very few specific cases.
Dedupe has been optimized a lot and its performance is very similar to classnames (in no dedupe mode). It's even better in some cases.
1<div classNames={"foo", "bar"}> 2→ <div classNames="foo bar"></div> 3 4<div classNames={'foo', { bar: true }}> 5→ <div classNames="foo bar"></div> 6 7<div classNames={{ 'foo-bar': true }}> 8→ <div classNames="foo-bar"></div> 9 10<div classNames={{ 'foo-bar': false }}> 11→ <div classNames=""></div> 12 13<div classNames={{ foo: true }, { bar: true }, ["foobar", "duck"]}> 14→ <div classNames="foo bar foobar duck"></div> 15 16<div classNames={'foo', { bar: true, duck: false }, 'baz', { quux: true }}> 17→ <div classNames="foo bar baz quux"></div> 18 19<!-- styleNames --> 20<div styleNames={"foo", "bar"}> 21→ <div styleNames="foo bar"></div> 22 23<!-- Dedupe --> 24<div classNames={'foo foo', 'bar', { bar: true, foo: false }}> 25→ <div classNames="bar"></div> 26 27<!-- No change --> 28<div classNames={props.active ? "foo" : "bar"}> 29→ <div classNames={props.active ? "foo" : "bar"}></div>
When classNames
/ styleNames
can't be resolved at compilation.
1<div classNames={"foo", { active: props.active }}> 2→ <div classNames={_cx("foo", { active: props.active })}></div> 3 4<div classNames={{ foo: true, [`btn-${props.type}`]: true }}> 5→ <div classNames={_cx({ foo: true, [`btn-${props.type}`]: true })}></div> 6 7<div classNames={"foo", props.active && getClassName()}> 8→ <div classNames={_cx("foo", props.active && getClassName())}></div>
You like this package?
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/8 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
82 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More