From f784c79ca195bcf5b83e3b5a26285d116c0b7f44 Mon Sep 17 00:00:00 2001 From: Christopher Karper Date: Sun, 15 Feb 2015 14:52:40 -0500 Subject: [PATCH 1/2] Stub to ignore require('sys') --- lib/bundle.js | 9 +++++---- lib/empty.js | 0 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 lib/empty.js diff --git a/lib/bundle.js b/lib/bundle.js index 277347e..b45a885 100644 --- a/lib/bundle.js +++ b/lib/bundle.js @@ -61,16 +61,17 @@ function bundle (input, complete) { }, filter: function (id) { - if (id == 'nexeres') { return false; } //treat our new moudle as a builtin module + if (id == 'nexeres') { return false; } //treat our new module as a builtin module return !~builtins.indexOf(id); }, - extensions: ['.js', '.json' ], - ignoreMissing: true + extensions: [ '.js', '.json' ], + ignoreMissing: true, + modules: { sys: __dirname + '/empty.js' } }); /** event for missing packages, fixes conditional requires **/ md.on('missing', function(id, parent) { - _log("warn", "couldn't find require '"+id+"', errors may occur."); + _log("warn", "couldn't find require '" + id + "', errors may occur."); }); md.pipe(through(function (chunk) { diff --git a/lib/empty.js b/lib/empty.js new file mode 100644 index 0000000..e69de29 From 7a25c2bfd9db656918ff8b86d08307a2eac1fea8 Mon Sep 17 00:00:00 2001 From: Christopher Karper Date: Sun, 15 Feb 2015 15:02:58 -0500 Subject: [PATCH 2/2] This handles embedding 'bin' scripts with shebang interpreter directives at the start --- lib/bundle.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/bundle.js b/lib/bundle.js index b45a885..476b9b8 100644 --- a/lib/bundle.js +++ b/lib/bundle.js @@ -96,6 +96,10 @@ function bundle (input, complete) { //this is the result of require("someFile.json"), so we need to export it from the function req += "module.exports = " } + if ((/^\#\!/).test(dep.source)) { + dep.source = '//' + dep.source; + } + req += dep.source + "}"; dbuffer.push(JSON.stringify(dep.id) + ": ["+req+", "+!!dep.entry+", "+JSON.stringify(dep.deps)+"]")