Skip to content

Commit

Permalink
fix(tsConfig): path mapping by filing-cabinet
Browse files Browse the repository at this point in the history
A PR pending in filingc-cabinet should be merged and published before
this to be merged. REF: dependents/node-filing-cabinet#100
  • Loading branch information
jjangga0214 committed May 27, 2023
1 parent 19f9ccf commit a9fab89
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const list = dependencyTree.toList({
* `requireConfig`: path to a requirejs config for AMD modules (allows for the result of aliased module paths)
* `webpackConfig`: path to a webpack config for aliased modules
* `tsConfig`: path to a typescript config (or a preloaded object representing the typescript config)
* `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.
* `nodeModulesConfig`: config for resolving entry file for node_modules
* `visited`: object used for avoiding redundant subtree generations via memoization.
* `nonExistent`: array used for storing the list of partial paths that do not exist
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ module.exports._getDependencies = function(config = {}) {
webpackConfig: config.webpackConfig,
nodeModulesConfig: config.nodeModulesConfig,
tsConfig: config.tsConfig,
tsConfigPath: config.tsConfigPath,
noTypeDefinitions: config.noTypeDefinitions
});

Expand Down
2 changes: 2 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = class Config {
this.nodeModulesConfig = options.nodeModulesConfig;
this.detectiveConfig = options.detective || options.detectiveConfig || {};
this.tsConfig = options.tsConfig;
this.tsConfigPath = options.tsConfigPath
this.noTypeDefinitions = options.noTypeDefinitions;

this.filter = options.filter;
Expand All @@ -31,6 +32,7 @@ module.exports = class Config {
const ts = require('typescript');
const tsParsedConfig = ts.readJsonConfigFile(this.tsConfig, ts.sys.readFile);
const obj = ts.parseJsonSourceFileConfigFileContent(tsParsedConfig, ts.sys, path.dirname(this.tsConfig));
this.tsConfigPath = this.tsConfigPath || this.tsConfig
this.tsConfig = obj.raw;
}

Expand Down

0 comments on commit a9fab89

Please sign in to comment.