Bump the npm group with 2 updates (#2045)
* Bump the npm group with 2 updates Bumps the npm group with 2 updates: [eslint](https://github.com/eslint/eslint) and [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import). Updates `eslint` from 8.55.0 to 8.56.0 - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.55.0...v8.56.0) Updates `eslint-plugin-import` from 2.29.0 to 2.29.1 - [Release notes](https://github.com/import-js/eslint-plugin-import/releases) - [Changelog](https://github.com/import-js/eslint-plugin-import/blob/main/CHANGELOG.md) - [Commits](https://github.com/import-js/eslint-plugin-import/compare/v2.29.0...v2.29.1) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm - dependency-name: eslint-plugin-import dependency-type: direct:development update-type: version-update:semver-patch dependency-group: npm ... Signed-off-by: dependabot[bot] <support@github.com> * Update checked-in dependencies --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
511f073971
commit
144b7d5b16
32 changed files with 618 additions and 251 deletions
6
node_modules/tsconfig-paths/CHANGELOG.md
generated
vendored
6
node_modules/tsconfig-paths/CHANGELOG.md
generated
vendored
|
|
@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [3.15.0] - 2023-12-14
|
||||
|
||||
### Added
|
||||
|
||||
- Add support for extends as array of strings to v3 (backport of #245). See PR #260. Thanks to [@domdomegg](https://github.com/domdomegg) for this PR!
|
||||
|
||||
## [3.14.1] - 2022-03-22
|
||||
|
||||
### Fixed
|
||||
|
|
|
|||
94
node_modules/tsconfig-paths/lib/__tests__/tsconfig-loader.test.js
generated
vendored
94
node_modules/tsconfig-paths/lib/__tests__/tsconfig-loader.test.js
generated
vendored
|
|
@ -112,25 +112,30 @@ describe("walkForTsConfig", function () {
|
|||
});
|
||||
});
|
||||
describe("loadConfig", function () {
|
||||
it("It should load a config", function () {
|
||||
it("should load a config", function () {
|
||||
var config = { compilerOptions: { baseUrl: "hej" } };
|
||||
var res = (0, tsconfig_loader_1.loadTsconfig)("/root/dir1/tsconfig.json", function (path) { return path === "/root/dir1/tsconfig.json"; }, function (_) { return JSON.stringify(config); });
|
||||
// assert.deepEqual(res, config);
|
||||
expect(res).toStrictEqual(config);
|
||||
});
|
||||
it("It should load a config with comments", function () {
|
||||
it("should load a config with comments", function () {
|
||||
var config = { compilerOptions: { baseUrl: "hej" } };
|
||||
var res = (0, tsconfig_loader_1.loadTsconfig)("/root/dir1/tsconfig.json", function (path) { return path === "/root/dir1/tsconfig.json"; }, function (_) { return "{\n // my comment\n \"compilerOptions\": { \n \"baseUrl\": \"hej\"\n }\n }"; });
|
||||
// assert.deepEqual(res, config);
|
||||
expect(res).toStrictEqual(config);
|
||||
});
|
||||
it("It should load a config with trailing commas", function () {
|
||||
it("should load a config with trailing commas", function () {
|
||||
var config = { compilerOptions: { baseUrl: "hej" } };
|
||||
var res = (0, tsconfig_loader_1.loadTsconfig)("/root/dir1/tsconfig.json", function (path) { return path === "/root/dir1/tsconfig.json"; }, function (_) { return "{\n \"compilerOptions\": { \n \"baseUrl\": \"hej\",\n },\n }"; });
|
||||
// assert.deepEqual(res, config);
|
||||
expect(res).toStrictEqual(config);
|
||||
});
|
||||
it("It should load a config with extends and overwrite all options", function () {
|
||||
it("should throw an error including the file path when encountering invalid JSON5", function () {
|
||||
expect(function () {
|
||||
return (0, tsconfig_loader_1.loadTsconfig)("/root/dir1/tsconfig.json", function (path) { return path === "/root/dir1/tsconfig.json"; }, function (_) { return "{\n \"compilerOptions\": {\n }"; });
|
||||
}).toThrowError("/root/dir1/tsconfig.json is malformed JSON5: invalid end of input at 3:12");
|
||||
});
|
||||
it("should load a config with string extends and overwrite all options", function () {
|
||||
var firstConfig = {
|
||||
extends: "../base-config.json",
|
||||
compilerOptions: { baseUrl: "kalle", paths: { foo: ["bar2"] } },
|
||||
|
|
@ -170,7 +175,7 @@ describe("loadConfig", function () {
|
|||
},
|
||||
});
|
||||
});
|
||||
it("It should load a config with extends from node_modules and overwrite all options", function () {
|
||||
it("should load a config with string extends from node_modules and overwrite all options", function () {
|
||||
var firstConfig = {
|
||||
extends: "my-package/base-config.json",
|
||||
compilerOptions: { baseUrl: "kalle", paths: { foo: ["bar2"] } },
|
||||
|
|
@ -210,7 +215,7 @@ describe("loadConfig", function () {
|
|||
},
|
||||
});
|
||||
});
|
||||
it("Should use baseUrl relative to location of extended tsconfig", function () {
|
||||
it("should use baseUrl relative to location of extended tsconfig", function () {
|
||||
var firstConfig = { compilerOptions: { baseUrl: "." } };
|
||||
var firstConfigPath = (0, path_1.join)("/root", "first-config.json");
|
||||
var secondConfig = { extends: "../first-config.json" };
|
||||
|
|
@ -242,5 +247,82 @@ describe("loadConfig", function () {
|
|||
compilerOptions: { baseUrl: (0, path_1.join)("..", "..") },
|
||||
});
|
||||
});
|
||||
it("should load a config with array extends and overwrite all options", function () {
|
||||
var baseConfig1 = {
|
||||
compilerOptions: { baseUrl: ".", paths: { foo: ["bar"] } },
|
||||
};
|
||||
var baseConfig1Path = (0, path_1.join)("/root", "base-config-1.json");
|
||||
var baseConfig2 = { compilerOptions: { baseUrl: "." } };
|
||||
var baseConfig2Path = (0, path_1.join)("/root", "dir1", "base-config-2.json");
|
||||
var baseConfig3 = {
|
||||
compilerOptions: { baseUrl: ".", paths: { foo: ["bar2"] } },
|
||||
};
|
||||
var baseConfig3Path = (0, path_1.join)("/root", "dir1", "dir2", "base-config-3.json");
|
||||
var actualConfig = {
|
||||
extends: [
|
||||
"./base-config-1.json",
|
||||
"./dir1/base-config-2.json",
|
||||
"./dir1/dir2/base-config-3.json",
|
||||
],
|
||||
};
|
||||
var actualConfigPath = (0, path_1.join)("/root", "tsconfig.json");
|
||||
var res = (0, tsconfig_loader_1.loadTsconfig)((0, path_1.join)("/root", "tsconfig.json"), function (path) {
|
||||
return [
|
||||
baseConfig1Path,
|
||||
baseConfig2Path,
|
||||
baseConfig3Path,
|
||||
actualConfigPath,
|
||||
].indexOf(path) >= 0;
|
||||
}, function (path) {
|
||||
if (path === baseConfig1Path) {
|
||||
return JSON.stringify(baseConfig1);
|
||||
}
|
||||
if (path === baseConfig2Path) {
|
||||
return JSON.stringify(baseConfig2);
|
||||
}
|
||||
if (path === baseConfig3Path) {
|
||||
return JSON.stringify(baseConfig3);
|
||||
}
|
||||
if (path === actualConfigPath) {
|
||||
return JSON.stringify(actualConfig);
|
||||
}
|
||||
return "";
|
||||
});
|
||||
expect(res).toEqual({
|
||||
extends: [
|
||||
"./base-config-1.json",
|
||||
"./dir1/base-config-2.json",
|
||||
"./dir1/dir2/base-config-3.json",
|
||||
],
|
||||
compilerOptions: {
|
||||
baseUrl: (0, path_1.join)("dir1", "dir2"),
|
||||
paths: { foo: ["bar2"] },
|
||||
},
|
||||
});
|
||||
});
|
||||
it("should load a config with array extends without .json extension", function () {
|
||||
var baseConfig = {
|
||||
compilerOptions: { baseUrl: ".", paths: { foo: ["bar"] } },
|
||||
};
|
||||
var baseConfigPath = (0, path_1.join)("/root", "base-config-1.json");
|
||||
var actualConfig = { extends: ["./base-config-1"] };
|
||||
var actualConfigPath = (0, path_1.join)("/root", "tsconfig.json");
|
||||
var res = (0, tsconfig_loader_1.loadTsconfig)((0, path_1.join)("/root", "tsconfig.json"), function (path) { return [baseConfigPath, actualConfigPath].indexOf(path) >= 0; }, function (path) {
|
||||
if (path === baseConfigPath) {
|
||||
return JSON.stringify(baseConfig);
|
||||
}
|
||||
if (path === actualConfigPath) {
|
||||
return JSON.stringify(actualConfig);
|
||||
}
|
||||
return "";
|
||||
});
|
||||
expect(res).toEqual({
|
||||
extends: ["./base-config-1"],
|
||||
compilerOptions: {
|
||||
baseUrl: ".",
|
||||
paths: { foo: ["bar"] },
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=tsconfig-loader.test.js.map
|
||||
2
node_modules/tsconfig-paths/lib/__tests__/tsconfig-loader.test.js.map
generated
vendored
2
node_modules/tsconfig-paths/lib/__tests__/tsconfig-loader.test.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/tsconfig-paths/lib/tsconfig-loader.d.ts
generated
vendored
2
node_modules/tsconfig-paths/lib/tsconfig-loader.d.ts
generated
vendored
|
|
@ -2,7 +2,7 @@
|
|||
* Typing for the parts of tsconfig that we care about
|
||||
*/
|
||||
export interface Tsconfig {
|
||||
extends?: string;
|
||||
extends?: string | string[];
|
||||
compilerOptions?: {
|
||||
baseUrl?: string;
|
||||
paths?: {
|
||||
|
|
|
|||
66
node_modules/tsconfig-paths/lib/tsconfig-loader.js
generated
vendored
66
node_modules/tsconfig-paths/lib/tsconfig-loader.js
generated
vendored
|
|
@ -82,30 +82,60 @@ function loadTsconfig(configFilePath, existsSync, readFileSync) {
|
|||
}
|
||||
var configString = readFileSync(configFilePath);
|
||||
var cleanedJson = StripBom(configString);
|
||||
var config = JSON5.parse(cleanedJson);
|
||||
var config;
|
||||
try {
|
||||
config = JSON5.parse(cleanedJson);
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error("".concat(configFilePath, " is malformed ").concat(e.message));
|
||||
}
|
||||
var extendedConfig = config.extends;
|
||||
if (extendedConfig) {
|
||||
if (typeof extendedConfig === "string" &&
|
||||
extendedConfig.indexOf(".json") === -1) {
|
||||
extendedConfig += ".json";
|
||||
var base = void 0;
|
||||
if (Array.isArray(extendedConfig)) {
|
||||
base = extendedConfig.reduce(function (currBase, extendedConfigElement) {
|
||||
return mergeTsconfigs(currBase, loadTsconfigFromExtends(configFilePath, extendedConfigElement, existsSync, readFileSync));
|
||||
}, {});
|
||||
}
|
||||
var currentDir = path.dirname(configFilePath);
|
||||
var extendedConfigPath = path.join(currentDir, extendedConfig);
|
||||
if (extendedConfig.indexOf("/") !== -1 &&
|
||||
extendedConfig.indexOf(".") !== -1 &&
|
||||
!existsSync(extendedConfigPath)) {
|
||||
extendedConfigPath = path.join(currentDir, "node_modules", extendedConfig);
|
||||
else {
|
||||
base = loadTsconfigFromExtends(configFilePath, extendedConfig, existsSync, readFileSync);
|
||||
}
|
||||
var base = loadTsconfig(extendedConfigPath, existsSync, readFileSync) || {};
|
||||
// baseUrl should be interpreted as relative to the base tsconfig,
|
||||
// but we need to update it so it is relative to the original tsconfig being loaded
|
||||
if (base.compilerOptions && base.compilerOptions.baseUrl) {
|
||||
var extendsDir = path.dirname(extendedConfig);
|
||||
base.compilerOptions.baseUrl = path.join(extendsDir, base.compilerOptions.baseUrl);
|
||||
}
|
||||
return __assign(__assign(__assign({}, base), config), { compilerOptions: __assign(__assign({}, base.compilerOptions), config.compilerOptions) });
|
||||
return mergeTsconfigs(base, config);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
exports.loadTsconfig = loadTsconfig;
|
||||
/**
|
||||
* Intended to be called only from loadTsconfig.
|
||||
* Parameters don't have defaults because they should use the same as loadTsconfig.
|
||||
*/
|
||||
function loadTsconfigFromExtends(configFilePath, extendedConfigValue,
|
||||
// eslint-disable-next-line no-shadow
|
||||
existsSync, readFileSync) {
|
||||
var _a;
|
||||
if (typeof extendedConfigValue === "string" &&
|
||||
extendedConfigValue.indexOf(".json") === -1) {
|
||||
extendedConfigValue += ".json";
|
||||
}
|
||||
var currentDir = path.dirname(configFilePath);
|
||||
var extendedConfigPath = path.join(currentDir, extendedConfigValue);
|
||||
if (extendedConfigValue.indexOf("/") !== -1 &&
|
||||
extendedConfigValue.indexOf(".") !== -1 &&
|
||||
!existsSync(extendedConfigPath)) {
|
||||
extendedConfigPath = path.join(currentDir, "node_modules", extendedConfigValue);
|
||||
}
|
||||
var config = loadTsconfig(extendedConfigPath, existsSync, readFileSync) || {};
|
||||
// baseUrl should be interpreted as relative to extendedConfigPath,
|
||||
// but we need to update it so it is relative to the original tsconfig being loaded
|
||||
if ((_a = config.compilerOptions) === null || _a === void 0 ? void 0 : _a.baseUrl) {
|
||||
var extendsDir = path.dirname(extendedConfigValue);
|
||||
config.compilerOptions.baseUrl = path.join(extendsDir, config.compilerOptions.baseUrl);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
function mergeTsconfigs(base, config) {
|
||||
base = base || {};
|
||||
config = config || {};
|
||||
return __assign(__assign(__assign({}, base), config), { compilerOptions: __assign(__assign({}, base.compilerOptions), config.compilerOptions) });
|
||||
}
|
||||
//# sourceMappingURL=tsconfig-loader.js.map
|
||||
2
node_modules/tsconfig-paths/lib/tsconfig-loader.js.map
generated
vendored
2
node_modules/tsconfig-paths/lib/tsconfig-loader.js.map
generated
vendored
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"tsconfig-loader.js","sourceRoot":"","sources":["../src/tsconfig-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2BAA6B;AAC7B,uBAAyB;AACzB,oCAAoC;AACpC,6BAAgC;AAChC,oCAAuC;AA+BvC,SAAgB,cAAc,CAAC,EAIR;QAHrB,MAAM,YAAA,EACN,GAAG,SAAA,EACH,gBAA0B,EAA1B,QAAQ,mBAAG,eAAe,KAAA;IAE1B,IAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAClD,IAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAElD,sEAAsE;IACtE,8DAA8D;IAC9D,IAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;IACnE,OAAO,UAAU,CAAC;AACpB,CAAC;AAZD,wCAYC;AAED,SAAS,eAAe,CACtB,GAAW,EACX,QAAiB,EACjB,OAAgB;IAEhB,2FAA2F;IAE3F,IAAM,UAAU,GAAG,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAEpD,IAAI,CAAC,UAAU,EAAE;QACf,OAAO;YACL,YAAY,EAAE,SAAS;YACvB,O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;QACnC,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACrD,MAAM,CAAC,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CACxC,UAAU,EACV,MAAM,CAAC,eAAe,CAAC,OAAO,CAC/B,CAAC;KACH;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CACrB,IAA0B,EAC1B,MAA4B;IAE5B,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IAClB,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;IAEtB,sCACK,IAAI,GACJ,MAAM,KACT,eAAe,wBACV,IAAI,CAAC,eAAe,GACpB,MAAM,CAAC,eAAe,KAE3B;AACJ,CAAC"}
|
||||
2
node_modules/tsconfig-paths/package.json
generated
vendored
2
node_modules/tsconfig-paths/package.json
generated
vendored
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tsconfig-paths",
|
||||
"version": "3.14.2",
|
||||
"version": "3.15.0",
|
||||
"description": "Load node modules according to tsconfig paths, in run-time or via API.",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
|
|
|
|||
116
node_modules/tsconfig-paths/src/__tests__/tsconfig-loader.test.ts
generated
vendored
116
node_modules/tsconfig-paths/src/__tests__/tsconfig-loader.test.ts
generated
vendored
|
|
@ -133,7 +133,7 @@ describe("walkForTsConfig", () => {
|
|||
});
|
||||
|
||||
describe("loadConfig", () => {
|
||||
it("It should load a config", () => {
|
||||
it("should load a config", () => {
|
||||
const config = { compilerOptions: { baseUrl: "hej" } };
|
||||
const res = loadTsconfig(
|
||||
"/root/dir1/tsconfig.json",
|
||||
|
|
@ -144,7 +144,7 @@ describe("loadConfig", () => {
|
|||
expect(res).toStrictEqual(config);
|
||||
});
|
||||
|
||||
it("It should load a config with comments", () => {
|
||||
it("should load a config with comments", () => {
|
||||
const config = { compilerOptions: { baseUrl: "hej" } };
|
||||
const res = loadTsconfig(
|
||||
"/root/dir1/tsconfig.json",
|
||||
|
|
@ -160,7 +160,7 @@ describe("loadConfig", () => {
|
|||
expect(res).toStrictEqual(config);
|
||||
});
|
||||
|
||||
it("It should load a config with trailing commas", () => {
|
||||
it("should load a config with trailing commas", () => {
|
||||
const config = { compilerOptions: { baseUrl: "hej" } };
|
||||
const res = loadTsconfig(
|
||||
"/root/dir1/tsconfig.json",
|
||||
|
|
@ -175,7 +175,21 @@ describe("loadConfig", () => {
|
|||
expect(res).toStrictEqual(config);
|
||||
});
|
||||
|
||||
it("It should load a config with extends and overwrite all options", () => {
|
||||
it("should throw an error including the file path when encountering invalid JSON5", () => {
|
||||
expect(() =>
|
||||
loadTsconfig(
|
||||
"/root/dir1/tsconfig.json",
|
||||
(path) => path === "/root/dir1/tsconfig.json",
|
||||
(_) => `{
|
||||
"compilerOptions": {
|
||||
}`
|
||||
)
|
||||
).toThrowError(
|
||||
"/root/dir1/tsconfig.json is malformed JSON5: invalid end of input at 3:12"
|
||||
);
|
||||
});
|
||||
|
||||
it("should load a config with string extends and overwrite all options", () => {
|
||||
const firstConfig = {
|
||||
extends: "../base-config.json",
|
||||
compilerOptions: { baseUrl: "kalle", paths: { foo: ["bar2"] } },
|
||||
|
|
@ -221,7 +235,7 @@ describe("loadConfig", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("It should load a config with extends from node_modules and overwrite all options", () => {
|
||||
it("should load a config with string extends from node_modules and overwrite all options", () => {
|
||||
const firstConfig = {
|
||||
extends: "my-package/base-config.json",
|
||||
compilerOptions: { baseUrl: "kalle", paths: { foo: ["bar2"] } },
|
||||
|
|
@ -273,7 +287,7 @@ describe("loadConfig", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("Should use baseUrl relative to location of extended tsconfig", () => {
|
||||
it("should use baseUrl relative to location of extended tsconfig", () => {
|
||||
const firstConfig = { compilerOptions: { baseUrl: "." } };
|
||||
const firstConfigPath = join("/root", "first-config.json");
|
||||
const secondConfig = { extends: "../first-config.json" };
|
||||
|
|
@ -309,4 +323,94 @@ describe("loadConfig", () => {
|
|||
compilerOptions: { baseUrl: join("..", "..") },
|
||||
});
|
||||
});
|
||||
|
||||
it("should load a config with array extends and overwrite all options", () => {
|
||||
const baseConfig1 = {
|
||||
compilerOptions: { baseUrl: ".", paths: { foo: ["bar"] } },
|
||||
};
|
||||
const baseConfig1Path = join("/root", "base-config-1.json");
|
||||
const baseConfig2 = { compilerOptions: { baseUrl: "." } };
|
||||
const baseConfig2Path = join("/root", "dir1", "base-config-2.json");
|
||||
const baseConfig3 = {
|
||||
compilerOptions: { baseUrl: ".", paths: { foo: ["bar2"] } },
|
||||
};
|
||||
const baseConfig3Path = join("/root", "dir1", "dir2", "base-config-3.json");
|
||||
const actualConfig = {
|
||||
extends: [
|
||||
"./base-config-1.json",
|
||||
"./dir1/base-config-2.json",
|
||||
"./dir1/dir2/base-config-3.json",
|
||||
],
|
||||
};
|
||||
const actualConfigPath = join("/root", "tsconfig.json");
|
||||
|
||||
const res = loadTsconfig(
|
||||
join("/root", "tsconfig.json"),
|
||||
(path) =>
|
||||
[
|
||||
baseConfig1Path,
|
||||
baseConfig2Path,
|
||||
baseConfig3Path,
|
||||
actualConfigPath,
|
||||
].indexOf(path) >= 0,
|
||||
(path) => {
|
||||
if (path === baseConfig1Path) {
|
||||
return JSON.stringify(baseConfig1);
|
||||
}
|
||||
if (path === baseConfig2Path) {
|
||||
return JSON.stringify(baseConfig2);
|
||||
}
|
||||
if (path === baseConfig3Path) {
|
||||
return JSON.stringify(baseConfig3);
|
||||
}
|
||||
if (path === actualConfigPath) {
|
||||
return JSON.stringify(actualConfig);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
);
|
||||
|
||||
expect(res).toEqual({
|
||||
extends: [
|
||||
"./base-config-1.json",
|
||||
"./dir1/base-config-2.json",
|
||||
"./dir1/dir2/base-config-3.json",
|
||||
],
|
||||
compilerOptions: {
|
||||
baseUrl: join("dir1", "dir2"),
|
||||
paths: { foo: ["bar2"] },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("should load a config with array extends without .json extension", () => {
|
||||
const baseConfig = {
|
||||
compilerOptions: { baseUrl: ".", paths: { foo: ["bar"] } },
|
||||
};
|
||||
const baseConfigPath = join("/root", "base-config-1.json");
|
||||
const actualConfig = { extends: ["./base-config-1"] };
|
||||
const actualConfigPath = join("/root", "tsconfig.json");
|
||||
|
||||
const res = loadTsconfig(
|
||||
join("/root", "tsconfig.json"),
|
||||
(path) => [baseConfigPath, actualConfigPath].indexOf(path) >= 0,
|
||||
(path) => {
|
||||
if (path === baseConfigPath) {
|
||||
return JSON.stringify(baseConfig);
|
||||
}
|
||||
if (path === actualConfigPath) {
|
||||
return JSON.stringify(actualConfig);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
);
|
||||
|
||||
expect(res).toEqual({
|
||||
extends: ["./base-config-1"],
|
||||
compilerOptions: {
|
||||
baseUrl: ".",
|
||||
paths: { foo: ["bar"] },
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
136
node_modules/tsconfig-paths/src/tsconfig-loader.ts
generated
vendored
136
node_modules/tsconfig-paths/src/tsconfig-loader.ts
generated
vendored
|
|
@ -9,7 +9,7 @@ import StripBom = require("strip-bom");
|
|||
* Typing for the parts of tsconfig that we care about
|
||||
*/
|
||||
export interface Tsconfig {
|
||||
extends?: string;
|
||||
extends?: string | string[];
|
||||
compilerOptions?: {
|
||||
baseUrl?: string;
|
||||
paths?: { [key: string]: Array<string> };
|
||||
|
|
@ -122,51 +122,105 @@ export function loadTsconfig(
|
|||
|
||||
const configString = readFileSync(configFilePath);
|
||||
const cleanedJson = StripBom(configString);
|
||||
const config: Tsconfig = JSON5.parse(cleanedJson);
|
||||
let config: Tsconfig;
|
||||
try {
|
||||
config = JSON5.parse(cleanedJson);
|
||||
} catch (e) {
|
||||
throw new Error(`${configFilePath} is malformed ${e.message}`);
|
||||
}
|
||||
|
||||
let extendedConfig = config.extends;
|
||||
|
||||
if (extendedConfig) {
|
||||
if (
|
||||
typeof extendedConfig === "string" &&
|
||||
extendedConfig.indexOf(".json") === -1
|
||||
) {
|
||||
extendedConfig += ".json";
|
||||
}
|
||||
const currentDir = path.dirname(configFilePath);
|
||||
let extendedConfigPath = path.join(currentDir, extendedConfig);
|
||||
if (
|
||||
extendedConfig.indexOf("/") !== -1 &&
|
||||
extendedConfig.indexOf(".") !== -1 &&
|
||||
!existsSync(extendedConfigPath)
|
||||
) {
|
||||
extendedConfigPath = path.join(
|
||||
currentDir,
|
||||
"node_modules",
|
||||
extendedConfig
|
||||
let base: Tsconfig;
|
||||
|
||||
if (Array.isArray(extendedConfig)) {
|
||||
base = extendedConfig.reduce(
|
||||
(currBase, extendedConfigElement) =>
|
||||
mergeTsconfigs(
|
||||
currBase,
|
||||
loadTsconfigFromExtends(
|
||||
configFilePath,
|
||||
extendedConfigElement,
|
||||
existsSync,
|
||||
readFileSync
|
||||
)
|
||||
),
|
||||
{}
|
||||
);
|
||||
} else {
|
||||
base = loadTsconfigFromExtends(
|
||||
configFilePath,
|
||||
extendedConfig,
|
||||
existsSync,
|
||||
readFileSync
|
||||
);
|
||||
}
|
||||
|
||||
const base =
|
||||
loadTsconfig(extendedConfigPath, existsSync, readFileSync) || {};
|
||||
|
||||
// baseUrl should be interpreted as relative to the base tsconfig,
|
||||
// but we need to update it so it is relative to the original tsconfig being loaded
|
||||
if (base.compilerOptions && base.compilerOptions.baseUrl) {
|
||||
const extendsDir = path.dirname(extendedConfig);
|
||||
base.compilerOptions.baseUrl = path.join(
|
||||
extendsDir,
|
||||
base.compilerOptions.baseUrl
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
...base,
|
||||
...config,
|
||||
compilerOptions: {
|
||||
...base.compilerOptions,
|
||||
...config.compilerOptions,
|
||||
},
|
||||
};
|
||||
return mergeTsconfigs(base, config);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Intended to be called only from loadTsconfig.
|
||||
* Parameters don't have defaults because they should use the same as loadTsconfig.
|
||||
*/
|
||||
function loadTsconfigFromExtends(
|
||||
configFilePath: string,
|
||||
extendedConfigValue: string,
|
||||
// eslint-disable-next-line no-shadow
|
||||
existsSync: (path: string) => boolean,
|
||||
readFileSync: (filename: string) => string
|
||||
): Tsconfig {
|
||||
if (
|
||||
typeof extendedConfigValue === "string" &&
|
||||
extendedConfigValue.indexOf(".json") === -1
|
||||
) {
|
||||
extendedConfigValue += ".json";
|
||||
}
|
||||
const currentDir = path.dirname(configFilePath);
|
||||
let extendedConfigPath = path.join(currentDir, extendedConfigValue);
|
||||
if (
|
||||
extendedConfigValue.indexOf("/") !== -1 &&
|
||||
extendedConfigValue.indexOf(".") !== -1 &&
|
||||
!existsSync(extendedConfigPath)
|
||||
) {
|
||||
extendedConfigPath = path.join(
|
||||
currentDir,
|
||||
"node_modules",
|
||||
extendedConfigValue
|
||||
);
|
||||
}
|
||||
|
||||
const config =
|
||||
loadTsconfig(extendedConfigPath, existsSync, readFileSync) || {};
|
||||
|
||||
// baseUrl should be interpreted as relative to extendedConfigPath,
|
||||
// but we need to update it so it is relative to the original tsconfig being loaded
|
||||
if (config.compilerOptions?.baseUrl) {
|
||||
const extendsDir = path.dirname(extendedConfigValue);
|
||||
config.compilerOptions.baseUrl = path.join(
|
||||
extendsDir,
|
||||
config.compilerOptions.baseUrl
|
||||
);
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
function mergeTsconfigs(
|
||||
base: Tsconfig | undefined,
|
||||
config: Tsconfig | undefined
|
||||
): Tsconfig {
|
||||
base = base || {};
|
||||
config = config || {};
|
||||
|
||||
return {
|
||||
...base,
|
||||
...config,
|
||||
compilerOptions: {
|
||||
...base.compilerOptions,
|
||||
...config.compilerOptions,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue