[Pkg-javascript-commits] [node-browser-pack] 23/141: minify prelude in-place so it gets out of your way. developers should be see their own code right away, not a bunch of prelude noise

Bastien Roucariès rouca at moszumanska.debian.org
Thu May 4 10:23:21 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-browser-pack.

commit a39c73b20e69d69319931dbf9c5db61cef4d2de2
Author: James Halliday <mail at substack.net>
Date:   Sat Feb 23 00:19:07 2013 -0800

    minify prelude in-place so it gets out of your way.
    developers should be see their own code right away, not a bunch of prelude noise
---
 index.js     | 9 ++++++++-
 package.json | 3 ++-
 prelude.js   | 4 ++--
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/index.js b/index.js
index 8b0a806..8e2014c 100644
--- a/index.js
+++ b/index.js
@@ -1,8 +1,15 @@
 var JSONStream = require('JSONStream');
 var duplexer = require('duplexer');
 var through = require('through');
+var uglify = require('uglify-js');
 
-var prelude = '(' + require('./prelude').toString() + ')(typeof require !== "undefined"&&require, {';
+var fs = require('fs');
+var path = require('path');
+
+var prelude = (function () {
+    var src = fs.readFileSync(path.join(__dirname, 'prelude.js'), 'utf8');
+    return uglify(src) + '(typeof require !== "undefined"&&require, {'
+})();
 
 module.exports = function (opts) {
     if (!opts) opts = {};
diff --git a/package.json b/package.json
index 3d20195..7ee653a 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,8 @@
     "dependencies": {
         "JSONStream": "~0.4.3",
         "duplexer": "~0.0.3",
-        "through": "~2.2.0"
+        "through": "~2.2.0",
+        "uglify-js": "1.3.4"
     },
     "devDependencies": {
         "tap": "~0.4.0",
diff --git a/prelude.js b/prelude.js
index 55cd9a8..c0c462c 100644
--- a/prelude.js
+++ b/prelude.js
@@ -7,7 +7,7 @@
 // anything defined in a previous bundle is accessed via the
 // orig method which is the requireuire for previous bundles
 
-module.exports = function(parent_req, modules, cache, entry) {
+(function(parent_req, modules, cache, entry) {
     function require(name){
         if(!cache[name]) {
             if(!modules[name]) {
@@ -25,4 +25,4 @@ module.exports = function(parent_req, modules, cache, entry) {
     }
     for(var i=0;i<entry.length;i++) require(entry[i]);
     return require;
-}
+})

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-browser-pack.git



More information about the Pkg-javascript-commits mailing list