All Projects β†’ duffman β†’ Tspath

duffman / Tspath

Licence: lgpl-2.1
TypeScript path alias resolver

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Tspath

calculate-aspect-ratio
πŸ“ A simple utility function, and command line utility, for calculating an aspect ratio based on width and height.
Stars: ✭ 43 (-62.61%)
Mutual labels:  utility, npm-module
Linuxacademy Dl
Download videos from Linux Academy (linuxacademy.com) for personal offline use
Stars: ✭ 111 (-3.48%)
Mutual labels:  utility
Mercury
Simple Android app that sends pre-configured commands to remote servers via SSH.
Stars: ✭ 100 (-13.04%)
Mutual labels:  utility
Startup
πŸ”§ R package: startup - Friendly R Startup Configuration
Stars: ✭ 107 (-6.96%)
Mutual labels:  utility
Git Extra Status
Get more information for a single or batch of git repositories with a single command
Stars: ✭ 102 (-11.3%)
Mutual labels:  utility
Nekos Dot Life
Nekos.life wrapper.
Stars: ✭ 108 (-6.09%)
Mutual labels:  npm-module
Jsonabc
Sorts JSON object alphabetically. It supports nested objects, arrays and collections. Works offline and beautifies JSON object too.
Stars: ✭ 100 (-13.04%)
Mutual labels:  utility
Kody
.files and environment configuration manager created with node
Stars: ✭ 113 (-1.74%)
Mutual labels:  utility
Beautifultable
Python package for printing visually appealing tables on a terminal.
Stars: ✭ 110 (-4.35%)
Mutual labels:  utility
Add Node Modules Path
Adds the node_modules/.bin directory to the buffer exec_path. E.g. support project local eslint installations.
Stars: ✭ 105 (-8.7%)
Mutual labels:  path
Clippathlayout
Android δΈθ§„εˆ™ε›Ύε½’εΈƒε±€
Stars: ✭ 104 (-9.57%)
Mutual labels:  path
Machina
Network capture library for realtime TCP/IP decoding from a windows application. Includes an extension library to support FFXIV data capture.
Stars: ✭ 102 (-11.3%)
Mutual labels:  utility
Discord.js Musicbot Addon
This DOES NOT WORK any more. This repo only serves as an archive for is anyone wants to pickup my work. You may still join the discord however.
Stars: ✭ 109 (-5.22%)
Mutual labels:  npm-module
Async Ray
Provide async/await callbacks for every, find, findIndex, filter, forEach, map, reduce, reduceRight and some methods in Array.
Stars: ✭ 102 (-11.3%)
Mutual labels:  utility
Endlines
Easy conversion between new-line conventions
Stars: ✭ 112 (-2.61%)
Mutual labels:  utility
Npm Quick Run
Quickly run NPM script by prefix without typing the full name
Stars: ✭ 97 (-15.65%)
Mutual labels:  utility
Lens
A utility for working with nested data structures.
Stars: ✭ 104 (-9.57%)
Mutual labels:  utility
Janus
Janus is a fake rest api server
Stars: ✭ 107 (-6.96%)
Mutual labels:  utility
Pal2
Path of Exile Addon Launcher and Manager
Stars: ✭ 115 (+0%)
Mutual labels:  path
To Case
Simple case detection and conversion for strings.
Stars: ✭ 111 (-3.48%)
Mutual labels:  utility

TSPath

TypeScript Path Alias Resolver

Everyone working in a TypeScript project that grows beyond a certains limit will eventually experience the situation commonly described as path hell, the snippet below is an example of such hell.

Path hell
 import { IgniterApplication } from "../../../Application/IgniterApplication";
 import { CrcCalculator }      from "../../../../../../../Utilities/FileUtilities";
 import { IMessageHandler }    from "../../../../Messaging/IMessageHandler";
 import { IMessageHub }        from "../../../../Messaging/Hub/IMessageHub";
 import { CronTabHelper }      from "../../../../../../../Utilities/CronTabHelper";
 import { GLog }               from "../../../Application/GLog";

By specifying path aliases in tsconfig.json you can use that alias to form an "absolute path"

{
  "compilerOptions": {
    ...
    "paths": {
      "@App/*":         ["./Application/*"],
      "@Messaging/*":   ["./Messaging/*"],
      "@Utils/*":       ["./Server/Tools/Utilities/*"]
    }
  }
}

Below is the sample example but with Path Aliases instead of relative paths added, as you can see, the readability have improved significantly!

 import { IgniterApplication } from "@App/IgniterApplication";
 import { CrcCalculator }      from "@Utils/FileUtilities";
 import { IMessageHandler }    from "@Messaging/IMessageHandler";
 import { IMessageHub }        from "@Messaging/Hub/IMessageHub";
 import { CronTabHelper }      from "@Utils/CronTabHelper";
 import { GLog }               from "@App/GLog";

The TypeScript compiler will be able to resolve the paths so this will compile without problems, however the JavaScript output will not be possible to execute by Node nor a Web Browser, why? the reason is simple!

The JavaScript engine does not know anything about the compile time TypeScript configuration.

In order to run your JavaScript code, the path aliases now needs to be made into relative paths again, here is when TSPath comes into play.

So, simply run:

$ tspath

Yes, thatΒ΄s it, really!

Running headless, slip in a -f in order to bypass the confirmation prompt.

$ tspath -f

Say bye bye to the relative path hell!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].