Skip to content

Commit c1ade06

Browse files
committed
update
1 parent d398f53 commit c1ade06

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ myResolver.resolve(
111111
| restrictions | [] | A list of resolve restrictions |
112112
| roots | [] | A list of root paths |
113113
| symlinks | true | Whether to resolve symlinks to their symlinked location |
114-
| tsconfig | "tsconfig.json" | Path to the tsconfig.json file to use for paths mapping |
114+
| tsconfig | "auto" | Path to the tsconfig.json file to use for paths mapping, The default value "auto" means it will try to load tsconfig.json. |
115115
| unsafeCache | false | Use this cache object to unsafely cache the successful requests |
116116

117117
## Plugins

lib/ResolverFactory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ function createOptions(options) {
297297
preferRelative: options.preferRelative || false,
298298
preferAbsolute: options.preferAbsolute || false,
299299
restrictions: new Set(options.restrictions),
300-
tsconfig: options.tsconfig || "",
300+
tsconfig: options.tsconfig || "auto",
301301
};
302302
}
303303

lib/TsconfigPathsPlugin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ const { modulesResolveHandler } = require("./ModulesUtils");
2020
* @property {string=} context - Context directory for resolving relative paths
2121
*/
2222

23+
const DEFAULT_CONFIG_FILE = "tsconfig.json";
24+
2325
module.exports = class TsconfigPathsPlugin {
2426
/**
25-
* @param {string} configFile tsconfig file path
27+
* @param {"auto" | string} configFile tsconfig file path
2628
*/
2729
constructor(configFile) {
28-
this.configFile = configFile;
30+
this.configFile = configFile === "auto" ? DEFAULT_CONFIG_FILE : configFile;
2931
}
3032

3133
/**
3234
* @param {Resolver} resolver the resolver
3335
* @returns {void}
3436
*/
3537
apply(resolver) {
36-
if (!this.configFile) return;
37-
3838
const aliasTarget = resolver.ensureHook("internal-resolve");
3939
const moduleTarget = resolver.ensureHook("module");
4040
const aliasOptionsPromise = this.loadAndConvertPaths(resolver);

0 commit comments

Comments
 (0)