Skip to content

Commit

Permalink
stable for resolving both fix and root aliases and emit resolved file…
Browse files Browse the repository at this point in the history
…s 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
  • Loading branch information
DevSA-009 authored Oct 19, 2023
1 parent 26d1679 commit 64afb03
Show file tree
Hide file tree
Showing 9 changed files with 1,589 additions and 23 deletions.
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
src
src
tsup.config.js
tsconfig.json
12 changes: 12 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
MIT License
# Personal Use Only License (PUOL)

Copyright (c) 2023 Safin Ali

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:

1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

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.

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.
81 changes: 81 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# tsconfig-paths-resolver

## 📑 Overview

[![npm version](https://badgen.net/npm/v/tsconfig-paths-resolver)](https://www.npmjs.com/package/tsconfig-paths-resolver)
[![npm version](https://badgen.net/github/license/Safin-Ali/tsconfig-paths-resolver)](https://github.com/Safin-Ali/tsconfig-paths-resolver/blob/main/LICENSE)
[![npm version](https://badgen.net/npm/dw/tsconfig-paths-resolver)](https://www.npmjs.com/package/tsconfig-paths-resolver)

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](https://www.npmjs.com/package/@babel/parser) | ![npm version](https://badgen.net/npm/dw/@babel/parser)
| [@babel/generator](https://www.npmjs.com/package/@babel/generator) | ![npm version](https://badgen.net/npm/dw/@babel/generator)
| [json-to-js-obj](https://www.npmjs.com/package/json-to-js-obj) | ![npm version](https://badgen.net/npm/dw/json-to-js-obj)

## 💎 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:

```bash
npm install --save-dev tsconfig-paths-resolver
```
### or
```bash
yarn add tsconfig-paths-resolver --dev
```

## 🧑‍💻 Usage:

### you can add your `package.json` this line

```json
"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:

- Author: Safin Ali
- Email: [email protected]
- GitHub: [github.com/Safin-Ali](https://github.com/Safin-Ali)
- Website: [https://safin-ali.vercel.app](https://safin-ali.vercel.app/)


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

0 comments on commit 64afb03

Please sign in to comment.