Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@kodiak-ui/babel-plugin
Advanced tools
A babel plugin that hoists jsx attributes.
@kodiak-ui/babel-plugin
is used to optimize sx
attributes by hoisting anything that could be out of the render path.
.babelrc
(Recommended).babelrc
Without options:
{
"plugins": ["@kodiak-ui"]
}
With options:
Defaults Shown
{
"plugins": [
[
"@kodiak-ui",
{
attributesToHoist: ["sx", "variants"]
}
]
]
}
attributesToHoist
An array of jsx attributes to hoist.
// Input
import { Box } from '@kodiak-ui/primitives'
function sxGenerator() {
return {
bg: 'green',
}
}
function App() {
const isTrue = true
return (
<div
sx={{
backgroundColor: 'blue',
'&:hover': {
color: 'lightgreen',
},
}}
>
This has a hotpink background.
<div
css={{ backgroundColor: isTrue ? 'red' : 'blue' }}
sx={{
color: isTrue ? 'red' : 'blue',
}}
onClick={() => null}
>
Another div that isn't hoisted
</div>
<Box
variants={['var1', 'var2']}
sx={{ background: 'blue' }}
aria-label="a label"
>
A box
</Box>
<Box sx={sxGenerator()}>Pure functions are also hoisted</Box>
</div>
)
}
// Output
↓ ↓ ↓ ↓ ↓ ↓
import * as React from 'react'; // or a jsx pragma
import { Box } from '@kodiak-ui/primitives';
function sxGenerator() {
return {
bg: 'green'
};
}
var _ref = {
backgroundColor: 'blue',
'&:hover': {
color: 'lightgreen'
}
};
var _ref2 = ['var1', 'var2'];
var _ref3 = {
background: 'blue'
};
var _ref4 = sxGenerator();
function App() {
const isTrue = true;
return <div sx={_ref}>
This has a hotpink background.
<div css={{
backgroundColor: isTrue ? 'red' : 'blue'
}} sx={{
color: isTrue ? 'red' : 'blue'
}} onClick={() => null}>
Another div that isn't hoisted
</div>
<Box variants={_ref2} sx={_ref3} aria-label="a label">
A box
</Box>
<Box sx={_ref4}>Pure functions are also hoisted</Box>
</div>;
}
FAQs
A babel plugin that hoists jsx attributes.
The npm package @kodiak-ui/babel-plugin receives a total of 3 weekly downloads. As such, @kodiak-ui/babel-plugin popularity was classified as not popular.
We found that @kodiak-ui/babel-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.