diff --git a/CHANGELOG.md b/CHANGELOG.md index abf034b..def7728 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,12 +7,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -### 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). - ### Changed - Ignore `--project`/`-P` CLI flag when explicit options are passed to `register`. See PR [#206](https://github.com/dividab/tsconfig-paths/pull/206). @@ -20,6 +14,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### 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). + +### Fixed + +- Tolerate an undefined `baseUrl` compiler option. See PR [#208](https://github.com/dividab/tsconfig-paths/pull/208). ## [3.14.1] - 2022-03-22 diff --git a/src/config-loader.ts b/src/config-loader.ts index 5c2185d..8f41602 100644 --- a/src/config-loader.ts +++ b/src/config-loader.ts @@ -21,7 +21,7 @@ export interface ConfigLoaderParams { export interface ConfigLoaderSuccessResult { resultType: "success"; configFileAbsolutePath: string; - baseUrl: string; + baseUrl?: string; absoluteBaseUrl: string; paths: { [key: string]: Array }; mainFields?: Array; @@ -75,21 +75,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, }; }