Single-page applications builder with continuous integration, granular updates and loader.
npm install spa#SPA 



!SPA
S ingle P age A pplications builder with continuous integration, granular updates and loader.
The general idea is to calculate dependencies offline and then eagerly cache/load modules in predefined order.
Also we can detect which files are changed and do partial updates.
Preferred module format is CommonJS.
Advantages:
- no async dependency resolution
- no AMD wrappers
- less moving parts and mutable state
- less data duplication and possible conflicts
- loader code is separate from application code
- loading progress is easy to visualize
spa -c spa.yaml
`
Options
Config file is a dict in YAML or JSON format with the following keys:
root(required) - path where the file search will start, may be relative to config file itself.
extensions(optional) - files to consider as modules, [".js"] by default.
excludes(optional) - files to ignore, empty by default.
List may contains wildcards/globs, eg. ./something/*/test/.js. Paths are relative to root path.
paths(optional) - path aliases to use during module name resolution.
Example:
`yaml
root: "/testimonial/"
paths:
vendor: "./lib/contrib"
`
This allows to use module /testimonial/lib/contrib/b.js from file /testimonial/src/a.js as require('vendor/b.js')
grab(optional) - do try grab all dependencies suppressing ExternalDependencyErrors.
Can walk inside node_modules with commonjs rules recursively. Default value is false.
hosting(required for web usage) - similar dict which specifies how to remap paths to URLs.
Keys - rules as in excludes, where you can select path fragments in brackets,
values - URI format where selected fragments will be substitutes.
If you want files to be included in cache manifest, they need to match at least one pattern in hosting as well.
Example:
`yaml
hosting:
"./lib/(*/.js)": "http://myapp.com/$1"
`
File ./lib/app/main.js will be loaded http://myapp.com/app/main.js.
hosting_map(optional) - relative path to output hosting map file. Can be omitted.
Hosting map format:
`json
{
"version": 1,
"files": {
"relative/hosting/path1.js": "node_modules/source/path1.js",
},
"manifest": {
"url": "relative/hosting/manifest.json",
"path": "node_modules/source/path1.js"
},
"index": {
"url": "http://site.com/hosting/index.html",
"path": "build/index.html"
}
}
`
loaders(optional) - rules which describe what module formats JS files use.
Keys - rules as in excludes, values - format types. Available formats:
- _cjs_ - CommonJS
- _amd_ - AMD or UMD.
- _junk_ - module needs to mutate window
- _raw_ - local variables from module needs to be in global context (like