Skip to content

Safin-Ali/tsconfig-paths-resolver

Repository files navigation

tsconfig-paths-resolver

📑 Overview

npm version npm version npm version

The tsconfig-paths-resolver is a powerful tool that allows you to resolve TypeScript module paths at build time using your tsconfig.json file. This is particularly useful when you have complex module structures or when you want to optimize your build process.

dependency weekly downloads
@babel/parser npm version
@babel/generator npm version
json-to-js-obj npm version

💎 Features

  • Easy Configuration: Integrates seamlessly into your existing TypeScript project by utilizing the tsconfig.json file.

  • Relative Path: Programmatically resolve paths into the relative path ./ || ../ based on baseUrl.

  • Support Alias: Ability to resolve both fix > @app/app.ts and root > @utility/*.ts aliases

  • File Type: Resolve only JavaScript codes.

🔧 Installation

You can install tsconfig-paths-resolver via npm:

npm install --save-dev tsconfig-paths-resolver

or

yarn add tsconfig-paths-resolver --dev

🧑‍💻 Usage:

you can add your package.json this line

"scripts": {
	"build": "npx tsc && npx tspr -s dist -ds resolved-file"
}

🔩 Options:

flag description default
-s typescript compiled codes directory dist
-ds destination path for the resolved codes none

If you want to use custom direcotry using -s flag npx tspr -s lib

You can emit resolved files into separte direcotry using -ds flag npx tspr -s lib -ds resolved-path

📌 Note:

remember it -s <here will be typescript compiler output directory>
that means if your compiled codes .js file inside the src directory
then you should use -s src

📞 Contact

If you have any questions, feedback, or need assistance with this package, feel free to reach out:

😊😁 Please review it and let me know if you have any specific concerns or if you'd like further changes.