Gathering detailed insights and metrics for @lukaskl/typescript-transform-paths
Gathering detailed insights and metrics for @lukaskl/typescript-transform-paths
Gathering detailed insights and metrics for @lukaskl/typescript-transform-paths
Gathering detailed insights and metrics for @lukaskl/typescript-transform-paths
Transforms module resolution paths using TypeScript path mapping and/or custom paths
npm install @lukaskl/typescript-transform-paths
Typescript
Module System
Node Version
NPM Version
TypeScript (97.27%)
JavaScript (2.73%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
494 Stars
422 Commits
28 Forks
6 Watchers
32 Branches
13 Contributors
Updated on Jul 05, 2025
Latest Version
3.4.6
Package Id
@lukaskl/typescript-transform-paths@3.4.6
Unpacked Size
131.28 kB
Size
31.07 kB
File Count
67
NPM Version
8.19.2
Node Version
18.12.1
Published on
Feb 06, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
This package is a fork of typescript-transform-paths with a single change - it is forced to treat File System as case sensitive.
Transform compiled source module resolution paths using TypeScript's paths
config, and/or custom resolution paths.
1<yarn|npm|pnpm> add -D typescript-transform-paths
Add it to plugins in your tsconfig.json
1{ 2 "compilerOptions": { 3 "baseUrl": "./", 4 // Configure your path mapping here 5 "paths": { 6 "@utils/*": ["utils/*"] 7 }, 8 // Note: To transform paths for both the output .js and .d.ts files, you need both of the below entries 9 "plugins": [ 10 // Transform paths in output .js files 11 { "transform": "typescript-transform-paths" }, 12 13 // Transform paths in output .d.ts files (Include this line if you output declarations files) 14 { "transform": "typescript-transform-paths", "afterDeclarations": true } 15 ] 16 } 17}
core/index.ts
1// The following transforms path to '../utils/sum' 2import { sum } from "@utils/sum";
Compile with tsc
— Use ts-patch
Use with ts-node — Add typescript-transform-paths/register
to require
config.
tsconfig.json
1{ 2 "ts-node": { 3 "transpileOnly": true, 4 "require": [ "typescript-transform-paths/register" ], 5 }, 6 "compilerOptions" { /* ... */ } 7}
Use with node — Use the register script: node -r typescript-transform-paths/register src/index.ts
Use with NX — Add the typescript-transform-paths/nx-transformer
to project config
project.json
1{ 2 /* ... */ 3 "targets": { 4 "build": { 5 /* ... */ 6 "options": { 7 /* ... */ 8 "transformers": [ 9 { 10 "name": "typescript-transform-paths/nx-transformer", 11 "options": { "afterDeclarations": true } 12 } 13 ] 14 } 15 } 16 } 17}
TS allows defining
virtual directories
via the rootDirs
compiler option.
To enable virtual directory mapping, use the useRootDirs
plugin option.
1{ 2 "compilerOptions": { 3 "rootDirs": [ "src", "generated" ], 4 "baseUrl": ".", 5 "paths": { 6 "#root/*": [ "./src/*", "./generated/*" ] 7 }, 8 "plugins": [ 9 { "transform": "typescript-transform-paths", "useRootDirs": true }, 10 { "transform": "typescript-transform-paths", "useRootDirs": true, "afterDeclarations": true } 11 ] 12 } 13}
- src/
- subdir/
- sub-file.ts
- file1.ts
- generated/
- file2.ts
src/file1.ts
1import '#root/file2.ts' // resolves to './file2'
src/subdir/sub-file.ts
1import '#root/file2.ts' // resolves to '../file2' 2import '#root/file1.ts' // resolves to '../file1'
You can disable transformation for paths based on the resolved file path. The exclude
option allows specifying glob
patterns to match against resolved file path.
For an example context in which this would be useful, see Issue #83
Example:
1{ 2 "compilerOptions": { 3 "paths": { 4 "sub-module1/*": [ "../../node_modules/sub-module1/*" ], 5 "sub-module2/*": [ "../../node_modules/sub-module2/*" ], 6 }, 7 "plugins": [ 8 { 9 "transform": "typescript-transform-paths", 10 "exclude": [ "**/node_modules/**" ] 11 } 12 ] 13 } 14}
1// This path will not be transformed 2import * as sm1 from 'sub-module1/index'
Use the @transform-path
tag to explicitly specify the output path for a single statement.
1// @transform-path https://cdnjs.cloudflare.com/ajax/libs/react/17.0.1/umd/react.production.min.js 2import react from 'react' // Output path will be the url above
Use the @no-transform-path
tag to explicitly disable transformation for a single statement.
1// @no-transform-path 2import 'normally-transformed' // This will remain 'normally-transformed', even though it has a different value in paths config
yarn
(yarn install
)prettier
(yarn run format
)standard-version
(yarn run release
)Ron S. | Daniel Perez Alvarez |
No vulnerabilities found.
Reason
12 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
Found 1/28 approved changesets -- score normalized to 0
Reason
security policy file not detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
10 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More