Comparing version 2.0.3 to 2.1.0-next.0
@@ -426,14 +426,37 @@ // src/find.ts | ||
]; | ||
while (extended[extended.length - 1].tsconfig.extends) { | ||
const extending = extended[extended.length - 1]; | ||
const extendedTSConfigFile = resolveExtends(extending.tsconfig.extends, extending.tsconfigFile); | ||
if (extended.some((x) => x.tsconfigFile === extendedTSConfigFile)) { | ||
const circle = extended.concat({ tsconfigFile: extendedTSConfigFile, tsconfig: null }).map((e) => e.tsconfigFile).join(" -> "); | ||
throw new TSConfckParseError( | ||
`Circular dependency in "extends": ${circle}`, | ||
"EXTENDS_CIRCULAR", | ||
result.tsconfigFile | ||
let pos = 0; | ||
const extendsPath = []; | ||
let currentBranchDepth = 0; | ||
while (pos < extended.length) { | ||
const extending = extended[pos]; | ||
extendsPath.push(extending.tsconfigFile); | ||
if (extending.tsconfig.extends) { | ||
currentBranchDepth += 1; | ||
let resolvedExtends; | ||
if (!Array.isArray(extending.tsconfig.extends)) { | ||
resolvedExtends = [resolveExtends(extending.tsconfig.extends, extending.tsconfigFile)]; | ||
} else { | ||
resolvedExtends = extending.tsconfig.extends.reverse().map((ex) => resolveExtends(ex, extending.tsconfigFile)); | ||
} | ||
const circularExtends = resolvedExtends.find( | ||
(tsconfigFile) => extendsPath.includes(tsconfigFile) | ||
); | ||
if (circularExtends) { | ||
const circle = extendsPath.concat([circularExtends]).join(" -> "); | ||
throw new TSConfckParseError( | ||
`Circular dependency in "extends": ${circle}`, | ||
"EXTENDS_CIRCULAR", | ||
result.tsconfigFile | ||
); | ||
} | ||
extended.splice( | ||
pos + 1, | ||
0, | ||
...await Promise.all(resolvedExtends.map((file) => parseFile(file, cache))) | ||
); | ||
} else { | ||
extendsPath.splice(-currentBranchDepth); | ||
currentBranchDepth = 0; | ||
} | ||
extended.push(await parseFile(extendedTSConfigFile, cache)); | ||
pos = pos + 1; | ||
} | ||
@@ -515,5 +538,7 @@ result.extended = extended; | ||
var REBASE_KEYS = [ | ||
// root | ||
"files", | ||
"include", | ||
"exclude", | ||
// compilerOptions | ||
"baseUrl", | ||
@@ -526,2 +551,3 @@ "rootDir", | ||
"declarationDir", | ||
// watchOptions | ||
"excludeDirectories", | ||
@@ -661,4 +687,7 @@ "excludeFiles" | ||
const ignoredErrorCodes = [ | ||
// see https://github.com/microsoft/TypeScript/blob/main/src/compiler/diagnosticMessages.json | ||
18002, | ||
// empty files list | ||
18003 | ||
// no inputs | ||
]; | ||
@@ -696,6 +725,5 @@ const criticalError = (_a = nativeResult.errors) == null ? void 0 : _a.find( | ||
enumeration: { | ||
1: "classic", | ||
2: "node", | ||
3: "node16", | ||
99: "nodenext" | ||
...ts.ModuleResolutionKind, | ||
2: "node" | ||
/*ts.ModuleResolutionKind uses "Node10" but in tsconfig it is just node"*/ | ||
} | ||
@@ -706,2 +734,3 @@ }, | ||
enumeration: { 0: "crlf", 1: "lf" } | ||
/*ts.NewLineKind uses different names*/ | ||
}, | ||
@@ -708,0 +737,0 @@ { name: "target", enumeration: ts.ScriptTarget } |
{ | ||
"name": "tsconfck", | ||
"version": "2.0.3", | ||
"version": "2.1.0-next.0", | ||
"description": "A utility to work with tsconfig.json without typescript", | ||
@@ -42,3 +42,3 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"typescript": "^4.3.5" | ||
"typescript": "^4.3.5 || ^5.0.1-rc || ^5.0.0" | ||
}, | ||
@@ -51,14 +51,14 @@ "peerDependenciesMeta": { | ||
"devDependencies": { | ||
"@commitlint/cli": "^17.4.2", | ||
"@commitlint/config-conventional": "^17.4.2", | ||
"@commitlint/cli": "^17.4.4", | ||
"@commitlint/config-conventional": "^17.4.4", | ||
"@tsconfig/node14": "^1.0.3", | ||
"@types/node": "^18.11.19", | ||
"@typescript-eslint/eslint-plugin": "^5.50.0", | ||
"@typescript-eslint/parser": "^5.50.0", | ||
"c8": "^7.12.0", | ||
"@types/node": "^18.14.1", | ||
"@typescript-eslint/eslint-plugin": "^5.53.0", | ||
"@typescript-eslint/parser": "^5.53.0", | ||
"c8": "^7.13.0", | ||
"chalk": "^5.2.0", | ||
"conventional-changelog-cli": "^2.2.2", | ||
"enquirer": "^2.3.6", | ||
"esbuild": "^0.17.5", | ||
"eslint": "^8.33.0", | ||
"esbuild": "^0.17.10", | ||
"eslint": "^8.34.0", | ||
"eslint-config-prettier": "^8.6.0", | ||
@@ -70,6 +70,6 @@ "eslint-plugin-markdown": "^3.0.0", | ||
"husky": "^8.0.3", | ||
"lint-staged": "^13.1.0", | ||
"minimist": "^1.2.7", | ||
"lint-staged": "^13.1.2", | ||
"minimist": "^1.2.8", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.8.3", | ||
"prettier": "^2.8.4", | ||
"rimraf": "^4.1.2", | ||
@@ -79,4 +79,4 @@ "semver": "^7.3.8", | ||
"tsm": "^2.3.0", | ||
"tsup": "^6.5.0", | ||
"typescript": "^4.9.5", | ||
"tsup": "^6.6.3", | ||
"typescript": "^5.0.1-rc", | ||
"uvu": "^0.5.6", | ||
@@ -110,4 +110,5 @@ "watchlist": "^0.3.1" | ||
"release": "node scripts/release.js", | ||
"release:dry": "pnpm release --dry" | ||
"release:dry": "pnpm release --dry", | ||
"release:next": "pnpm release --next" | ||
} | ||
} |
@@ -192,7 +192,5 @@ import path from 'path'; | ||
enumeration: { | ||
1: 'classic', | ||
2: 'node', | ||
3: 'node16', | ||
99: 'nodenext' | ||
} /*ts.ModuleResolutionKind uses different names*/ | ||
...ts.ModuleResolutionKind, | ||
2: 'node' /*ts.ModuleResolutionKind uses "Node10" but in tsconfig it is just node"*/ | ||
} | ||
}, | ||
@@ -199,0 +197,0 @@ { |
@@ -116,21 +116,49 @@ import path from 'path'; | ||
// but dereference tsconfig so that mergeExtended can modify the original without affecting extended[0] | ||
const extended = [ | ||
const extended: TSConfckParseResult[] = [ | ||
{ tsconfigFile: result.tsconfigFile, tsconfig: JSON.parse(JSON.stringify(result.tsconfig)) } | ||
]; | ||
while (extended[extended.length - 1].tsconfig.extends) { | ||
const extending = extended[extended.length - 1]; | ||
const extendedTSConfigFile = resolveExtends(extending.tsconfig.extends, extending.tsconfigFile); | ||
if (extended.some((x) => x.tsconfigFile === extendedTSConfigFile)) { | ||
const circle = extended | ||
.concat({ tsconfigFile: extendedTSConfigFile, tsconfig: null }) | ||
.map((e) => e.tsconfigFile) | ||
.join(' -> '); | ||
throw new TSConfckParseError( | ||
`Circular dependency in "extends": ${circle}`, | ||
'EXTENDS_CIRCULAR', | ||
result.tsconfigFile | ||
// flatten extends graph into extended | ||
let pos = 0; | ||
const extendsPath: string[] = []; | ||
let currentBranchDepth = 0; | ||
while (pos < extended.length) { | ||
const extending = extended[pos]; | ||
extendsPath.push(extending.tsconfigFile); | ||
if (extending.tsconfig.extends) { | ||
// keep following this branch | ||
currentBranchDepth += 1; | ||
let resolvedExtends: string[]; | ||
if (!Array.isArray(extending.tsconfig.extends)) { | ||
resolvedExtends = [resolveExtends(extending.tsconfig.extends, extending.tsconfigFile)]; | ||
} else { | ||
// reverse because typescript 5.0 treats ['a','b','c'] as c extends b extends a | ||
resolvedExtends = extending.tsconfig.extends | ||
.reverse() | ||
.map((ex: string) => resolveExtends(ex, extending.tsconfigFile)); | ||
} | ||
const circularExtends = resolvedExtends.find((tsconfigFile) => | ||
extendsPath.includes(tsconfigFile) | ||
); | ||
if (circularExtends) { | ||
const circle = extendsPath.concat([circularExtends]).join(' -> '); | ||
throw new TSConfckParseError( | ||
`Circular dependency in "extends": ${circle}`, | ||
'EXTENDS_CIRCULAR', | ||
result.tsconfigFile | ||
); | ||
} | ||
// add new extends to the list directly after current | ||
extended.splice( | ||
pos + 1, | ||
0, | ||
...(await Promise.all(resolvedExtends.map((file) => parseFile(file, cache)))) | ||
); | ||
} else { | ||
// reached a leaf, backtrack to the last branching point and continue | ||
extendsPath.splice(-currentBranchDepth); | ||
currentBranchDepth = 0; | ||
} | ||
extended.push(await parseFile(extendedTSConfigFile, cache)); | ||
pos = pos + 1; | ||
} | ||
@@ -137,0 +165,0 @@ result.extended = extended; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
217639
2995
1