/ts-module-alias-transformer

A cli tool uses Babel to rewrite module name from typescript's build result including .d.ts files.

Primary LanguageTypeScriptMIT LicenseMIT

ts-module-alias-transformer

npm version Build Status

A cli tool uses Babel to rewrite module name from typescript's build result including .d.ts files.

It uses

This command line tool is bundled with all dependencies (including @babel/core). Thus, it doesn't require installing any dependencies and won't pollute the dependency tree in your local project.

Installation

npm install -g ts-module-alias-transformer

Usage

Usage: ts-module-alias-transformer [options] <src> [dst]

A cli tool uses Babel to rewrite module name from typescript's build result including .d.ts files.
  <src>: The source directory / file that contains typescript build result.
  [dst]: Optional. The destination directory / file. If not provided, output will replace the <src>.

Options:
  -V, --version                              output the version number
  -p, --mappingConfigPath <packageJsonPath>  Optional. Specify the mapping config json file location. 
                                             By default, it will read the `_moduleMappings` field of package.json in current working 
                                             directory to determine the module paths to replace. 
                                             See https://github.com/t83714/ts-module-alias-transformer for more details.
  -h, --help                                 output usage information

Configuration

By default, it will read the _moduleMappings field of package.json in current working directory to determine the module paths to replace (unless the switch -p is provided to specify an alternative config file location).

e.g. Here is an example:

{
  "name": "....",
  "version": "1.0.0",
  "description": "...",
  "_moduleMappings": {
      "@a/b/c": "../../a/b/c",
      "@x/y/z": "../d/e/f"
  }
}