From 3f48b96d337112808eda48220a7ea5bd031c1a0b Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Wed, 20 Apr 2022 13:16:26 -0400 Subject: [PATCH 1/3] fix: tolerate an undefined `baseUrl` compiler option --- src/config-loader.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/config-loader.ts b/src/config-loader.ts index 3b5c7dc..71dfda2 100644 --- a/src/config-loader.ts +++ b/src/config-loader.ts @@ -22,7 +22,7 @@ export interface ConfigLoaderParams { export interface ConfigLoaderSuccessResult { resultType: "success"; configFileAbsolutePath: string; - baseUrl: string; + baseUrl?: string; absoluteBaseUrl: string; paths: { [key: string]: Array }; mainFields?: Array; @@ -76,21 +76,15 @@ export function configLoader({ }; } - if (!loadResult.baseUrl) { - return { - resultType: "failed", - message: "Missing baseUrl in compilerOptions", - }; - } - - const tsConfigDir = path.dirname(loadResult.tsConfigPath); - const absoluteBaseUrl = path.join(tsConfigDir, loadResult.baseUrl); - return { resultType: "success", configFileAbsolutePath: loadResult.tsConfigPath, baseUrl: loadResult.baseUrl, - absoluteBaseUrl, + absoluteBaseUrl: path.join( + path.dirname(loadResult.tsConfigPath), + loadResult.baseUrl || "" + ), paths: loadResult.paths || {}, + addMatchAll: loadResult.baseUrl !== undefined, }; } From 228d003322c40c4ba0ad444a2ca48664b30d21b5 Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Mon, 2 May 2022 13:22:04 -0400 Subject: [PATCH 2/3] chore: clean up changelog --- CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a480126..0199435 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,13 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -- Ability to use absolute paths. [#184](https://github.com/dividab/tsconfig-paths/pull/184) - -- 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! ### Added - 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). +- 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! +- Let `paths` mappings be absolute paths. See PR [#184](https://github.com/dividab/tsconfig-paths/pull/184). ## [3.14.1] - 2022-03-22 From b1647e4cda2a1d5b66a183c31ad648018a7281c4 Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Mon, 2 May 2022 13:25:37 -0400 Subject: [PATCH 3/3] chore: update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0199435..ea041db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - 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! - Let `paths` mappings be absolute paths. See PR [#184](https://github.com/dividab/tsconfig-paths/pull/184). +### Fixed + +- Tolerate an undefined `baseUrl` compiler option. See PR [#208](https://github.com/dividab/tsconfig-paths/pull/208). + ## [3.14.1] - 2022-03-22 ### Fixed