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

broccoli-webpack-cached

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-webpack-cached - npm Package Compare versions

Comparing version 0.2.0-beta to 0.3.0-beta

.node-version

63

index.js

@@ -10,2 +10,3 @@ 'use strict';

var Plugin = require('broccoli-plugin');
var CachingWriter = require('broccoli-caching-writer');
var symlinkOrCopySync = require('symlink-or-copy').sync;

@@ -22,3 +23,3 @@

Plugin.call(this, [inputNode], {
CachingWriter.call(this, [inputNode], {
annotation: options.annotation

@@ -29,3 +30,3 @@ });

WebpackFilter.prototype = Object.create(Plugin.prototype);
WebpackFilter.prototype = Object.create(CachingWriter.prototype);
WebpackFilter.prototype.constructor = WebpackFilter;

@@ -85,11 +86,22 @@

// Save state between builds do that changes to module ids doesn't bust the cache
// unnecessarily (https://github.com/webpack/webpack/issues/1315)
if (!this.options.recordsPath) {
this.options.recordsPath = "/webpack.recordsPath.json";
}
// By default, log webpack's output to the console
var DEFAULT_LOG_OPTIONS = true;
// {
// var DEFAULT_LOG_OPTIONS = {
// // assets: true,
// colors: true,
// timings: true,
// modules: true,
// cached: true,
// reasons: true,
// hash: true
// // timings: true,
// // reasons: true,
// // chunkOrigins: true

@@ -176,5 +188,7 @@ // };

var memoryFS = that.compiler.outputFileSystem;
var writtenFiles = allMemoryFSFiles(memoryFS);
var writtenBuffersByFilepath = allMemoryFSFiles(memoryFS, {
ignore: that.options.recordsPath
});
// Question... does webpack re-write cached assets to the outputFileSystem?
var filesThatChanged = allChangedMemoryFSFiles(that.lastWrittenBuffersByFilepath, writtenBuffersByFilepath)

@@ -185,3 +199,3 @@ // Get all of the assets from webpack, both emitted in this current compile

writtenFiles.forEach(function(f) {
filesThatChanged.forEach(function(f) {
// Write the new file to the broccoli cache dir

@@ -205,2 +219,4 @@ mkdirp.sync(path.dirname(that.cachePath + f));

that.lastWrittenBuffersByFilepath = writtenBuffersByFilepath;
resolve();

@@ -213,15 +229,24 @@ }

var allMemoryFSFiles = function(memoryFS, dir) {
dir = dir !== undefined ? dir : '/';
var allMemoryFSFiles = function(memoryFS, options) {
options = options !== undefined ? options : {};
var dir = options.dir !== undefined ? options.dir : '/';
var ignore = options.ignore !== undefined ? options.ignore : [];
var result = [];
var result = options.resultsSoFar !== undefined ? options.resultsSoFar : Object.create(null);
var list = memoryFS.readdirSync(dir);
list.forEach(function(file) {
// Skip ignored files
if (ignore && ignore.indexOf(file) >= 0) {
return;
}
file = path.join(dir, file);
var stat = memoryFS.statSync(file);
if (stat && stat.isDirectory()) {
result = result.concat(allMemoryFSFiles(memoryFS, file));
options.dir = file;
options.resultsSoFar = results;
allMemoryFSFiles(memoryFS, options);
} else {
result.push(file);
result[file] = memoryFS.readFileSync(file);
}

@@ -233,2 +258,14 @@ });

var allChangedMemoryFSFiles = function(lastBuffersByFilepath, newBuffersByFilepath) {
var result = [];
Object.keys(newBuffersByFilepath).forEach(function(filepath) {
if (!lastBuffersByFilepath || !lastBuffersByFilepath[filepath] || lastBuffersByFilepath[filepath] !== newBuffersByFilepath[filepath]) {
result.push(filepath);
}
});
return result;
}
module.exports = WebpackFilter;
{
"name": "broccoli-webpack-cached",
"version": "0.2.0-beta",
"version": "0.3.0-beta",
"description": "Yet another webpack plugin for Broccoli. This one relies on webpack's caching for speed, but does it in a way that works well as a broccoli plugin (symlinking from the webpack cache to the output folder as needed).",

@@ -8,2 +8,3 @@ "main": "index.js",

"dependencies": {
"broccoli-caching-writer": "^2.2.1",
"broccoli-plugin": "^1.0.0",

@@ -14,7 +15,22 @@ "memory-fs": "^0.3.0",

"symlink-or-copy": "^1.0.1",
"webpack": "^1.10.5"
"webpack": "timmfin/webpack#mtime-for-caching"
},
"devDependencies": {},
"devDependencies": {
"broccoli": "^0.16.9",
"broccoli-babel-transpiler": "^5.5.0",
"broccoli-merge-trees": "^1.1.1",
"broccoli-stew": "^1.2.0",
"chai": "^3.5.0",
"css-loader": "^0.23.1",
"extract-text-webpack-plugin": "^1.0.1",
"html-webpack-plugin": "^2.7.2",
"mocha": "^2.4.5",
"source-map-loader": "^0.1.5",
"style-loader": "^0.13.0"
},
"scripts": {
"test": "mocha"
},
"author": "tfinley@hubspot.com",
"repository": "timmfin/broccoli-webpack-cached"
}

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