Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'perf_tuning_asset_install'
- Loading branch information
Showing
11 changed files
with
521 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
221 changes: 167 additions & 54 deletions
221
packages/broccoli-eyeglass/src/broccoli_sass_compiler.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
export = SyncDiskCache; | ||
interface CacheHit { | ||
isCached: true; | ||
key: string; | ||
value: string; | ||
} | ||
interface CacheMiss { | ||
isCached: false; | ||
key: undefined; | ||
value: undefined; | ||
} | ||
|
||
interface SyncDiskCacheOptions { | ||
location?: string; | ||
compression?: 'deflate' | 'deflateRaw' | 'gzip'; | ||
} | ||
|
||
declare class SyncDiskCache { | ||
constructor(key: any, _?: any); | ||
constructor(key?: string, options?: SyncDiskCacheOptions); | ||
tmpdir: any; | ||
compression: any; | ||
key: any; | ||
root: any; | ||
clear(...args: any[]): any; | ||
compress(...args: any[]): any; | ||
decompress(...args: any[]): any; | ||
get(...args: any[]): any; | ||
has(...args: any[]): any; | ||
pathFor(...args: any[]): any; | ||
remove(...args: any[]): any; | ||
set(...args: any[]): any; | ||
clear(): void; | ||
compress(value: string): string; | ||
decompress(value: string): string; | ||
get(key: string): CacheHit | CacheMiss; | ||
has(key: string): boolean; | ||
pathFor(key: string): string; | ||
remove(key: string): void; | ||
set(key: string, value: string): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import BroccoliPlugin = require("broccoli-plugin"); | ||
import path = require("path"); | ||
import * as fs from "fs-extra"; | ||
|
||
type EnsureSymlinkSync = (srcFile: string, destLink: string) => void; | ||
/* eslint-disable-next-line @typescript-eslint/no-var-requires */ | ||
const ensureSymlink: EnsureSymlinkSync = require("ensure-symlink"); | ||
|
||
/** | ||
* An object where the keys are the files that will be created in the tree and | ||
* the values are the source files. | ||
* | ||
* @interface FileMap | ||
*/ | ||
interface FileMap { | ||
[relativePath: string]: string; | ||
} | ||
|
||
type BroccoliSymbolicLinkerOptions = | ||
Pick<BroccoliPlugin.BroccoliPluginOptions, "annotation" | "persistentOutput">; | ||
|
||
/** | ||
* Creates symlinks to the source files specified. | ||
* | ||
* BroccoliSymbolicLinker | ||
*/ | ||
export class BroccoliSymbolicLinker extends BroccoliPlugin { | ||
files: FileMap; | ||
constructor(fileMap?: FileMap | undefined, options: BroccoliSymbolicLinkerOptions = {}) { | ||
let pluginOpts: BroccoliPlugin.BroccoliPluginOptions = {needsCache: false}; | ||
Object.assign(pluginOpts, options); | ||
super([], pluginOpts); | ||
this.files = Object.assign({}, fileMap); | ||
} | ||
reset(fileMap?: FileMap | undefined): void { | ||
this.files = Object.assign({}, fileMap); | ||
} | ||
/** | ||
* Record that a symlink should be created from src to dest. | ||
* | ||
* This can be called many times before the build method is invoked. | ||
* Calling it after will not have an effect until the next time build() is | ||
* invoked. | ||
* | ||
* @param src The file that should be symlinked into the tree. | ||
* @param dest the relative path from the tree's root to the location of the | ||
* symlink. the filename does not have to be the same. | ||
* @returns the absolute path to the location where the symlink will be created. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/camelcase | ||
ln_s(src: string, dest: string): string { | ||
this.files[dest] = src; | ||
return path.join(this.outputPath, dest); | ||
} | ||
/** | ||
* Returns the number of symlinks that will be created. | ||
*/ | ||
numberOfFiles(): number { | ||
return Object.keys(this.files).length; | ||
} | ||
/** | ||
* Create the symlinks. Directories to them will be created as necessary. | ||
*/ | ||
build(): void { | ||
// eslint-disable-next-line no-console | ||
// console.log(`Building ${this.numberOfFiles()} symlinks for ${this["_annotation"]}.`); | ||
for (let dest of Object.keys(this.files)) { | ||
let src = this.files[dest]; | ||
// console.log(`linking ${src} to ${dest}`); | ||
dest = path.join(this.outputPath, dest) | ||
let dir = path.dirname(dest); | ||
fs.mkdirpSync(dir); | ||
ensureSymlink(src, dest) | ||
} | ||
} | ||
/** | ||
* Output the symlinks that will be created for debugging. | ||
*/ | ||
debug(): string { | ||
return Object.keys(this.files).join("\n"); | ||
} | ||
} |
Oops, something went wrong.