Skip to content

Commit

Permalink
fix: tolerate an undefined baseUrl compiler option
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Apr 20, 2022
1 parent 98bbcdc commit 38e04a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/config-loader.ts
Expand Up @@ -22,7 +22,7 @@ export interface ConfigLoaderParams {
export interface ConfigLoaderSuccessResult {
resultType: "success";
configFileAbsolutePath: string;
baseUrl: string;
baseUrl?: string;
absoluteBaseUrl: string;
paths: { [key: string]: Array<string> };
mainFields?: Array<string>;
Expand Down Expand Up @@ -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,
};
}
1 change: 1 addition & 0 deletions src/register.ts
@@ -1,6 +1,7 @@
import { createMatchPath } from "./match-path-sync";
import { configLoader, ExplicitParams } from "./config-loader";
import { options } from "./options";
import * as path from "path";

const noOp = (): void => void 0;

Expand Down

0 comments on commit 38e04a8

Please sign in to comment.