Skip to content

Commit

Permalink
Added support for external modules in command line parameter.
Browse files Browse the repository at this point in the history
Fixes #5.
  • Loading branch information
RReverser committed Oct 10, 2014
1 parent 35fecd9 commit 7417548
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Command-line options:
-e, --exports <id> top module exports destination (optional)
-x, --extension <ext> default extension for requires (defaults to "js")
-d, --module-dir <dir> modules directory name to look in (defaults to "node_modules")
-s, --external [hash] external modules (names or JSON hashes)
```

## Usage from Node.js
Expand Down
11 changes: 11 additions & 0 deletions bin/pure-cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ program
.option('-m, --map [file]', 'file to store source map to (optional)')
.option('-c, --comments', 'preserve comments in output')
.option('-e, --exports <id>', 'top module exports destination (optional)')
.option('-s, --external [hash]', 'external modules (names or JSON hashes)', function (value, obj) {
try {
var add = JSON.parse(value);
for (var name in add) {
obj[name] = add[name];
}
} catch (e) {
obj[value] = true;
}
return obj;
}, {})
.parse(process.argv);

if (!program.input) {
Expand Down
2 changes: 1 addition & 1 deletion lib/replacerMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function ReplacerMap(options) {
this.defaultExt = options.defaultExt;
this.moduleDir = options.moduleDir;
this.depsMap = options.deps.reduce(function (obj, dep) {
obj[pathUtils.getNodePath('.', dep.name, this)] = dep;
obj[pathUtils.getNodePath('_', dep.name, this)] = dep;
return obj;
}.bind(this), {});
}
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": "pure-cjs",
"version": "1.12.0",
"version": "1.12.1",
"description": "Pure minimalistic CommonJS builder",
"bin": "./bin/pure-cjs.js",
"main": "./lib/index.js",
Expand Down

0 comments on commit 7417548

Please sign in to comment.