ts-js-path-resolve
v0.0.9
Published
When TS compiler for path resolving use the tsconfig.json file, it isn't correctly work after compiling, couse nodejs require doesn't nkow how find module. This ismplementation use the NODE_PATH hack to add new path where nodejs should search for modules.
Maintainers
Readme
TS-JS-PATH-RESOLVE
Use the "NODE_PATH hack" to add new path from tsconfig.json where nodejs should search for modules. *Works with
typescript@>=2.0and only with -unix OS.
Installation
npm install ts-js-path-resolve --save-devUsage
rootDir
|
/src
|
/lib
|
main.ts
|
/lib2
|
/lib3
|
index.ts// ts-config.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"baseUrl": "./src",
"paths": {
"*": [
"./li/*"
],
"lib/*": ["./lib/*"]
}
},
}
// now can require some modules as:
// src/main.ts
import * as http from 'http';
import * as path from 'path';
import resolve from 'ts-js-path-resolve';
const configPath = path.join(__dirname, '..', 'tsconfig.json'); //add absolute path to tsconfig.json
resolve(configPath);
import module1 from 'lib/main';
import module2 from 'lib2/lib3/'; // now import currectly work after compilingflags
- --logs, -LG Get a logs display how change NODE_PATH
License
MIT
