Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
babel-plugin-conditional
Advanced tools
Conditionally applies a set of babel plugins based on the result of an expression evaluated at runtime.
Conditionally applies a set of babel plugins based on the result of an expression evaluated at runtime.
Yes, an explanation would be nice. See https://github.com/codemix/flow-runtime/issues/64 for some background for what and why.
yarn add --dev babel-plugin-conditional
Add the following to your .babelrc
or babel configuration:
{
"plugins": [
["conditional", {
"test": "process.env.NODE_ENV === 'development'",
"consequent": [["some-plugin-you-want-to-run-only-in-dev"]],
"alternate": [["some-plugin-you-want-to-run-only-in-prod"]]
}]
]
}
Now given an input like this:
export const add = (a, b) => a + b;
it will produce output like this:
export let add;
if (process.env.NODE_ENV === 'development') {
const _add = (a, b) => {
return a + b;
};
add = _add;
}
else {
const _add = (a, b) => a + b;
add = _add;
}
The condition can then be stripped by tools such as webpack or rollup, so you only get one of the branches in production, but library authors can ship a one set of file that covers both debug and production use cases.
MIT.
FAQs
Conditionally applies a set of babel plugins based on the result of an expression evaluated at runtime.
The npm package babel-plugin-conditional receives a total of 25 weekly downloads. As such, babel-plugin-conditional popularity was classified as not popular.
We found that babel-plugin-conditional 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.