Skip to content

Commit 64afb03

Browse files
authored
stable for resolving both fix and root aliases and emit resolved files optionally (#2)
* logger with meaningful status color * common utilities * get tsconfig as js object * new functions for check path Directory and paths join * get-config.ts throw error when TSConfig parsing time occurs issue * created function which resolve the task by looping * new packages added babel-parser and babel-generator * created transformer utility for create code ATS * ccreate new checkModuleType utilities for module type detect from AST * JSDocs type added for JS code * transform and createAST and function new params created and JSDocs * new function for throw error * module-type-detector utility throw error * !*important*! create more function which modify the path alis to relative * invoke getRelativePath function * created terminal-loader for animation in terminal * modified code rewrite * common-utilities.ts pretty indent * path-converter.ts debuging friendly error handled * main.ts invoke function by startExecute as a arg * gitignore & tsconfig.json little bit update * remove all type extension from ts config path alias value * entry point for tsconf-paths-resolver * dev mode starting entry changed * resolving baseUrl based on cli source argument * simple cli created with -s and -ds flags * invoke startExecution with cli srcArg * fixed tsConfigAliasVal extension not removing and isTSPathAlias * prevented unnessary loop and print task status * support to resolve fixed aliases * support to emit converted files in destination directory * configured tsup package * new README.md, LICENSE added
1 parent 26d1679 commit 64afb03

File tree

9 files changed

+1589
-23
lines changed

9 files changed

+1589
-23
lines changed

.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
src
1+
src
2+
tsup.config.js
3+
tsconfig.json

LICENSE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
MIT License
2+
# Personal Use Only License (PUOL)
3+
4+
Copyright (c) 2023 Safin Ali
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use the Software for personal purposes, including without limitation the rights to use, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, subject to the following conditions:
7+
8+
1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9+
10+
2. The Software or any modified versions of it may not be republished or distributed in any form without the explicit written permission of the original author.
11+
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# tsconfig-paths-resolver
2+
3+
## 📑 Overview
4+
5+
[![npm version](https://badgen.net/npm/v/tsconfig-paths-resolver)](https://www.npmjs.com/package/tsconfig-paths-resolver)
6+
[![npm version](https://badgen.net/github/license/Safin-Ali/tsconfig-paths-resolver)](https://github.com/Safin-Ali/tsconfig-paths-resolver/blob/main/LICENSE)
7+
[![npm version](https://badgen.net/npm/dw/tsconfig-paths-resolver)](https://www.npmjs.com/package/tsconfig-paths-resolver)
8+
9+
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.
10+
11+
| dependency | weekly downloads |
12+
| ----------------------------------- | -------------------------------------------------------- |
13+
| [@babel/parser](https://www.npmjs.com/package/@babel/parser) | ![npm version](https://badgen.net/npm/dw/@babel/parser)
14+
| [@babel/generator](https://www.npmjs.com/package/@babel/generator) | ![npm version](https://badgen.net/npm/dw/@babel/generator)
15+
| [json-to-js-obj](https://www.npmjs.com/package/json-to-js-obj) | ![npm version](https://badgen.net/npm/dw/json-to-js-obj)
16+
17+
## 💎 Features
18+
19+
- **Easy Configuration**: Integrates seamlessly into your existing TypeScript project by utilizing the `tsconfig.json` file.
20+
21+
- **Relative Path**: Programmatically resolve paths into the relative path `./ || ../` based on `baseUrl`.
22+
23+
- **Support Alias**: Ability to resolve both `fix` > `@app/app.ts` **and** `root` > `@utility/*.ts` aliases
24+
25+
- **File Type**: Resolve only `JavaScript` codes.
26+
27+
## 🔧 Installation
28+
29+
You can install `tsconfig-paths-resolver` via npm:
30+
31+
```bash
32+
npm install --save-dev tsconfig-paths-resolver
33+
```
34+
### or
35+
```bash
36+
yarn add tsconfig-paths-resolver --dev
37+
```
38+
39+
## 🧑‍💻 Usage:
40+
41+
### you can add your `package.json` this line
42+
43+
```json
44+
"scripts": {
45+
"build": "npx tsc && npx tspr -s dist -ds resolved-file"
46+
}
47+
```
48+
49+
50+
## 🔩 Options:
51+
52+
| flag | description | default |
53+
|-------------|-----------------------------------------|-----------|
54+
| -s | typescript compiled codes directory | dist |
55+
| -ds | destination path for the resolved codes | none |
56+
57+
58+
> If you want to use `custom direcotry ` using -s flag `npx tspr -s lib`
59+
60+
> You can `emit` resolved files into separte direcotry using -ds flag `npx tspr -s lib -ds resolved-path`
61+
62+
## 📌 Note:
63+
64+
```
65+
remember it -s <here will be typescript compiler output directory>
66+
that means if your compiled codes .js file inside the src directory
67+
then you should use -s src
68+
```
69+
70+
## 📞 Contact
71+
72+
If you have any questions, feedback, or need assistance with this package, feel free to reach out:
73+
74+
- Author: Safin Ali
75+
76+
- GitHub: [github.com/Safin-Ali](https://github.com/Safin-Ali)
77+
- Website: [https://safin-ali.vercel.app](https://safin-ali.vercel.app/)
78+
79+
80+
😊😁
81+
*Please review it and let me know if you have any specific concerns or if you'd like further changes.*

0 commit comments

Comments
 (0)