tsc-path-replacer
Resolve imports/requires alias according to tsconfig paths. It tries use more resources provided by Node.js, like, asynchronous methods, paralelism and a simple memory cache.
Examples
// ./src/controllers/user/index.js
// this import:
import userService from '@services/user/getUsers';
// will be replaced by:
import userService from '../../services/user/getUsers';
Using require
:
// ./src/controllers/user/index.js
const userService = require('@services/user/getUsers');
const userService = require('../../services/user/getUsers');
The biggest difference from this package to another similar ones is the huge usage of the Node.js asynchronous APIs and paralelism (up to 5 files are processed at the same time).
Table of Contents
Installing
Just run:
npm install --save-dev @diegovictor/tsc-path-replacer
Or simply:
yarn add -D @diegovictor/tsc-path-replacer
Usage
Register on your build script:
"scripts": {
"build": "tsc --project tsconfig.json && tsc-path-replacer tsconfig.json",
}