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-transform-preprocessor
Advanced tools
Simple identifier replacements for Babel, supporting function name (__funcname
) as well as any custom mapping, such as would usually be handled by a preprocessor in other languages. This is particularly useful if you have a profiling build that wants additional instrumentation.
Example (__funcname and custom replace)
Configuration (.babelrc or otherwise):
{
"plugins": [
["transform-preprocessor", {
"replace": {
"trace()": "if (_enabled) logTrace(__funcname)",
}
}]
]
}
Input:
function test1() {
console.log(__funcname);
}
function test2() {
trace();
}
Output:
function test1() {
console.log("test1");
}
function test2() {
if (_enabled) logTrace("test2");
}
Options
{
replace: {
'source': 'dest', // simple replacement applied to Identifiers, replaces with specified code
'source()': 'dest()', // simple replacement applied to a CallExpressions, replaces with specified code
'source': (path) => {}, // calls replacement function, maybe just write a Babel plugin instead?
'source()': '', // replace a CallExpression with nothing
'__funcname': null, // disable a default replacement (__funcname will remain in output source)
}
}
Default options
{
replace: {
'__funcname': replacerFuncName, // see lib/transform-preprocessor.js
}
}
Future work
F(A, B)
=> f(A + 1, B, c)
const WIDTH = __define(10)
, or leave this kind of optimization to the minifiers?FAQs
Simple identifier replacements for Babel
The npm package babel-plugin-transform-preprocessor receives a total of 1 weekly downloads. As such, babel-plugin-transform-preprocessor popularity was classified as not popular.
We found that babel-plugin-transform-preprocessor 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.