Skip to content

Commit

Permalink
Allow specifying SystemJS builder configuration and bump version.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjrv committed Sep 7, 2017
1 parent d08d6a7 commit dc00bd8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,19 @@ Run `npm run cbuild -- --help` to see the command line options:
Options:
-h, --help output usage information
-V, --version output the version number
-d, --debug [flag] use development environment
-m, --map <package> add package to mappings
-s, --source <file> main JavaScript source to bundle
-p, --package <path> directory with package.json and config.js
-o, --out <file> write output bundle to file
-C, --out-config <file> write path mappings to new config file
-q, --quiet [flag] suppress terminal output
-v, --verbose [flag] print dependency tree of bundled files
-x, --static [flag] create static (sfx) bundle
-V, --version output the version number
-b, --builder-config <file> specify SystemJS builder configuration file
-d, --debug [flag] use development environment
-m, --map <package> add package to mappings
-s, --source <file> main JavaScript source to bundle
-p, --package <path> directory with package.json and config.js
-o, --out <file> write output bundle to file
-C, --out-config <file> write path mappings to new config file
-I, --include-config <file> merge another file into new config file
-q, --quiet [flag] suppress terminal output
-v, --verbose [flag] print dependency tree of bundled files
-x, --static [flag] create static (sfx) bundle
-h, --help output usage information
```

API
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cbuild",
"version": "0.1.3",
"version": "0.1.4",
"description": "Use SystemJS with npm instead of jspm",
"main": "dist/cbuild.js",
"typings": "dist/cbuild.d.ts",
Expand Down
13 changes: 8 additions & 5 deletions src/cbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export interface BuildOptions {
/** If true, create static (sfx) bundle. */
sfx?: boolean;

/** Main source file to bundle. */
builderPath?: string;

/** Bundled file to output. */
bundlePath?: string;

Expand Down Expand Up @@ -293,6 +296,7 @@ export function build(basePath: string, options: BuildOptions = {}) {
);
}

const builderPath = options.builderPath;
const bundlePath = options.bundlePath;
let sourcePath = options.sourcePath;

Expand Down Expand Up @@ -365,11 +369,10 @@ export function build(basePath: string, options: BuildOptions = {}) {

let makeBundle = options.sfx ? builder.buildStatic : builder.bundle;

const buildArguments = ([] as any[]).concat(
[ sourceUrl ],
(bundlePath ? [bundlePath] : []),
[{}]
);
const buildArguments: any[] = [ sourceUrl ];

if(bundlePath) buildArguments.push(bundlePath);
buildArguments.push({ config: builderPath ? require(builderPath) : null });

// Call systemjs-builder.
built = makeBundle.apply(builder, buildArguments);
Expand Down
14 changes: 9 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function printTree(root: Branch, indent = '') {

((cmd.version(require('../package.json').version) as Command)
.description('SystemJS node module bundling tool')
.option('-b, --builder-config <file>', 'specify SystemJS builder configuration file')
.option('-d, --debug [flag]', 'use development environment', parseBool)
.option('-m, --map <package>', 'add package to mappings',
parseList, [])
Expand All @@ -81,13 +82,15 @@ handleBundle(cmd.opts());

function handleBundle(opts: { [key: string]: any }) {
const basePath = path.resolve('.', opts['package']);
let builderPath = opts['builderConfig'];
let sourcePath: string = opts['source'];
const env = process.env['NODE_ENV'];
let debug: boolean = opts['debug'];
const quiet: boolean = opts['quiet'];
const verbose: boolean = opts['verbose'];
const sfx: boolean = opts['static'];

if(builderPath) builderPath = path.resolve('.', builderPath);
if(sourcePath) sourcePath = path.resolve('.', sourcePath);
if(env == 'development') debug = true;

Expand All @@ -108,13 +111,14 @@ function handleBundle(opts: { [key: string]: any }) {
process.chdir(basePath);

build(basePath, {
bundlePath: bundlePath,
debug: debug,
builderPath,
bundlePath,
debug,
includeConfigList: opts['includeConfig'],
mapPackages: opts['map'],
outConfigPath: outConfigPath,
sfx: sfx,
sourcePath: sourcePath
outConfigPath,
sfx,
sourcePath
}).then((result: BuildResult) => {
if(!quiet) {
if(verbose) {
Expand Down

0 comments on commit dc00bd8

Please sign in to comment.