Skip to content

Commit a9fab89

Browse files
committed
fix(tsConfig): path mapping by filing-cabinet
A PR pending in filingc-cabinet should be merged and published before this to be merged. REF: dependents/node-filing-cabinet#100
1 parent 19f9ccf commit a9fab89

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const list = dependencyTree.toList({
5050
* `requireConfig`: path to a requirejs config for AMD modules (allows for the result of aliased module paths)
5151
* `webpackConfig`: path to a webpack config for aliased modules
5252
* `tsConfig`: path to a typescript config (or a preloaded object representing the typescript config)
53+
* `tsConfigPath`: a (virtual) path to typescript config file when `tsConfig` option is given as an object, not a string. Needed to calculate [Path Mapping](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping). If not given when `tsConfig` is an object, **Path Mapping** is ignored. This is not needed when `tsConfig` is given as a path string.
5354
* `nodeModulesConfig`: config for resolving entry file for node_modules
5455
* `visited`: object used for avoiding redundant subtree generations via memoization.
5556
* `nonExistent`: array used for storing the list of partial paths that do not exist

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ module.exports._getDependencies = function(config = {}) {
106106
webpackConfig: config.webpackConfig,
107107
nodeModulesConfig: config.nodeModulesConfig,
108108
tsConfig: config.tsConfig,
109+
tsConfigPath: config.tsConfigPath,
109110
noTypeDefinitions: config.noTypeDefinitions
110111
});
111112

lib/config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = class Config {
1818
this.nodeModulesConfig = options.nodeModulesConfig;
1919
this.detectiveConfig = options.detective || options.detectiveConfig || {};
2020
this.tsConfig = options.tsConfig;
21+
this.tsConfigPath = options.tsConfigPath
2122
this.noTypeDefinitions = options.noTypeDefinitions;
2223

2324
this.filter = options.filter;
@@ -31,6 +32,7 @@ module.exports = class Config {
3132
const ts = require('typescript');
3233
const tsParsedConfig = ts.readJsonConfigFile(this.tsConfig, ts.sys.readFile);
3334
const obj = ts.parseJsonSourceFileConfigFileContent(tsParsedConfig, ts.sys, path.dirname(this.tsConfig));
35+
this.tsConfigPath = this.tsConfigPath || this.tsConfig
3436
this.tsConfig = obj.raw;
3537
}
3638

0 commit comments

Comments
 (0)