
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@halkeye/tscpaths
Advanced tools
Replace absolute paths to relative paths after typescript compilation
Replace absolute paths to relative paths after typescript compilation (tsc) during compile-time.
+ Compile time (no runtime dependencies)
First, install tscpaths as devDependency using npm or yarn.
npm install --save-dev tscpaths
# or
yarn add -D tscpaths
"scripts": {
"build": "tsc --project tsconfig.json && tscpaths --project tsconfig.json",
}
You can also setup a seperate tsconfig file just for types like tsconfig.types.json if you are also compiling with Babel.
// tsconfig.types.json
{
"extends": "./tsconfig",
"compilerOptions": {
"module": "amd",
"outDir": "dist",
"rootDir": "./src",
"declaration": true,
"declarationMap": false,
"isolatedModules": false,
"noEmit": false,
"allowJs": false,
"emitDeclarationOnly": true
},
"exclude": ["**/*.test.ts"]
}
And then target that
"scripts": {
"build:types": "tsc --project tsconfig.types.json && tscpaths -project tsconfig.types.json",
}
Your final build script might look like
"scripts": {
"build": "yarn build:commonjs && yarn build:types",
}
| flag | description |
|---|---|
| -p --project | project configuration file (tsconfig.json) |
| -s --src | source code root directory (overrides the tsconfig provided) |
| -o --out | output directory of transpiled code (tsc --outDir) (overrides the tsconfig provided) |
| -v --verbose | console.log all the events |
This is not a mature project yet. Pull Requests are welcome!
It works for my setup so far.
It may not work correctly if your setup is too complicated, so please do some testing before pushing it to production!!!
You need to provide -s (--src) and -o (--out), because it's hard to predict source and output paths based on tsconfig.json.
I've tried a little and failed. :(
The above is no longer neccesary <-- got you fam: @jonkwheeler
FAQs
Replace absolute paths to relative paths after typescript compilation
We found that @halkeye/tscpaths 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.