1.0.1 • Published 4 years ago

ts-transformer-replace-paths v1.0.1

Weekly downloads
2
License
UNLICENSED
Repository
github
Last release
4 years ago

ts-transformer-replace-paths

npm

TypeScript custom transformer that replaces import paths with regular expressions

tsconfig.json:

{
    "compilerOptions": {
        "plugins": [
            {
                "transform": "ts-transformer-replace-paths",
                "replaceImportPaths": {
                    "^foo/esm/(.+)": "foo/cjs/$1",
                    "^bar$": "buzz"
                }
            }
        ]
    }
}

Input:

import * as foo from 'foo/esm/index';
import { bar } from "bar";
import 'asd';

foo;
bar;

Output:

import * as foo from 'foo/cjs/index';
import { bar } from "buzz";
import 'asd';
foo;
bar;