Other: Bundler provides useful stuff to uglify and a global var without extra bloat

This commit is contained in:
dcodeIO 2017-01-17 05:51:19 +01:00
parent 32e0529387
commit 168e448dba
21 changed files with 49 additions and 77 deletions

View File

@ -8,9 +8,9 @@
"Float32Array": true,
"Float64Array": true,
"define": true,
"global": true,
"XMLHttpRequest": true,
"Promise": true,
"dcodeIO": true
"Promise": true
},
"parserOptions": {
"ecmaVersion": 5

View File

@ -1,10 +1,10 @@
/*!
* protobuf.js v6.5.0 (c) 2016, Daniel Wirtz
* Compiled Tue, 17 Jan 2017 04:07:33 UTC
* Compiled Tue, 17 Jan 2017 04:40:35 UTC
* Licensed under the BSD-3-Clause License
* see: https://github.com/dcodeIO/protobuf.js for details
*/
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
!function(global,undefined){"use strict";(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";
module.exports = asPromise;
@ -5048,7 +5048,7 @@ util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next *
* @memberof util
* @type {boolean}
*/
util.isNode = typeof process !== "undefined" && Boolean(process.versions && process.versions.node);
util.isNode = Boolean(global.process && global.process.versions && global.process.versions.node);
/**
* Tests if the specified value is an integer.
@ -5136,7 +5136,7 @@ util.LongBits = require(32);
* Long.js's Long class if available.
* @type {?function(new: Long)}
*/
util.Long = typeof dcodeIO !== "undefined" && /* istanbul ignore next */ dcodeIO && /* istanbul ignore next */ dcodeIO.Long || util.inquire("long");
util.Long = /* istanbul ignore next */ global.dcodeIO && /* istanbul ignore next */ global.dcodeIO.Long || util.inquire("long");
/**
* Converts a number or long to an 8 characters long hash string.
@ -6059,7 +6059,7 @@ BufferWriterPrototype.string = function write_string_buffer(value) {
},{"33":33,"35":35}],37:[function(require,module,exports){
"use strict";
var protobuf = exports;
var protobuf = global.protobuf = exports;
/**
* A node-style callback as used by {@link load} and {@link Root#load}.
@ -6187,14 +6187,6 @@ function configure() {
protobuf.Reader._configure();
}
/* istanbul ignore next */
if (typeof window !== "undefined" && window)
window.protobuf = protobuf;
else if (typeof self !== "undefined" && self)
self.protobuf = protobuf;
else
this.protobuf = protobuf; // eslint-disable-line no-invalid-this
/* istanbul ignore next */
if (typeof define === "function" && define.amd)
define(["long"], function(Long) {
@ -6207,5 +6199,5 @@ if (typeof define === "function" && define.amd)
},{"11":11,"12":12,"13":13,"14":14,"15":15,"16":16,"17":17,"18":18,"19":19,"20":20,"21":21,"22":22,"23":23,"24":24,"25":25,"26":26,"28":28,"29":29,"30":30,"31":31,"34":34,"35":35,"36":36,"undefined":undefined}]},{},[37])
}(typeof window==="object"&&window||typeof self==="object"&&self||this);
//# sourceMappingURL=protobuf.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

20
dist/protobuf.js vendored
View File

