[Pkg-javascript-commits] [node-browser-pack] 84/141: handle standalone in browser-pack
Bastien Roucariès
rouca at moszumanska.debian.org
Thu May 4 10:23:27 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 c44aeb5ca05f3420b98e113cda01ae2e42782321
Author: James Halliday <mail at substack.net>
Date: Thu Jul 24 01:19:26 2014 -0700
handle standalone in browser-pack
---
index.js | 43 ++++++++++++++++-------
package.json | 113 +++++++++++++++++++++++++++++++----------------------------
2 files changed, 90 insertions(+), 66 deletions(-)
diff --git a/index.js b/index.js
index 8aed316..0352715 100644
--- a/index.js
+++ b/index.js
@@ -1,5 +1,6 @@
var JSONStream = require('JSONStream');
-var through = require('through');
+var through = require('through2');
+var umd = require('umd');
var fs = require('fs');
var path = require('path');
@@ -18,12 +19,13 @@ function newlinesIn(src) {
module.exports = function (opts) {
if (!opts) opts = {};
- var parser = opts.raw ? through() : JSONStream.parse([ true ]);
- var stream = through(
- function (buf) { parser.write(buf) },
+ var parser = opts.raw ? through.obj() : JSONStream.parse([ true ]);
+ var stream = through.obj(
+ function (buf, enc, next) { parser.write(buf); next() },
function () { parser.end() }
);
- parser.pipe(through(write, end));
+ parser.pipe(through.obj(write, end));
+ stream.standaloneModule = opts.standaloneModule;
var first = true;
var entries = [];
@@ -35,8 +37,16 @@ module.exports = function (opts) {
return stream;
- function write (row) {
- if (first) stream.queue(prelude + '({');
+ function write (row, enc, next) {
+ if (first && opts.standalone) {
+ var pre = umd.prelude(opts.standalone).trim();
+ stream.push(pre + 'return ');
+ }
+ else if (first && opts.hasExports) {
+ var pre = opts.externalRequireName || 'require';
+ this.push(pre + '=');
+ }
+ if (first) stream.push(prelude + '({');
if (row.sourceFile && !row.nomap) {
if (!sourcemap) {
@@ -67,7 +77,7 @@ module.exports = function (opts) {
']'
].join('');
- stream.queue(wrappedSource);
+ stream.push(wrappedSource);
lineno += newlinesIn(wrappedSource);
first = false;
@@ -75,13 +85,22 @@ module.exports = function (opts) {
entries[row.order] = row.id;
}
else if (row.entry) entries.push(row.id);
+ next();
}
function end () {
- if (first) stream.queue(prelude + '({');
+ if (first) stream.push(prelude + '({');
entries = entries.filter(function (x) { return x !== undefined });
- stream.queue('},{},' + JSON.stringify(entries) + ')');
+ stream.push('},{},' + JSON.stringify(entries) + ')');
+
+ if (opts.standalone) {
+ stream.push(
+ '(' + JSON.stringify(stream.standaloneModule) + ')'
+ + umd.postlude(opts.standalone)
+ );
+ }
+
if (sourcemap) {
var comment = sourcemap.comment();
if (opts.sourceMapPrefix) {
@@ -89,9 +108,9 @@ module.exports = function (opts) {
/^\/\/#/, function () { return opts.sourceMapPrefix }
)
}
- stream.queue('\n' + comment);
+ stream.push('\n' + comment);
}
- stream.queue(null);
+ stream.push(null);
}
};
diff --git a/package.json b/package.json
index 87071c8..89e222b 100644
--- a/package.json
+++ b/package.json
@@ -1,56 +1,61 @@
{
- "name": "browser-pack",
- "version": "2.0.1",
- "description": "pack node-style source files from a json stream into a browser bundle",
- "main": "index.js",
- "bin": {
- "browser-pack": "bin/cmd.js"
- },
- "dependencies": {
- "JSONStream": "~0.6.4",
- "through": "~2.3.4",
- "combine-source-map": "~0.3.0"
-
- },
- "devDependencies": {
- "tap": "~0.4.0",
- "tape": "~0.2.2",
- "uglify-js": "1.3.5",
- "convert-source-map": "~0.3.1",
- "parse-base64vlq-mappings": "~0.1.1"
- },
- "scripts": {
- "test": "tap test/*.js",
- "prepublish": "node bin/prepublish.js"
- },
- "testling" : {
- "files" : "test/*.js",
- "browsers" : [
- "ie/8", "ie/9", "ie/10",
- "chrome/15", "chrome/latest",
- "firefox/10", "firefox/latest",
- "safari/latest",
- "opera/latest"
- ]
- },
- "repository": {
- "type": "git",
- "url": "git://github.com/substack/browser-pack.git"
- },
- "homepage": "https://github.com/substack/browser-pack",
- "keywords": [
- "browser",
- "bundle",
- "commonjs",
- "commonj-esque",
- "exports",
- "module.exports",
- "require"
- ],
- "author": {
- "name": "James Halliday",
- "email": "mail at substack.net",
- "url": "http://substack.net"
- },
- "license": "MIT"
+ "name": "browser-pack",
+ "version": "2.0.1",
+ "description": "pack node-style source files from a json stream into a browser bundle",
+ "main": "index.js",
+ "bin": {
+ "browser-pack": "bin/cmd.js"
+ },
+ "dependencies": {
+ "JSONStream": "~0.6.4",
+ "combine-source-map": "~0.3.0",
+ "concat-stream": "~1.4.1",
+ "through2": "^0.5.1",
+ "umd": "^2.1.0"
+ },
+ "devDependencies": {
+ "tap": "~0.4.0",
+ "tape": "~0.2.2",
+ "uglify-js": "1.3.5",
+ "convert-source-map": "~0.3.1",
+ "parse-base64vlq-mappings": "~0.1.1"
+ },
+ "scripts": {
+ "test": "tap test/*.js",
+ "prepublish": "node bin/prepublish.js"
+ },
+ "testling": {
+ "files": "test/*.js",
+ "browsers": [
+ "ie/8",
+ "ie/9",
+ "ie/10",
+ "chrome/15",
+ "chrome/latest",
+ "firefox/10",
+ "firefox/latest",
+ "safari/latest",
+ "opera/latest"
+ ]
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/substack/browser-pack.git"
+ },
+ "homepage": "https://github.com/substack/browser-pack",
+ "keywords": [
+ "browser",
+ "bundle",
+ "commonjs",
+ "commonj-esque",
+ "exports",
+ "module.exports",
+ "require"
+ ],
+ "author": {
+ "name": "James Halliday",
+ "email": "mail at substack.net",
+ "url": "http://substack.net"
+ },
+ "license": "MIT"
}
--
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