2.2.9 • Published 2 years ago

typescript-module-alias v2.2.9

Weekly downloads
76
License
MIT
Repository
github
Last release
2 years ago

typescript-module-alias

This is a library that can automatically find and execute corresponding modules according to alias path alias in tsconfig.json

Install

install with npm:

npm install --save-dev typescript-module-alias

install with yarn:

yarn add typescript-module-alias -dev

Quickstart

on command line

npx typescript-module-alias ./test/a.ts

package.json scripts

development

  "scripts": {
    "dev": "typescript-module-alias ./test/a.ts"
  }

production

  "scripts": {
    "build": "typescript-module-alias-build ./test"
  }
set dist dir

default the dist dir is 'dist'

  "scripts": {
    "build": "typescript-module-alias-build ./test --out-dir release"
  }

Finally, that will build to "release" dir

Example

  • tsconfig.json
{
  "compileOnSave": true,
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node",
    "esModuleInterop": true,
    "lib": [
      "es5",
      "es2015",
      "es2017"
    ],
    "baseUrl": "./",
    "paths": {
      "@test/*": ["./test/*"]
    }
  }
}
  • module test/a.ts
  import b from '@test/b';
  console.log('module a run success !!!', b);
  • module test/b.ts
  console.log('module b run success !!!');
  export default 1;

Advanced use

Integration with nodemon

we can use the nodemon exec command to run our old lib script

  "scripts": {
    "dev": "nodemon --exec typescript-module-alias ./src/a/index.ts"
  },
2.2.9

2 years ago

2.2.8

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.2.5

2 years ago

2.2.4

2 years ago

2.2.7

2 years ago

2.2.6

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago