Skip to content

Commit 25496bb

Browse files
fix: tolerate an undefined baseUrl compiler option (#208)
* fix: tolerate an undefined `baseUrl` compiler option * chore: clean up changelog * chore: update changelog Co-authored-by: Jonas Kello <jonaskello@users.noreply.github.com>
1 parent 1081597 commit 25496bb

2 files changed

Lines changed: 12 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10-
### Added
11-
12-
- Add `cwd` option to `register` function that overrides where the `tsconfig.json` search begins. See PR [#205](https://github.com/dividab/tsconfig-paths/pull/205).
13-
- Add support for `jsconfig.json`. See PR [#199](https://github.com/dividab/tsconfig-paths/pull/199). Thanks to [@F3n67u](https://github.com/F3n67u) for this PR!
14-
- Let `paths` mappings be absolute paths. See PR [#184](https://github.com/dividab/tsconfig-paths/pull/184).
15-
1610
### Changed
1711

1812
- Ignore `--project`/`-P` CLI flag when explicit options are passed to `register`. See PR [#206](https://github.com/dividab/tsconfig-paths/pull/206).
1913

2014
### Added
2115

2216
- Add `cwd` option to `register` function that overrides where the `tsconfig.json` search begins. See PR [#205](https://github.com/dividab/tsconfig-paths/pull/205).
17+
- Add support for `jsconfig.json`. See PR [#199](https://github.com/dividab/tsconfig-paths/pull/199). Thanks to [@F3n67u](https://github.com/F3n67u) for this PR!
18+
- Let `paths` mappings be absolute paths. See PR [#184](https://github.com/dividab/tsconfig-paths/pull/184).
19+
20+
### Fixed
21+
22+
- Tolerate an undefined `baseUrl` compiler option. See PR [#208](https://github.com/dividab/tsconfig-paths/pull/208).
2323

2424
## [3.14.1] - 2022-03-22
2525

src/config-loader.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface ConfigLoaderParams {
2121
export interface ConfigLoaderSuccessResult {
2222
resultType: "success";
2323
configFileAbsolutePath: string;
24-
baseUrl: string;
24+
baseUrl?: string;
2525
absoluteBaseUrl: string;
2626
paths: { [key: string]: Array<string> };
2727
mainFields?: Array<string>;
@@ -75,21 +75,15 @@ export function configLoader({
7575
};
7676
}
7777

78-
if (!loadResult.baseUrl) {
79-
return {
80-
resultType: "failed",
81-
message: "Missing baseUrl in compilerOptions",
82-
};
83-
}
84-
85-
const tsConfigDir = path.dirname(loadResult.tsConfigPath);
86-
const absoluteBaseUrl = path.join(tsConfigDir, loadResult.baseUrl);
87-
8878
return {
8979
resultType: "success",
9080
configFileAbsolutePath: loadResult.tsConfigPath,
9181
baseUrl: loadResult.baseUrl,
92-
absoluteBaseUrl,
82+
absoluteBaseUrl: path.join(
83+
path.dirname(loadResult.tsConfigPath),
84+
loadResult.baseUrl || ""
85+
),
9386
paths: loadResult.paths || {},
87+
addMatchAll: loadResult.baseUrl !== undefined,
9488
};
9589
}

0 commit comments

Comments
 (0)