Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
paths.macro
Advanced tools
Babel plugin that returns an object containing paths like __dirname and __filename as static values
Babel macro that allows you to "import" the location of the source-file.
The supported paths you can import:
name | example |
---|---|
npmRoot | /Users/you/project |
gitRoot | /Users/you/project |
wd | /Users/you/project |
fileAbsolute | /Users/you/project/src/input.js |
file | input.js |
extention | .js |
filename | input |
baseAbsolute | /Users/you/project/src/ |
base | /src/ |
The default import is equal to base
.
Source file input.js
:
import base, { filename } from 'babel-plugin-module-paths/paths.macro';
console.log(base, filename);
alert(filename, base);
function usePathsForSomething() {
return [filename, base];
};
Output:
console.log("/src/", "input");
alert("input", "/src/");
function usePathsForSomething() {
return ["input", "/src/"];
};
Install:
yarn add babel-plugin-module-paths
If you don't have babel-macros already you must also install that:
yarn add babel-plugin-macros
Ensure you have babel-plugin-macros
in your babel config (.babelrc
).
{
"plugins": ["macros"]
}
FAQs
Babel plugin that returns an object containing paths like __dirname and __filename as static values
The npm package paths.macro receives a total of 10,348 weekly downloads. As such, paths.macro popularity was classified as popular.
We found that paths.macro demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.