Skip to content

Commit

Permalink
Add support for JSON dependencies.
Browse files Browse the repository at this point in the history
Upgraded deps and performed cleanup.
Fixes #13.
  • Loading branch information
RReverser committed Nov 14, 2014
1 parent 64d9577 commit 54a017c
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 49 deletions.
3 changes: 3 additions & 0 deletions lib/parseOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ module.exports = function (inOptions) {

options.getFileAST = inOptions.getFileAST || function (parseOpts) {
return getFileContents(parseOpts.source).then(function (js) {
if (pathUtils.ext(parseOpts.source) === 'json') {
js = 'module.exports = ' + js;
}
return esprima.parse(js, parseOpts);
});
};
Expand Down
4 changes: 4 additions & 0 deletions lib/pathUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ exports.getNodePath = function (from, to, options) {
moduleDirectory: options.moduleDir
}));
}
};

exports.ext = function (path) {
return stdUtils.extname(path).slice(1).toLowerCase();
};
4 changes: 1 addition & 3 deletions lib/templates/preamble.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
(function (%=
deps.map(function (dep) { return dep.id }).concat([b.identifier('define')])
%) {
(function (%= deps.map(function (dep) { return dep.id }) %, define) {
function _require(index) {
var module = _require.cache[index];

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pure-cjs",
"version": "1.15.0",
"version": "1.16.0",
"description": "Pure minimalistic CommonJS builder",
"bin": "./bin/pure-cjs.js",
"main": "./lib/index.js",
Expand All @@ -11,18 +11,18 @@
"author": "Ingvar Stepanyan <[email protected]> (http://github.com/RReverser)",
"license": "MIT",
"dependencies": {
"ast-types": "^0.5.2",
"commander": "^2.3.0",
"ast-types": "^0.6.5",
"commander": "^2.5.0",
"davy": "0.3.3",
"escodegen": "git+https://github.com/RReverser/escodegen.git",
"esprima": "^1.2.2",
"estemplate": "^0.2.0",
"estemplate": "^0.3.0",
"event-stream": "^3.1.7",
"resolve": "^1.0.0"
},
"devDependencies": {
"chai": "^1.9.2",
"mocha": "^1.21.5",
"chai": "^1.10.0",
"mocha": "^2.0.1",
"source-map": "^0.1.40"
}
}
1 change: 0 additions & 1 deletion test/fixtures/a.html

This file was deleted.

3 changes: 2 additions & 1 deletion test/fixtures/a.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ var c = require('./c'),
url = require('url'),
Promise = require('davy');

this.topValue = require('./sub/b.js') * 2;
this.topValue = require('./sub/b.js') * 2;
this.expectedValue = require('./data.json').answer;
30 changes: 0 additions & 30 deletions test/fixtures/a.out.js

This file was deleted.

3 changes: 3 additions & 0 deletions test/fixtures/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"answer": 42
}
6 changes: 5 additions & 1 deletion test/suites/a (exports A with externals)/expected.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/suites/a (exports A with externals)/expected.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion test/suites/a (exports A with map and comments)/expected.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 54a017c

Please sign in to comment.