
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
babel-plugin-root-require
Advanced tools
Transforms require module paths that have a prefix referring to the project root. Also works on `require.resolve`.
Transforms require module paths that have a prefix referring to the project root. Also works on require.resolve.
npm install babel-plugin-root-require
// these paths will work from any file in the project root (src)
require('~/foo/a')
require('~/bar/b')
require('~/bar/baz/c')
require('~/d')
// foo/a.js
require('~/d') // -> require('../d')
{
"plugins": [
["root-require", {
"projectRoot": "src"
}]
]
}
babel src --out-dir build
Prefix that refers to the project root
Absolute path of project root or relative path from process.cwd() to the project root which prefix refers to. Module paths will not be resolved correctly if this option is not correct. In the typical case that the source code is under the src directory, but babel is executed in the parent directory of src, set projectRoot: src.
By default, transformed module paths will be the most efficient path from the requiring file to the module. When long is true, the prefix will be transformed to the relative path up the tree to the project root and the rest of the path is untouched. In some cases, the module path will be longer this way, because the path goes up the tree to the project root and then back down the tree to the module.
FAQs
Transforms require module paths that have a prefix referring to the project root. Also works on `require.resolve`.
We found that babel-plugin-root-require 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
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.