
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
babel-plugin-pure-static-props
Advanced tools
Fixes issue with tree shaking that can occur when using static properties on React components using styled-components
Fixes an issue with tree shaking that can occur when using static properties on React components using styled-components.
This plugin replaces static property assignments on React components (e.g. MyComponent.defaultProps = {...}
) with Object.assign()
statements annotated with /*#__PURE__*/
comments so that tree-shaking will work correctly.
npm i -D babel-plugin-pure-static-props
Or:
yarn add -D babel-plugin-pure-static-props
Then add the plugin to your Babel config as explained in the Babel documentation.
Example babel.config.js
:
module.exports = {
presets: ['@babel/preset-env'],
plugins: [
'@babel/plugin-proposal-class-properties',
'babel-plugin-pure-static-props',
],
}
The tree-shaking issue with static properties on React components also affects styled components. This plugin only addresses tree-shaking for regular React components; it will not work on components created using the styled
helper.
A fix for styled components is in this PR: https://github.com/styled-components/babel-plugin-styled-components/pull/248.
FAQs
Fixes issue with tree shaking that can occur when using static properties on React components using styled-components
We found that babel-plugin-pure-static-props demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.