@stylable/core
Advanced tools
Comparing version 2.5.0-alpha.1 to 2.5.0
import { FileProcessor, MinimalFS } from './cached-process-file'; | ||
import { processNamespace, StylableMeta } from './stylable-processor'; | ||
import { TimedCacheOptions } from './timed-cache'; | ||
export interface StylableInfrastructure { | ||
@@ -7,3 +8,3 @@ fileProcessor: FileProcessor<StylableMeta>; | ||
} | ||
export declare function createInfrastructure(projectRoot: string, fileSystem: MinimalFS, onProcess?: (meta: StylableMeta, path: string) => StylableMeta, resolveOptions?: any, resolveNamespace?: typeof processNamespace): StylableInfrastructure; | ||
export declare function createInfrastructure(projectRoot: string, fileSystem: MinimalFS, onProcess?: (meta: StylableMeta, path: string) => StylableMeta, resolveOptions?: any, resolveNamespace?: typeof processNamespace, timedCacheOptions?: Omit<TimedCacheOptions, 'createKey'>): StylableInfrastructure; | ||
//# sourceMappingURL=create-infra-structure.d.ts.map |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const enhanced_resolve_1 = require("enhanced-resolve"); | ||
const path_1 = __importDefault(require("path")); | ||
@@ -11,6 +12,6 @@ const cached_process_file_1 = require("./cached-process-file"); | ||
const stylable_processor_1 = require("./stylable-processor"); | ||
const ResolverFactory = require('enhanced-resolve/lib/ResolverFactory'); | ||
function createInfrastructure(projectRoot, fileSystem, onProcess, resolveOptions = {}, resolveNamespace) { | ||
const eResolver = ResolverFactory.createResolver(Object.assign({ useSyncFileSystemCalls: true, fileSystem }, resolveOptions)); | ||
const resolvePath = (context = projectRoot, moduleId) => { | ||
const timed_cache_1 = require("./timed-cache"); | ||
function createInfrastructure(projectRoot, fileSystem, onProcess, resolveOptions = {}, resolveNamespace, timedCacheOptions) { | ||
const eResolver = enhanced_resolve_1.ResolverFactory.createResolver(Object.assign({ useSyncFileSystemCalls: true, fileSystem }, resolveOptions)); | ||
let resolvePath = (context = projectRoot, moduleId) => { | ||
if (!path_1.default.isAbsolute(moduleId) && moduleId.charAt(0) !== '.') { | ||
@@ -21,2 +22,6 @@ moduleId = eResolver.resolveSync({}, context, moduleId); | ||
}; | ||
if (timedCacheOptions) { | ||
const cacheManager = timed_cache_1.timedCache(resolvePath, Object.assign({ timeout: 1, useTimer: true, createKey: (args) => args.join(';') }, timedCacheOptions)); | ||
resolvePath = cacheManager.get; | ||
} | ||
const fileProcessor = cached_process_file_1.cachedProcessFile((from, content) => { | ||
@@ -23,0 +28,0 @@ return stylable_processor_1.process(parser_1.safeParse(content, { from: resolvePath(projectRoot, from) }), undefined, resolveNamespace); |
@@ -6,2 +6,3 @@ import { FileProcessor, MinimalFS } from './cached-process-file'; | ||
import { StylableResults, StylableTransformer, TransformerOptions, TransformHooks } from './stylable-transformer'; | ||
import { TimedCacheOptions } from './timed-cache'; | ||
import { IStylableOptimizer } from './types'; | ||
@@ -24,2 +25,3 @@ export interface StylableConfig { | ||
resolveNamespace?: typeof processNamespace; | ||
timedCacheOptions?: Omit<TimedCacheOptions, 'createKey'>; | ||
} | ||
@@ -38,2 +40,3 @@ export declare class Stylable { | ||
protected resolveNamespace?: typeof processNamespace | undefined; | ||
protected timedCacheOptions: Omit<TimedCacheOptions, 'createKey'>; | ||
static create(config: StylableConfig): Stylable; | ||
@@ -43,3 +46,3 @@ fileProcessor: FileProcessor<StylableMeta>; | ||
resolvePath: (ctx: string | undefined, path: string) => string; | ||
constructor(projectRoot: string, fileSystem: MinimalFS, requireModule: (path: string) => any, delimiter?: string, onProcess?: ((meta: StylableMeta, path: string) => StylableMeta) | undefined, diagnostics?: Diagnostics, hooks?: TransformHooks, resolveOptions?: any, optimizer?: IStylableOptimizer | undefined, mode?: 'production' | 'development', resolveNamespace?: typeof processNamespace | undefined); | ||
constructor(projectRoot: string, fileSystem: MinimalFS, requireModule: (path: string) => any, delimiter?: string, onProcess?: ((meta: StylableMeta, path: string) => StylableMeta) | undefined, diagnostics?: Diagnostics, hooks?: TransformHooks, resolveOptions?: any, optimizer?: IStylableOptimizer | undefined, mode?: 'production' | 'development', resolveNamespace?: typeof processNamespace | undefined, timedCacheOptions?: Omit<TimedCacheOptions, 'createKey'>); | ||
createTransformer(options?: Partial<TransformerOptions>): StylableTransformer; | ||
@@ -46,0 +49,0 @@ transform(meta: StylableMeta): StylableResults; |
@@ -10,3 +10,6 @@ "use strict"; | ||
class Stylable { | ||
constructor(projectRoot, fileSystem, requireModule, delimiter = '__', onProcess, diagnostics = new diagnostics_1.Diagnostics(), hooks = {}, resolveOptions = {}, optimizer, mode = 'production', resolveNamespace) { | ||
constructor(projectRoot, fileSystem, requireModule, delimiter = '__', onProcess, diagnostics = new diagnostics_1.Diagnostics(), hooks = {}, resolveOptions = {}, optimizer, mode = 'production', resolveNamespace, timedCacheOptions = { | ||
timeout: 1, | ||
useTimer: true | ||
}) { | ||
this.projectRoot = projectRoot; | ||
@@ -23,3 +26,4 @@ this.fileSystem = fileSystem; | ||
this.resolveNamespace = resolveNamespace; | ||
const { fileProcessor, resolvePath } = create_infra_structure_1.createInfrastructure(projectRoot, fileSystem, onProcess, resolveOptions, this.resolveNamespace); | ||
this.timedCacheOptions = timedCacheOptions; | ||
const { fileProcessor, resolvePath } = create_infra_structure_1.createInfrastructure(projectRoot, fileSystem, onProcess, resolveOptions, this.resolveNamespace, timedCacheOptions); | ||
this.resolvePath = resolvePath; | ||
@@ -35,3 +39,3 @@ this.fileProcessor = fileProcessor; | ||
throw new Error('Javascript files are not supported without requireModule options'); | ||
}, config.delimiter, config.onProcess, config.diagnostics, config.hooks, config.resolveOptions, config.optimizer, config.mode, config.resolveNamespace); | ||
}, config.delimiter, config.onProcess, config.diagnostics, config.hooks, config.resolveOptions, config.optimizer, config.mode, config.resolveNamespace, config.timedCacheOptions); | ||
} | ||
@@ -38,0 +42,0 @@ createTransformer(options = {}) { |
{ | ||
"name": "@stylable/core", | ||
"version": "2.5.0-alpha.1", | ||
"version": "2.5.0", | ||
"description": "CSS for Components", | ||
@@ -47,3 +47,3 @@ "main": "./cjs/index.js", | ||
"license": "BSD-3-Clause", | ||
"gitHead": "10d8c5a95de7e0cb4b7bfb85caa2819b25cec6bc" | ||
"gitHead": "9d3151697859778eb3c2fa08a11566819e8d4929" | ||
} |
@@ -0,1 +1,2 @@ | ||
import { ResolverFactory } from 'enhanced-resolve'; | ||
import path from 'path'; | ||
@@ -5,3 +6,3 @@ import { cachedProcessFile, FileProcessor, MinimalFS } from './cached-process-file'; | ||
import { process, processNamespace, StylableMeta } from './stylable-processor'; | ||
const ResolverFactory = require('enhanced-resolve/lib/ResolverFactory'); | ||
import { timedCache, TimedCacheOptions } from './timed-cache'; | ||
@@ -18,3 +19,4 @@ export interface StylableInfrastructure { | ||
resolveOptions: any = {}, | ||
resolveNamespace?: typeof processNamespace | ||
resolveNamespace?: typeof processNamespace, | ||
timedCacheOptions?: Omit<TimedCacheOptions, 'createKey'> | ||
): StylableInfrastructure { | ||
@@ -27,3 +29,3 @@ const eResolver = ResolverFactory.createResolver({ | ||
const resolvePath = (context: string | undefined = projectRoot, moduleId: string) => { | ||
let resolvePath = (context: string | undefined = projectRoot, moduleId: string) => { | ||
if (!path.isAbsolute(moduleId) && moduleId.charAt(0) !== '.') { | ||
@@ -35,2 +37,12 @@ moduleId = eResolver.resolveSync({}, context, moduleId); | ||
if (timedCacheOptions) { | ||
const cacheManager = timedCache(resolvePath, { | ||
timeout: 1, | ||
useTimer: true, | ||
createKey: (args: string[]) => args.join(';'), | ||
...timedCacheOptions | ||
}); | ||
resolvePath = cacheManager.get; | ||
} | ||
const fileProcessor = cachedProcessFile<StylableMeta>( | ||
@@ -37,0 +49,0 @@ (from, content) => { |
@@ -13,2 +13,3 @@ import { FileProcessor, MinimalFS } from './cached-process-file'; | ||
} from './stylable-transformer'; | ||
import { TimedCacheOptions } from './timed-cache'; | ||
import { IStylableOptimizer } from './types'; | ||
@@ -32,2 +33,3 @@ | ||
resolveNamespace?: typeof processNamespace; | ||
timedCacheOptions?: Omit<TimedCacheOptions, 'createKey'>; | ||
} | ||
@@ -53,3 +55,4 @@ | ||
config.mode, | ||
config.resolveNamespace | ||
config.resolveNamespace, | ||
config.timedCacheOptions | ||
); | ||
@@ -71,3 +74,7 @@ } | ||
protected mode: 'production' | 'development' = 'production', | ||
protected resolveNamespace?: typeof processNamespace | ||
protected resolveNamespace?: typeof processNamespace, | ||
protected timedCacheOptions: Omit<TimedCacheOptions, 'createKey'> = { | ||
timeout: 1, | ||
useTimer: true | ||
} | ||
) { | ||
@@ -79,3 +86,4 @@ const { fileProcessor, resolvePath } = createInfrastructure( | ||
resolveOptions, | ||
this.resolveNamespace | ||
this.resolveNamespace, | ||
timedCacheOptions | ||
); | ||
@@ -82,0 +90,0 @@ this.resolvePath = resolvePath; |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
648885
128
11232
0