Comparing version 3.0.2 to 3.0.3
{ | ||
"name": "tsconfck", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "A utility to work with tsconfig.json without typescript", | ||
@@ -52,7 +52,7 @@ "license": "MIT", | ||
"@tsconfig/node18": "^18.2.2", | ||
"@vitest/coverage-v8": "^1.2.2", | ||
"esbuild": "^0.20.0", | ||
"@vitest/coverage-v8": "^1.3.1", | ||
"esbuild": "^0.20.1", | ||
"tiny-glob": "^0.2.9", | ||
"typescript": "^5.3.3", | ||
"vitest": "^1.2.2" | ||
"typescript": "^5.4.2", | ||
"vitest": "^1.3.1" | ||
}, | ||
@@ -59,0 +59,0 @@ "engines": { |
@@ -66,5 +66,13 @@ /** @template T */ | ||
* @param file | ||
* @param {boolean} isRootFile a flag to check if current file which involking the parse() api, used to distinguish the normal cache which only parsed by parseFile() | ||
* @param {Promise<T>} result | ||
*/ | ||
setParseResult(file, result) { | ||
setParseResult(file, result, isRootFile = false) { | ||
// _isRootFile_ is a temporary property for Promise result, used to prevent deadlock with cache | ||
Object.defineProperty(result, '_isRootFile_', { | ||
value: isRootFile, | ||
writable: false, | ||
enumerable: false, | ||
configurable: false | ||
}); | ||
this.#parsed.set(file, result); | ||
@@ -71,0 +79,0 @@ result |
@@ -40,3 +40,3 @@ import path from 'node:path'; | ||
} = makePromise(); | ||
cache?.setParseResult(filename, promise); | ||
cache?.setParseResult(filename, promise, true); | ||
try { | ||
@@ -80,3 +80,3 @@ let tsconfigFile = | ||
]).then(() => result); | ||
cache.setParseResult(filename, promise); | ||
cache.setParseResult(filename, promise, true); | ||
return promise; | ||
@@ -95,3 +95,7 @@ } | ||
async function parseFile(tsconfigFile, cache, skipCache) { | ||
if (!skipCache && cache?.hasParseResult(tsconfigFile)) { | ||
if ( | ||
!skipCache && | ||
cache?.hasParseResult(tsconfigFile) && | ||
!cache.getParseResult(tsconfigFile)._isRootFile_ | ||
) { | ||
return cache.getParseResult(tsconfigFile); | ||
@@ -118,3 +122,6 @@ } | ||
}); | ||
if (!skipCache) { | ||
if ( | ||
!skipCache && | ||
(!cache?.hasParseResult(tsconfigFile) || !cache.getParseResult(tsconfigFile)._isRootFile_) | ||
) { | ||
cache?.setParseResult(tsconfigFile, promise); | ||
@@ -121,0 +128,0 @@ } |
@@ -58,3 +58,5 @@ declare module 'tsconfck' { | ||
getParseResult(file: string): Promise<T> | T; | ||
/** | ||
* @param isRootFile a flag to check if current file which involking the parse() api, used to distinguish the normal cache which only parsed by parseFile() | ||
* */ | ||
private setParseResult; | ||
@@ -61,0 +63,0 @@ |
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
67544
1857