@diegovictor/tsc-path-replacer
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

tsc-path-replacer

npm eslint prettier airbnb-style typescript MIT License PRs Welcome

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",
}

Inspired by

tsconfig-replace-paths

Package Sidebar

Install

npm i @diegovictor/tsc-path-replacer

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

80.2 kB

Total Files

10

Last publish

Collaborators

  • diegovictorgonzaga