broccoli-webpack-cached
Advanced tools
Comparing version 0.2.0-beta to 0.3.0-beta
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
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
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
59143
54
911
7
11
1
7
2
+ Addedbroccoli-caching-writer@2.3.1(transitive)
+ Addedbroccoli-kitchen-sink-helpers@0.2.9(transitive)
+ Addedbroccoli-plugin@1.1.0(transitive)
+ Addedensure-posix-path@1.1.1(transitive)
+ Addedglob@5.0.15(transitive)
+ Addedmatcher-collection@1.1.2(transitive)
+ Addedwalk-sync@0.2.7(transitive)
- Removedacorn@3.3.0(transitive)
- Removedalign-text@0.1.4(transitive)
- Removedamdefine@1.0.1(transitive)
- Removedanymatch@1.3.2(transitive)
- Removedarr-diff@2.0.04.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@3.1.0(transitive)
- Removedarray-unique@0.2.10.3.2(transitive)
- Removedassert@1.5.1(transitive)
- Removedassign-symbols@1.0.0(transitive)
- Removedasync@0.2.100.9.21.5.2(transitive)
- Removedasync-each@1.0.6(transitive)
- Removedatob@2.1.2(transitive)
- Removedbase@0.11.2(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbig.js@3.2.0(transitive)
- Removedbinary-extensions@1.13.1(transitive)
- Removedbindings@1.5.0(transitive)
- Removedbraces@1.8.52.3.2(transitive)
- Removedbrowserify-aes@0.4.0(transitive)
- Removedbrowserify-zlib@0.1.4(transitive)
- Removedbuffer@4.9.2(transitive)
- Removedbuiltin-status-codes@3.0.0(transitive)
- Removedcache-base@1.0.1(transitive)
- Removedcall-bind@1.0.8(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.3(transitive)
- Removedcamelcase@1.2.1(transitive)
- Removedcenter-align@0.1.3(transitive)
- Removedchokidar@1.7.0(transitive)
- Removedclass-utils@0.3.6(transitive)
- Removedcliui@2.1.0(transitive)
- Removedclone@1.0.4(transitive)
- Removedcollection-visit@1.0.0(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedconsole-browserify@1.2.0(transitive)
- Removedconstants-browserify@1.0.0(transitive)
- Removedcopy-descriptor@0.1.1(transitive)
- Removedcrypto-browserify@3.3.0(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removeddefine-property@0.2.51.0.02.0.2(transitive)
- Removeddomain-browser@1.2.0(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedemojis-list@2.1.0(transitive)
- Removedenhanced-resolve@0.9.1(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedevents@1.1.1(transitive)
- Removedexpand-brackets@0.1.52.1.4(transitive)
- Removedexpand-range@1.8.2(transitive)
- Removedextend-shallow@2.0.13.0.2(transitive)
- Removedextglob@0.3.22.0.4(transitive)
- Removedfile-uri-to-path@1.0.0(transitive)
- Removedfilename-regex@2.0.1(transitive)
- Removedfill-range@2.2.44.0.0(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfor-own@0.1.5(transitive)
- Removedfragment-cache@0.2.1(transitive)
- Removedfsevents@1.2.13(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.7(transitive)
- Removedget-proto@1.0.1(transitive)
- Removedget-value@2.0.6(transitive)
- Removedglob-base@0.3.0(transitive)
- Removedglob-parent@2.0.0(transitive)
- Removedgopd@1.2.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhas-flag@1.0.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-value@0.3.11.0.0(transitive)
- Removedhas-values@0.1.41.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhttps-browserify@0.0.1(transitive)
- Removedieee754@1.2.1(transitive)
- Removedindexof@0.0.1(transitive)
- Removedinherits@2.0.3(transitive)
- Removedinterpret@0.6.6(transitive)
- Removedis-accessor-descriptor@1.0.1(transitive)
- Removedis-binary-path@1.0.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-data-descriptor@1.0.1(transitive)
- Removedis-descriptor@0.1.71.0.3(transitive)
- Removedis-dotfile@1.0.3(transitive)
- Removedis-equal-shallow@0.1.3(transitive)
- Removedis-extendable@0.1.11.0.1(transitive)
- Removedis-extglob@1.0.0(transitive)
- Removedis-glob@2.0.1(transitive)
- Removedis-number@2.1.03.0.04.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-posix-bracket@0.1.1(transitive)
- Removedis-primitive@2.0.0(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisobject@2.1.03.0.1(transitive)
- Removedjson5@0.5.1(transitive)
- Removedkind-of@3.2.24.0.06.0.3(transitive)
- Removedlazy-cache@1.0.4(transitive)
- Removedloader-utils@0.2.17(transitive)
- Removedlongest@1.0.1(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmap-visit@1.0.0(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedmath-random@1.0.4(transitive)
- Removedmemory-fs@0.2.0(transitive)
- Removedmicromatch@2.3.113.1.10(transitive)
- Removedminimist@0.0.10(transitive)
- Removedmixin-deep@1.3.2(transitive)
- Removednan@2.22.0(transitive)
- Removednanomatch@1.2.13(transitive)
- Removednode-libs-browser@0.7.0(transitive)
- Removednormalize-path@2.1.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedobject-copy@0.1.0(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject-visit@1.0.1(transitive)
- Removedobject.assign@4.1.7(transitive)
- Removedobject.omit@2.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedoptimist@0.6.1(transitive)
- Removedos-browserify@0.2.1(transitive)
- Removedpako@0.2.9(transitive)
- Removedparse-glob@3.0.4(transitive)
- Removedpascalcase@0.1.1(transitive)
- Removedpath-browserify@0.0.0(transitive)
- Removedpbkdf2-compat@2.0.1(transitive)
- Removedposix-character-classes@0.1.1(transitive)
- Removedpreserve@0.2.0(transitive)
- Removedprocess@0.11.10(transitive)
- Removedpunycode@1.4.1(transitive)
- Removedqs@6.13.1(transitive)
- Removedquerystring-es3@0.2.1(transitive)
- Removedrandomatic@3.1.1(transitive)
- Removedreaddirp@2.2.1(transitive)
- Removedregex-cache@0.4.4(transitive)
- Removedregex-not@1.0.2(transitive)
- Removedremove-trailing-separator@1.1.0(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedret@0.1.15(transitive)
- Removedright-align@0.1.3(transitive)
- Removedripemd160@0.2.0(transitive)
- Removedsafe-regex@1.1.0(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedset-value@2.0.1(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedsha.js@2.2.6(transitive)
- Removedside-channel@1.1.0(transitive)
- Removedside-channel-list@1.0.0(transitive)
- Removedside-channel-map@1.0.1(transitive)
- Removedside-channel-weakmap@1.0.2(transitive)
- Removedsnapdragon@0.8.2(transitive)
- Removedsnapdragon-node@2.1.1(transitive)
- Removedsnapdragon-util@3.0.1(transitive)
- Removedsource-list-map@0.1.8(transitive)
- Removedsource-map@0.4.40.5.7(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedsplit-string@3.1.0(transitive)
- Removedstatic-extend@0.1.2(transitive)
- Removedstream-browserify@2.0.2(transitive)
- Removedstream-http@2.8.3(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedsupports-color@3.2.3(transitive)
- Removedtapable@0.1.10(transitive)
- Removedtimers-browserify@2.0.12(transitive)
- Removedto-arraybuffer@1.0.1(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedto-regex@3.0.2(transitive)
- Removedto-regex-range@2.1.1(transitive)
- Removedtty-browserify@0.0.0(transitive)
- Removeduglify-js@2.7.5(transitive)
- Removeduglify-to-browserify@1.0.2(transitive)
- Removedunion-value@1.0.1(transitive)
- Removedunset-value@1.0.0(transitive)
- Removedurix@0.1.0(transitive)
- Removedurl@0.11.4(transitive)
- Removeduse@3.1.1(transitive)
- Removedutil@0.10.4(transitive)
- Removedvm-browserify@0.0.4(transitive)
- Removedwatchpack@0.2.9(transitive)
- Removedwebpack@1.15.0(transitive)
- Removedwebpack-core@0.6.9(transitive)
- Removedwindow-size@0.1.0(transitive)
- Removedwordwrap@0.0.20.0.3(transitive)
- Removedxtend@4.0.2(transitive)
- Removedyargs@3.10.0(transitive)