diff --git a/CHANGELOG.md b/CHANGELOG.md index def7728..f87f0c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - 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). +- Allow `baseUrl` in `tsconfig.json` to be an absolute path. See PR [#174](https://github.com/dividab/tsconfig-paths/pull/174). Thanks to [@nwalters512](https://github.com/nwalters512) for this PR! ### Fixed diff --git a/src/__tests__/config-loader.test.ts b/src/__tests__/config-loader.test.ts index 182ea21..a78ea16 100644 --- a/src/__tests__/config-loader.test.ts +++ b/src/__tests__/config-loader.test.ts @@ -97,4 +97,20 @@ describe("config-loader", (): void => { expect(successResult.resultType).toBe("success"); expect(successResult.configFileAbsolutePath).toBe(configFile); }); + + it("should allow an absolute baseUrl in tsconfig.json", () => { + const result = configLoader({ + explicitParams: undefined, + cwd: "/baz", + // tslint:disable-next-line:no-any + tsConfigLoader: (_: any) => ({ + tsConfigPath: "/baz/tsconfig.json", + baseUrl: "/baz", + paths: {}, + }), + }); + + const successResult = result as ConfigLoaderSuccessResult; + assert.equal(successResult.absoluteBaseUrl, "/baz"); + }); }); diff --git a/src/config-loader.ts b/src/config-loader.ts index 8f41602..796a518 100644 --- a/src/config-loader.ts +++ b/src/config-loader.ts @@ -79,7 +79,7 @@ export function configLoader({ resultType: "success", configFileAbsolutePath: loadResult.tsConfigPath, baseUrl: loadResult.baseUrl, - absoluteBaseUrl: path.join( + absoluteBaseUrl: path.resolve( path.dirname(loadResult.tsConfigPath), loadResult.baseUrl || "" ),