A type of dependency graph, component manager, and package builder.
Compartment is part dependency graph, part component manager, part package builder, all handled through a manifest file. The manifest simply stores a list of components and their dependency on other components from the same manifest. Compartment provides an easy mechanism to create custom packaging builds with resolution for file types, system paths, and requirements.
Compartment was built to handle the dependencies for front-end files, like CSS and JS. It allows components to define source paths for multiple file types, making it really easy to customize and package. However, Compartment is pretty abstract and can be used in any way possible.
Require the module and instantiate a new instance.
var Compartment = require'compartment'graph = ;
Define the types of files the graph will support.
graphaddTypescss: '/src/css/'js: '/src/js/';
Either load the list of components from a manifest file, or define manually. Each component supports the following properties:
graphloadManifest'path/to/manifest.json';graphaddComponentsbutton:category: 'component'source:css: 'button.css'buttonGroup:category: 'component'require: 'button'source:css: 'button-group.css'modal:category: 'component'source:css: 'modal.css'js: 'modal.js';
Build a chain of components (or all) with optional category filtering.
graphbuildChain; // allgraphbuildChain'buttonGroup'; // build buttonGroup and dependenciesgraphbuildChainnull 'component'; // filter all by category
Return a merged list of sources based on the type.
graphbuildChain'buttonGroup'getPaths'css';// ['/src/css/button.css', '/src/css/button-group.css']
Run the following command in the project root to run all tests.