Skip to content

Commit

Permalink
Expose the session/build cache in eyeglass.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseppstein committed Mar 23, 2019
1 parent 3c300cf commit 9bf60f7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/broccoli-eyeglass/src/index.ts
Expand Up @@ -132,6 +132,7 @@ class EyeglassCompiler extends BroccoliSassCompiler {
options.eyeglass.engines = options.eyeglass.engines || {};
options.eyeglass.engines.sass = options.eyeglass.engines.sass || sass;
options.eyeglass.installWithSymlinks = true;
options.eyeglass.buildCache = this.buildCache;

let eyeglass = new Eyeglass(options);

Expand Down
17 changes: 17 additions & 0 deletions packages/eyeglass/src/util/Options.ts
Expand Up @@ -67,6 +67,11 @@ export interface EyeglassConfig extends Required<EyeglassSpecificOptions<never>>
engines: Required<Engines>;
}

export interface BuildCache {
get(key: string): number | string | undefined;
set(key: string, value: number | string): void;
}

export interface EyeglassSpecificOptions<ExtraSandboxTypes = true | string> {
/**
* Where to find assets for the eyeglass project.
Expand Down Expand Up @@ -152,6 +157,16 @@ export interface EyeglassSpecificOptions<ExtraSandboxTypes = true | string> {
* * An empty list disables filesystem access (default).
*/
fsSandbox?: ExtraSandboxTypes | false | Array<string>;
/**
* The buildCache is provided by the caller to allow eyeglass to cache
* information about files including file contents repeated disk access to
* common files. The cache can be a Map, or some memory-capped cache like
* `lru-cache`. This cache will only have strings or numbers placed into it.
*
* The cache should be cleared by the caller whenever file changes may have
* occurred (usually between builds of a long-running watcher).
*/
buildCache?: BuildCache;
}

export interface SimpleDeprecatedOptions {
Expand Down Expand Up @@ -325,6 +340,8 @@ export function resolveConfig(options: Partial<EyeglassSpecificOptions>): Eyegla
defaultValue(options, "useGlobalModuleCache", () => true);
// There's no eyeglass module API changes in eyeglass 2.x so we default to silencing these warnings.
defaultValue(options, "assertEyeglassCompatibility", () => DEFAULT_EYEGLASS_COMPAT);
// Use a simple cache that just lasts for this one file if no buildCache is provided.
defaultValue(options, "buildCache", () => new Map());

options.fsSandbox = normalizeFsSandbox(options.fsSandbox, options.root!);
return options as EyeglassConfig;
Expand Down

0 comments on commit 9bf60f7

Please sign in to comment.