Skip to content

Commit beca296

Browse files
authored
Merge branch 'main' into main_161
2 parents 33b78c8 + 28d2767 commit beca296

File tree

7 files changed

+3218
-1642
lines changed

7 files changed

+3218
-1642
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
os: [ubuntu-latest, windows-latest]
25-
node: [18, 20]
25+
node: [18, 20, 22]
2626

2727
steps:
2828
- name: Clone repository

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
npm install dependency-tree
1111
```
1212

13-
* Works for JS (AMD, CommonJS, ES6 modules), Typescript, and CSS preprocessors (CSS (PostCSS), Sass, Stylus, and Less); basically, any module type supported by [Precinct](https://github.com/dependents/node-precinct).
13+
* Works for JS (AMD, CommonJS, ES6 modules), TypeScript, and CSS preprocessors (CSS (PostCSS), Sass, Stylus, and Less); basically, any module type supported by [Precinct](https://github.com/dependents/node-precinct).
1414
- For CommonJS modules, 3rd party dependencies (npm installed dependencies) are included in the tree by default
1515
- Dependency path resolutions are handled by [filing-cabinet](https://github.com/dependents/node-filing-cabinet)
1616
- Supports RequireJS and Webpack loaders
@@ -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
@@ -107,6 +107,7 @@ module.exports._getDependencies = function(config = {}) {
107107
webpackConfig: config.webpackConfig,
108108
nodeModulesConfig: config.nodeModulesConfig,
109109
tsConfig: config.tsConfig,
110+
tsConfigPath: config.tsConfigPath,
110111
noTypeDefinitions: config.noTypeDefinitions
111112
});
112113

lib/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ 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;
22-
2323
this.filter = options.filter;
2424

2525
if (!this.filename) throw new Error('filename not given');
@@ -31,6 +31,7 @@ module.exports = class Config {
3131
const ts = require('typescript');
3232
const tsParsedConfig = ts.readJsonConfigFile(this.tsConfig, ts.sys.readFile);
3333
const obj = ts.parseJsonSourceFileConfigFileContent(tsParsedConfig, ts.sys, path.dirname(this.tsConfig));
34+
this.tsConfigPath ||= this.tsConfig;
3435
this.tsConfig = obj.raw;
3536
}
3637

0 commit comments

Comments
 (0)