0.1.2 • Published 3 years ago

@benyap/tscpaths v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

This package is deprecated

Please use resolve-tspaths instead! It is a rewrite and tested version of this package.


@benyap/tscpaths

This is a fork of joonhocho's tscpaths. Credit goes to joonhocho for the original code.

npm version Dependency Status License

If you use Typescript's path mapping feature (by setting baseUrl and paths in tsconfig.json), you may have found that transpiling with tsc doesn't convert your aliases to proper relative paths. This causes problems as the transpiled code can't actually run with those path aliases - you'll get a "module not found" error.

Use this package after tsc transpilation to replace path aliases with relative paths so that you can develop using path aliases whilst still being able to ship working JavaScript code.

Comparison to tsconfig-paths

  • Use during compile time - no runtime dependencies!

Usage

  1. Install @benyap/tscpaths as a dev dependency using npm or yarn.

    npm install --save-dev @benyap/tscpaths
    # or
    yarn add -D @benyap/tscpaths
  2. Add it as a part of your build script in package.json after the code has been transpiled.

    "scripts": {
      "build": "tsc && tscpaths -p tsconfig.json -s ./src -o ./out",
    }

Options

flagshorthandrequireddefaultdescription
--src-syessource directory (where the source code is)
--out-oyesoutput directory of transpiled code (tsc --outDir)
--project-pnotsconfig.jsonpath to the project configuration file (tsconfig.json)
--extnojscomma separated list of extensions to match and replace
--verbosenoshow verbose output

Disclaimer

This is not a mature nor is it a well tested project. It works for some personal use cases. Feel free to fork or submit pull requests.