@stylable/core
Advanced tools
Comparing version 5.1.0 to 5.2.0
@@ -30,3 +30,8 @@ import type { FileProcessor } from './cached-process-file'; | ||
} | ||
export declare type CachedModuleEntity = InvalidCachedModule | CachedStylableMeta | CachedJsModule; | ||
export interface ResolveOnly { | ||
resolvedPath: string; | ||
kind: 'resolve'; | ||
value: null; | ||
} | ||
export declare type CachedModuleEntity = InvalidCachedModule | CachedStylableMeta | CachedJsModule | ResolveOnly; | ||
export declare type StylableResolverCache = Map<string, CachedModuleEntity>; | ||
@@ -33,0 +38,0 @@ export interface CSSResolve<T extends StylableSymbol = StylableSymbol> { |
@@ -23,10 +23,16 @@ "use strict"; | ||
var _a, _b, _c; | ||
let entity; | ||
let resolvedPath; | ||
const key = cacheKey(context, request); | ||
if ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.has(key)) { | ||
return this.cache.get(key); | ||
const entity = this.cache.get(key); | ||
if (entity.kind === 'resolve') { | ||
resolvedPath = entity.resolvedPath; | ||
} | ||
else { | ||
return entity; | ||
} | ||
} | ||
let entity; | ||
let resolvedPath; | ||
try { | ||
resolvedPath = this.moduleResolver(context, request); | ||
resolvedPath || (resolvedPath = this.moduleResolver(context, request)); | ||
} | ||
@@ -67,8 +73,15 @@ catch (error) { | ||
resolvePath(directoryPath, request) { | ||
var _a, _b; | ||
const resolvedPath = (_b = (_a = this.cache) === null || _a === void 0 ? void 0 : _a.get(cacheKey(directoryPath, request))) === null || _b === void 0 ? void 0 : _b.resolvedPath; | ||
if (resolvedPath) { | ||
var _a, _b, _c; | ||
const key = cacheKey(directoryPath, request); | ||
let resolvedPath = (_b = (_a = this.cache) === null || _a === void 0 ? void 0 : _a.get(key)) === null || _b === void 0 ? void 0 : _b.resolvedPath; | ||
if (resolvedPath !== undefined) { | ||
return resolvedPath; | ||
} | ||
return this.moduleResolver(directoryPath, request); | ||
resolvedPath = this.moduleResolver(directoryPath, request); | ||
(_c = this.cache) === null || _c === void 0 ? void 0 : _c.set(key, { | ||
resolvedPath, | ||
value: null, | ||
kind: 'resolve', | ||
}); | ||
return resolvedPath; | ||
} | ||
@@ -75,0 +88,0 @@ resolveImported(imported, name, subtype = 'mappedSymbols') { |
{ | ||
"name": "@stylable/core", | ||
"version": "5.1.0", | ||
"version": "5.2.0", | ||
"description": "CSS for Components", | ||
@@ -24,3 +24,3 @@ "main": "dist/index.js", | ||
"lodash.clonedeepwith": "^4.5.0", | ||
"postcss": "^8.4.14", | ||
"postcss": "^8.4.16", | ||
"postcss-js": "^4.0.0", | ||
@@ -27,0 +27,0 @@ "postcss-nested": "^5.0.6", |
@@ -51,3 +51,14 @@ import type { FileProcessor } from './cached-process-file'; | ||
export type CachedModuleEntity = InvalidCachedModule | CachedStylableMeta | CachedJsModule; | ||
export interface ResolveOnly { | ||
resolvedPath: string; | ||
kind: 'resolve'; | ||
value: null; | ||
} | ||
export type CachedModuleEntity = | ||
| InvalidCachedModule | ||
| CachedStylableMeta | ||
| CachedJsModule | ||
| ResolveOnly; | ||
export type StylableResolverCache = Map<string, CachedModuleEntity>; | ||
@@ -110,12 +121,18 @@ | ||
private getModule({ context, request }: Imported): CachedModuleEntity { | ||
let entity: CachedModuleEntity; | ||
let resolvedPath: string | undefined; | ||
const key = cacheKey(context, request); | ||
if (this.cache?.has(key)) { | ||
return this.cache.get(key)!; | ||
const entity = this.cache.get(key)!; | ||
if (entity.kind === 'resolve') { | ||
resolvedPath = entity.resolvedPath; | ||
} else { | ||
return entity; | ||
} | ||
} | ||
let entity: CachedModuleEntity; | ||
let resolvedPath: string; | ||
try { | ||
resolvedPath = this.moduleResolver(context, request); | ||
resolvedPath ||= this.moduleResolver(context, request); | ||
} catch (error) { | ||
@@ -155,7 +172,14 @@ entity = { | ||
public resolvePath(directoryPath: string, request: string): string { | ||
const resolvedPath = this.cache?.get(cacheKey(directoryPath, request))?.resolvedPath; | ||
if (resolvedPath) { | ||
const key = cacheKey(directoryPath, request); | ||
let resolvedPath = this.cache?.get(key)?.resolvedPath; | ||
if (resolvedPath !== undefined) { | ||
return resolvedPath; | ||
} | ||
return this.moduleResolver(directoryPath, request); | ||
resolvedPath = this.moduleResolver(directoryPath, request); | ||
this.cache?.set(key, { | ||
resolvedPath, | ||
value: null, | ||
kind: 'resolve', | ||
}); | ||
return resolvedPath; | ||
} | ||
@@ -162,0 +186,0 @@ public resolveImported( |
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
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
1096547
19639
Updatedpostcss@^8.4.16