typhonjs-config-jspm-parse v0.6.1

Provides several utility functions to parse JSPM packages and find normalized paths
from package.json and config.js using an instance of System / SystemJS Loader. This npm module works in the
Node execution environment and the browser. The following functions are available:
getPackageJSPMDependencies - Parses the packageObj / top level package.json for the JSPM entry to index JSPM dependencies. If an existing
jspmPackageMapobject hash exists then only the keys in that hash are resolved againstjspm.dependenciesentry inpackage.json.getPackageJSPMDevDependencies - Parses the packageObj / top level package.json for the JSPM entry to index JSPM devDependencies. If an existing
jspmPackageMapobject hash exists then only the keys in that hash are resolved againstjspm.devDependenciesentry inpackage.json.getPackageResolver- Returns an instance of PackageResolver which provides all top level (topLevelPackages) and child package (childPackageMap) dependencies. An optional
packageFilterparameter which is an array of strings will limit the resolver to specifically those top level packages. Additional methods:getDirectDependency,getDirectDependencyMap&getUniqueDependencyListprovide functionality to respectively return a specific direct child dependency, the direct child dependency map, or an array of all unique child dependencies.getRootPath - Returns the root execution path.
getTopLevelDependencies - Returns all top level package dependencies and devDependencies. If
jspmPackagesis defined only the keys ofjspmPackageswill be resolved.parseChildDependencies - Provides a map of all child dependencies defined in
config.js/System.packages.System.packagesstores the mapped dependency paths by afile://reference, but we actually want the mapped paths for the package. This function parsesSystem.packagesconverting the entries into the desired format.parseNormalizedPackage - Attempts to normalize and parse a packageName returning
nullif it is an invalid package or an object hash containing the parsed package details. Note: Only works in the Node execution environment.
To install: npm install typhonjs-config-jspm-parse
For the latest significant changes please see the CHANGELOG.
For instance in specifying further user defined mapped paths in additional config loading here is an example
from backbone-parse-es6-todos that maps a source file from a child dependency of backbone
(https://github.com/typhonjs-demos/backbone-parse-es6-todos/blob/master/config/config-app-paths.js):
var System = System || global.System;
var JSPMParser = JSPMParser || (typeof require !== 'undefined' ? require('typhonjs-config-jspm-parse') : undefined);
var packageResolver = JSPMParser.getPackageResolver(System);
var pathBackboneEvents = packageResolver.getDirectDependency('backbone', 'typhonjs-core-backbone-events');
System.config(
{
map:
{
'mainEventbus': pathBackboneEvents + '/src/mainEventbus.js',
}
});In the case of running in the browser load typhonjs-config-jspm-parse before usage.
<script src="jspm_packages/system.js"></script>
<script src="config.js"></script>
<script src="node_modules/typhonjs-config-jspm-parse/src/parser.js"></script>
<script src="config/config-app-paths.js"></script>
<script>System.import('main.js');</script>Please see package.json and the jspm entries from backbone-parse-es6-todos:
https://github.com/typhonjs-demos/backbone-parse-es6-todos/blob/master/package.json
In this case backbone is mapped to github:typhonjs-backbone-parse/backbone-parse-es6@master
The above code example searches for the mapped package typhonjs-core-backbone-events which is mapped
in the package.json of github:typhonjs-backbone-parse/backbone-parse-es6@master:
https://github.com/typhonjs-backbone-parse/backbone-parse-es6/blob/master/package.json