Package Exports
- broccoli-caching-writer
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (broccoli-caching-writer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Broccoli Caching Writer
Drop-in-replacement for
broccoli-plugin adding a thin
caching layer based on the computed hash of the input directory trees. If any
file in an input node has changed, the build
method will be called,
otherwise (if input is the same) the results of the last build
call will be
used instead.
Example
Say your plugin derives from Plugin
like so:
var Plugin = require('broccoli-plugin');
MyPlugin.prototype = Object.create(Plugin.prototype);
MyPlugin.prototype.constructor = MyPlugin;
function MyPlugin(inputNodes, options) {
options = options || {};
Plugin.call(this, inputNodes, {
annotation: options.annotation
});
}
To add caching, simply replace Plugin
with CachingWriter
, like so:
var CachingWriter = require('broccoli-caching-writer');
MyPlugin.prototype = Object.create(CachingWriter.prototype);
MyPlugin.prototype.constructor = MyPlugin;
function MyPlugin(inputNodes, options) {
options = options || {};
CachingWriter.call(this, inputNodes, {
annotation: options.annotation
});
}
Documentation
new CachingWriter(inputNodes, options)
Call this base class constructor from your subclass constructor.
inputNodes
: An array of input nodes.options
:name
,annotation
,persistentOutput
: Same as broccoli-plugin; see there.cacheInclude
(default:[]
): An array of regular expressions that files and directories in an input node must pass (match at least one pattern) in order to be included in the cache hash for rebuilds. In other words, a whitelist of patterns that identify which files and/or directories can trigger a rebuild.cacheExclude
(default:[]
): An array of regular expressions that files and directories in an input node cannot pass in order to be included in the cache hash for rebuilds. In other words, a blacklist of patterns that identify which files and/or directories will never trigger a rebuild.Note, in the case when a file or directory matches both an include and exlude pattern, the exclude pattern wins
ZOMG!!! TESTS?!?!!?
I know, right?
Running the tests:
npm install
npm test
License
This project is distributed under the MIT license.