@ -1,10 +1,10 @@
/*!
* protobuf.js v6.5.0 (c) 2016, Daniel Wirtz
* Compiled Tue, 17 Jan 2017 04:07:33 UTC
* Compiled Tue, 17 Jan 2017 04:40:35 UTC
* Licensed under the BSD-3-Clause License
* see: https://github.com/dcodeIO/protobuf.js for details
*/
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
!function(global,undefined){"use strict";(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";
module.exports = asPromise;
@ -6219,7 +6219,7 @@ util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next *
* @memberof util
* @type {boolean}
*/
util.isNode = typeof process !== "undefined" && Boolean(process.versions && process.versions.node);
util.isNode = Boolean(global.process && global.process.versions && global.process.versions.node);
/**
* Tests if the specified value is an integer.
@ -6307,7 +6307,7 @@ util.LongBits = require(35);
* Long.js's Long class if available.
* @type {?function(new: Long)}
*/
util.Long = typeof dcodeIO !== "undefined" && /* istanbul ignore next */ dcodeIO && /* istanbul ignore next */ dcodeIO.Long || util.inquire("long");
util.Long = /* istanbul ignore next */ global.dcodeIO && /* istanbul ignore next */ global.dcodeIO.Long || util.inquire("long");
/**
* Converts a number or long to an 8 characters long hash string.
@ -7230,7 +7230,7 @@ BufferWriterPrototype.string = function write_string_buffer(value) {
},{"36":36,"38":38}],40:[function(require,module,exports){
"use strict";
var protobuf = exports;
var protobuf = global.protobuf = exports;
/**
* A node-style callback as used by {@link load} and {@link Root#load}.
@ -7358,14 +7358,6 @@ function configure() {
protobuf.Reader._configure();
}
/* istanbul ignore next */
if (typeof window !== "undefined" && window)
window.protobuf = protobuf;
else if (typeof self !== "undefined" && self)
self.protobuf = protobuf;
else
this.protobuf = protobuf; // eslint-disable-line no-invalid-this
/* istanbul ignore next */
if (typeof define === "function" && define.amd)
define(["long"], function(Long) {
@ -7378,5 +7370,5 @@ if (typeof define === "function" && define.amd)
},{"11":11,"12":12,"13":13,"14":14,"15":15,"16":16,"17":17,"18":18,"19":19,"20":20,"21":21,"22":22,"23":23,"24":24,"25":25,"26":26,"27":27,"28":28,"30":30,"31":31,"32":32,"33":33,"34":34,"37":37,"38":38,"39":39}]},{},[40])
}(typeof window==="object"&&window||typeof self==="object"&&self||this);
//# sourceMappingURL=protobuf.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,10 @@
/*!
* protobuf.js v6.5.0 (c) 2016, Daniel Wirtz
* Compiled Tue, 17 Jan 2017 04:07:33 UTC
* Compiled Tue, 17 Jan 2017 04:40:35 UTC
* Licensed under the BSD-3-Clause License
* see: https://github.com/dcodeIO/protobuf.js for details
*/
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
!function(global,undefined){"use strict";(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";
/**
@ -315,7 +315,7 @@ utf8.write = function utf8_write(string, buffer, offset) {
// This file exports just the bare minimum required to work with statically generated code.
// Can be used as a drop-in replacement for the full library as it has the same general structure.
"use strict";
var protobuf = exports;
var protobuf = global.protobuf = exports;
protobuf.Writer = require(10);
protobuf.BufferWriter = require(11);
@ -329,13 +329,6 @@ function configure() {
protobuf.Reader._configure();
}
if (typeof window !== "undefined" && window)
window.protobuf = protobuf;
else if (typeof self !== "undefined" && self)
self.protobuf = protobuf;
else
this.protobuf = protobuf; // eslint-disable-line no-invalid-this
if (typeof define === "function" && define.amd)
define(["long"], function(Long) {
if (Long) {
@ -1137,7 +1130,7 @@ util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next *
* @memberof util
* @type {boolean}
*/
util.isNode = typeof process !== "undefined" && Boolean(process.versions && process.versions.node);
util.isNode = Boolean(global.process && global.process.versions && global.process.versions.node);
/**
* Tests if the specified value is an integer.
@ -1225,7 +1218,7 @@ util.LongBits = require(8);
* Long.js's Long class if available.
* @type {?function(new: Long)}
*/
util.Long = typeof dcodeIO !== "undefined" && /* istanbul ignore next */ dcodeIO && /* istanbul ignore next */ dcodeIO.Long || util.inquire("long");
util.Long = /* istanbul ignore next */ global.dcodeIO && /* istanbul ignore next */ global.dcodeIO.Long || util.inquire("long");
/**
* Converts a number or long to an 8 characters long hash string.
@ -1980,5 +1973,5 @@ BufferWriterPrototype.string = function write_string_buffer(value) {
},{"10":10,"9":9}]},{},[5])
}(typeof window==="object"&&window||typeof self==="object"&&self||this);
//# sourceMappingURL=protobuf.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -61,6 +61,7 @@
"@types/node": "7.0.0",
"benchmark": "^2.1.3",
"browserify": "^13.3.0",
"browserify-wrap": "^1.0.2",
"bundle-collapser": "^1.2.1",
"chalk": "^1.1.3",
"escodegen": "^1.8.1",

View File

@ -1,7 +1,7 @@
// This file exports just the bare minimum required to work with statically generated code.
// Can be used as a drop-in replacement for the full library as it has the same general structure.
"use strict";
var protobuf = exports;
var protobuf = global.protobuf = exports;
protobuf.Writer = require("../src/writer");
protobuf.BufferWriter = require("../src/writer_buffer");
@ -15,13 +15,6 @@ function configure() {
protobuf.Reader._configure();
}
if (typeof window !== "undefined" && window)
window.protobuf = protobuf;
else if (typeof self !== "undefined" && self)
self.protobuf = protobuf;
else
this.protobuf = protobuf; // eslint-disable-line no-invalid-this
if (typeof define === "function" && define.amd)
define(["long"], function(Long) {
if (Long) {

View File

@ -43,6 +43,12 @@ function bundle(options) {
if (options.exclude)
options.exclude.forEach(bundler.exclude, bundler);
return bundler
.plugin(require("browserify-wrap"), {
// + global object for convenience
// + undefined var and global strict-mode for uglify
prefix: "!function(global,undefined){\"use strict\";",
suffix: "}(typeof window===\"object\"&&window||typeof self===\"object\"&&self||this);"
})
.plugin(require("bundle-collapser/plugin"))
.bundle()
.pipe(source(options.compress ? "protobuf.min.js" : "protobuf.js"))
@ -53,6 +59,10 @@ function bundle(options) {
mangleProperties: {
regex: /^_/
},
mangle: {
eval: true,
toplevel: false
},
compress: {
unused: true,
keep_fargs: false,

View File

@ -1,5 +1,5 @@
"use strict";
var protobuf = exports;
var protobuf = global.protobuf = exports;
/**
* A node-style callback as used by {@link load} and {@link Root#load}.
@ -127,14 +127,6 @@ function configure() {
protobuf.Reader._configure();
}
/* istanbul ignore next */
if (typeof window !== "undefined" && window)
window.protobuf = protobuf;
else if (typeof self !== "undefined" && self)
self.protobuf = protobuf;
else
this.protobuf = protobuf; // eslint-disable-line no-invalid-this
/* istanbul ignore next */
if (typeof define === "function" && define.amd)
define(["long"], function(Long) {

View File

@ -24,7 +24,7 @@ util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next *
* @memberof util
* @type {boolean}
*/
util.isNode = typeof process !== "undefined" && Boolean(process.versions && process.versions.node);
util.isNode = Boolean(global.process && global.process.versions && global.process.versions.node);
/**
* Tests if the specified value is an integer.
@ -112,7 +112,7 @@ util.LongBits = require("./longbits");
* Long.js's Long class if available.
* @type {?function(new: Long)}
*/
util.Long = typeof dcodeIO !== "undefined" && /* istanbul ignore next */ dcodeIO && /* istanbul ignore next */ dcodeIO.Long || util.inquire("long");
util.Long = /* istanbul ignore next */ global.dcodeIO && /* istanbul ignore next */ global.dcodeIO.Long || util.inquire("long");
/**
* Converts a number or long to an 8 characters long hash string.