Socket
Socket
Sign inDemoInstall

piping-browser

Package Overview
Dependencies
69
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.1.5

106

lib/piping.js
// Generated by CoffeeScript 1.6.2
(function() {
var browserify, chokidar, colors, convertSourceMap, fs, options, path, through;
var UglifyJS, browserify, chokidar, colors, convertSourceMap, fs, options, path, through;

@@ -19,2 +19,4 @@ path = require("path");

UglifyJS = require("uglify-js");
options = {

@@ -24,2 +26,3 @@ ignore: /(\/\.|~$)/,

debug: true,
minify: false,
build: {

@@ -42,3 +45,3 @@ "coffee": function(file, data) {

module.exports = function(ops, out) {
var basedir, bundle, key, value, watcher, _ref;
var basedir, bundle, file, files, key, uglify, value, vendor, vendorBuild, watcher, _i, _len, _ref, _ref1;

@@ -55,4 +58,4 @@ if ((typeof ops === "string" || ops instanceof String) && (typeof out === "string" || out instanceof String)) {

}
if (opts.build) {
_ref = opts.build;
if (ops.build) {
_ref = ops.build;
for (key in _ref) {

@@ -98,8 +101,57 @@ value = _ref[key];

debug: options.debug
}).on("error", function(err) {
return console.log("[piping-browser]".bold.yellow, "Error:", err);
}).on("end", function() {
return console.log("[piping-browser]".bold.yellow, "Built in", Date.now() - start, "ms");
}).pipe(fs.createWriteStream(path.resolve(basedir, o)));
}, function(err, src) {
if (err) {
return console.log("[piping-browser]".bold.yellow, "Error:", err);
} else {
if (options.minify) {
uglify(src, path.resolve(basedir, o));
} else {
fs.writeFileSync(path.resolve(basedir, o), src);
}
return console.log("[piping-browser]".bold.yellow, "Built in", Date.now() - start, "ms");
}
});
};
uglify = function(files, output, inputmap) {
var code, comment, compressed, compressor, file, map, mapopts, toplevel, _i, _len;
toplevel = null;
if (!(typeof files === "string" || files instanceof String)) {
for (_i = 0, _len = files.length; _i < _len; _i++) {
file = files[_i];
code = fs.readFileSync(file, "utf8");
toplevel = UglifyJS.parse(code, {
filename: file,
toplevel: toplevel
});
}
} else {
toplevel = UglifyJS.parse(files, {
filename: "bundle.js"
});
}
toplevel.figure_out_scope();
compressor = UglifyJS.Compressor();
compressed = toplevel.transform(compressor);
compressed.figure_out_scope();
compressed.compute_char_frequency();
compressed.mangle_names();
if (options.debug) {
mapopts = {
file: output
};
if (inputmap) {
mapopts.orig = inputmap;
}
map = UglifyJS.SourceMap(mapopts);
code = compressed.print_to_string({
source_map: map
});
comment = convertSourceMap.fromObject(map.get()).toComment();
code += "\n" + comment;
} else {
code = compressed.print_to_string();
}
return fs.writeFileSync(output, code);
};
watcher.on("change", function(file) {

@@ -111,2 +163,38 @@ console.log("[piping-browser]".bold.yellow, "File", path.relative(process.cwd(), file), "has changed, rebuilding");

});
if (options.vendor && options.vendor.files.length && options.vendor.out && options.vendor.path) {
files = [];
_ref1 = options.vendor.files;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
file = _ref1[_i];
files.push(path.resolve(basedir, options.vendor.path, file));
}
vendor = chokidar.watch(files, {
ignored: options.ignore,
ignoreInitial: true,
persistent: true
});
vendorBuild = function(out) {
var code, start, _j, _len1;
start = Date.now();
if (options.minify) {
uglify(files, path.resolve(basedir, out));
} else {
code = ";";
for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
file = files[_j];
code += fs.readFileSync(file, "utf8") + ";\n";
}
fs.writeFileSync(path.resolve(basedir, out), code);
}
return console.log("[piping-browser]".bold.yellow, "Vendor built in", Date.now() - start, "ms");
};
vendor.on("change", function(file) {
console.log("[piping-browser]".bold.yellow, "File", path.relative(process.cwd(), file), "has changed, rebuilding vendor");
if (options.watch) {
return vendorBuild(options.vendor.out);
}
});
vendorBuild(options.vendor.out);
}
return bundle(options.main, options.out);

@@ -113,0 +201,0 @@ };

5

package.json
{
"name": "piping-browser",
"version": "0.1.0",
"version": "0.1.5",
"description": "Keep your code piping hot! Rebuild your client side code on change without binaries",

@@ -11,3 +11,4 @@ "main": "lib/piping.js",

"convert-source-map": "0.2.x",
"through": "2.2.x"
"through": "2.2.x",
"uglify-js": "2.2.x"
},

@@ -14,0 +15,0 @@ "devDependencies": {

@@ -16,3 +16,3 @@ # Piping-browser

```javascript
require("piping-browser")({main:"./client/scripts/main.js",out:"./public/application.js"})
require("piping-browser")({main:"./client/scripts/main.js",out:"./public/application.js"});
```

@@ -26,2 +26,7 @@ ### Options

- __debug__ _(boolean)_: Whether browserify should run in debug mode or not. Debug mode turns on source maps. Defaults to true
- __minify__ _(boolean)_: Whether browserify should minify output with UglifyJS. Source maps for minified output are currently not working right, and are mostly disabled regardless of debug option.
- __vendor__ _(object)_: Specify configuration for building vendor files. Vendor files are concatenated in order and then minified if minify is true, and written to the given path.
-- __path__ _(string)_: Directory where vendor files are located, relative to file where piping-browser was required
-- __out__ _(string)_: Path where vendor ouput should be written, relative to the file where piping-browser was required
-- __files__ _(array)_: Array of vendor files, relative to vendor path.
- __build__ _(object)_: An object that maps file extensions, eg "coffee" to functions that take a filename and the files data and compiles it to javascript. By default can compile coffeescript files, with sourcemaps .

@@ -32,3 +37,3 @@

```javascript
require("piping-browser")("./client/scripts/main.js","./public/application.js")
require("piping-browser")("./client/scripts/main.js","./public/application.js");
```

@@ -40,6 +45,6 @@

if(!require("piping")()){
require("piping-browser")("./client/scripts/main.js","./public/application.js")
return
require("piping-browser")("./client/scripts/main.js","./public/application.js");
return;
}
// application logic here
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc