Comparing version 3.0.3 to 3.1.0
{ | ||
"name": "tsconfck", | ||
"version": "3.0.3", | ||
"version": "3.1.0", | ||
"description": "A utility to work with tsconfig.json without typescript", | ||
@@ -51,8 +51,8 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@tsconfig/node18": "^18.2.2", | ||
"@vitest/coverage-v8": "^1.3.1", | ||
"esbuild": "^0.20.1", | ||
"@tsconfig/node18": "^18.2.4", | ||
"@vitest/coverage-v8": "^1.6.0", | ||
"esbuild": "^0.21.3", | ||
"tiny-glob": "^0.2.9", | ||
"typescript": "^5.4.2", | ||
"vitest": "^1.3.1" | ||
"typescript": "^5.4.5", | ||
"vitest": "^1.6.0" | ||
}, | ||
@@ -59,0 +59,0 @@ "engines": { |
@@ -8,3 +8,4 @@ import path from 'node:path'; | ||
resolveSolutionTSConfig, | ||
resolveTSConfigJson | ||
resolveTSConfigJson, | ||
replaceTokens | ||
} from './util.js'; | ||
@@ -106,2 +107,3 @@ import { findNative } from './find-native.js'; | ||
); | ||
checkErrors(nativeResult, tsconfigFile); | ||
@@ -112,8 +114,10 @@ | ||
tsconfigFile, | ||
tsconfig: result2tsconfig(nativeResult, ts), | ||
tsconfig: result2tsconfig(nativeResult, ts, tsconfigFile), | ||
result: nativeResult | ||
}; | ||
if (!skipCache) { | ||
cache?.setParseResult(tsconfigFile, Promise.resolve(result)); | ||
} | ||
return result; | ||
@@ -172,5 +176,6 @@ } | ||
* @param {any} ts typescript | ||
* @param {string} tsconfigFile | ||
* @returns {object} tsconfig with merged compilerOptions and enums restored to their string form | ||
*/ | ||
function result2tsconfig(result, ts) { | ||
function result2tsconfig(result, ts, tsconfigFile) { | ||
// dereference result.raw so changes below don't modify original | ||
@@ -250,3 +255,4 @@ const tsconfig = JSON.parse(JSON.stringify(result.raw)); | ||
} | ||
return tsconfig; | ||
// ts itself has not replaced all tokens at this point, make sure they are | ||
return replaceTokens(tsconfig, path.dirname(tsconfigFile)); | ||
} | ||
@@ -253,0 +259,0 @@ |
@@ -10,2 +10,3 @@ import path from 'node:path'; | ||
resolve2posix, | ||
replaceTokens, | ||
resolveReferencedTSConfigFiles, | ||
@@ -140,3 +141,4 @@ resolveSolutionTSConfig, | ||
} | ||
return tsconfig; | ||
return replaceTokens(tsconfig, dir); | ||
} | ||
@@ -143,0 +145,0 @@ |
@@ -297,1 +297,15 @@ import path from 'node:path'; | ||
} | ||
/** | ||
* replace tokens like ${configDir} | ||
* @param {any} tsconfig | ||
* @param {string} configDir | ||
* @returns {any} | ||
*/ | ||
export function replaceTokens(tsconfig, configDir) { | ||
return JSON.parse( | ||
JSON.stringify(tsconfig) | ||
// replace ${configDir}, accounting for rebaseRelative emitted ../${configDir} | ||
.replaceAll(/"(?:\.\.\/)*\${configDir}/g, `"${native2posix(configDir)}`) | ||
); | ||
} |
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
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
68160
1874