Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

broccoli-eyeglass

Package Overview
Dependencies
Maintainers
4
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-eyeglass - npm Package Compare versions

Comparing version 4.1.5 to 4.2.0

22

lib/index.js

@@ -11,2 +11,3 @@ "use strict";

const persistentCacheDebug = debugGenerator("broccoli-eyeglass:persistent-cache");
const assetImportCacheDebug = debugGenerator("broccoli-eyeglass:asset-import-cache");
const CURRENT_VERSION = require(path.join(__dirname, "..", "package.json")).version;

@@ -69,2 +70,8 @@

this.events.on("compiling", this.handleNewFile.bind(this));
this._assetImportCache = Object.create(null);
this._assetImportCacheStats = {
hits: 0,
misses: 0,
};
}

@@ -88,2 +95,4 @@

details.options.assetsCache = this.cacheAssetImports.bind(this);
details.options.eyeglass.buildDir = details.destDir;

@@ -185,2 +194,15 @@ details.options.eyeglass.engines = details.options.eyeglass.engines || {};

}
// Cache the asset import code that is generated in eyeglass
cacheAssetImports(key, getValue) {
// if this has already been generated, return it from cache
if (this._assetImportCache[key] !== undefined) {
assetImportCacheDebug("cache hit for key '%s'", key);
this._assetImportCacheStats.hits += 1;
return this._assetImportCache[key];
}
assetImportCacheDebug("cache miss for key '%s'", key);
this._assetImportCacheStats.misses += 1;
return this._assetImportCache[key] = getValue();
}
};

4

package.json
{
"name": "broccoli-eyeglass",
"description": "Sass compiler for Broccoli with Eyeglass Integration",
"version": "4.1.5",
"version": "4.2.0",
"author": "Chris Eppstein <chris@eppsteins.net>",

@@ -31,3 +31,3 @@ "main": "lib/index.js",

"ensure-symlink": "^1.0.2",
"eyeglass": "^1.3.0",
"eyeglass": "^1.4.1",
"fs-tree-diff": "^0.5.3",

@@ -34,0 +34,0 @@ "glob": "^7.1.2",

@@ -1192,2 +1192,87 @@ /* Copyright 2016 LinkedIn Corp. Licensed under the Apache License, Version 2.0 (the "License");

it("caches main asset import scss", function() {
let projectDir = makeFixtures("projectDir", {
"file1.scss": '@import "assets";\n',
"file2.scss": '@import "assets";\n',
});
let expectedOutputDir = makeFixtures("expectedOutputDir", {
"file1.css": "",
"file2.css": "",
});
let compiler = new EyeglassCompiler(projectDir, {
cssDir: ".",
});
let builder = new broccoli.Builder(compiler);
// cache should start empty
assert.deepEqual(compiler._assetImportCache, {});
return build(builder)
.then(outputDir => {
assertEqualDirs(outputDir, expectedOutputDir);
// cache should have one entry
assert.notDeepEqual(compiler._assetImportCache, {});
assert.equal(Object.keys(compiler._assetImportCache).length, 1);
// first file should be a miss, 2nd should return from cache
assert.equal(compiler._assetImportCacheStats.misses, 1);
assert.equal(compiler._assetImportCacheStats.hits, 1);
});
});
it("caches module asset import scss", function() {
let projectDir = makeFixtures("projectDir", {
"file1.scss": '@import "eyeglass-module/assets";\n',
"file2.scss": '@import "eyeglass-module/assets";\n',
});
let eyeglassModDir = makeFixtures("eyeglassmod", {
"package.json": "{\n" +
' "name": "is_a_module",\n' +
' "keywords": ["eyeglass-module"],\n' +
' "main": "eyeglass-exports.js",\n' +
' "private": true,\n' +
' "eyeglass": {\n' +
' "name": "eyeglass-module",\n' +
' "needs": "*"\n' +
" }\n" +
"}",
"eyeglass-exports.js":
'var path = require("path");\n' +
"module.exports = function(eyeglass, sass) {\n" +
" return {\n" +
" sassDir: __dirname, // directory where the sass files are.\n" +
' assets: eyeglass.assets.export(path.join(__dirname, "images"))\n' +
" };\n" +
"};",
});
let expectedOutputDir = makeFixtures("expectedOutputDir", {
"file1.css": "",
"file2.css": ""
});
let compiler = new EyeglassCompiler(projectDir, {
cssDir: ".",
eyeglass: {
modules: [
{path: eyeglassModDir}
]
}
});
let builder = new broccoli.Builder(compiler);
// cache should start empty
assert.deepEqual(compiler._assetImportCache, {});
return build(builder)
.then(outputDir => {
assertEqualDirs(outputDir, expectedOutputDir);
// cache should have one entry
assert.notDeepEqual(compiler._assetImportCache, {});
assert.equal(Object.keys(compiler._assetImportCache).length, 1);
// first file should be a miss, 2nd should return from cache
assert.equal(compiler._assetImportCacheStats.misses, 1);
assert.equal(compiler._assetImportCacheStats.hits, 1);
});
});
it("can force invalidate the persistent cache", function() {

@@ -1194,0 +1279,0 @@ let projectDir = makeFixtures("projectDir", {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc