Permalink
Browse files

New: Now compresses .gz files using zopfli to make them useful beyond…

… being just a reference
  • Loading branch information...
dcodeIO committed Dec 21, 2016
1 parent aed134a commit bfee1cc3624d0fa21f9553c2f6ce2fcf7fcc09b7
@@ -16,7 +16,7 @@
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/ea7ba8b83890084d61012cb5386dc11dadfb3908) Fixed release links in README files<br />
## New
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/9078a37fbf7bff8ba829d979073e3df91f1bcfc5) Updated non-bundled common google types folder with field_mask, source_context, type and wrappers<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/aed134aa1cd7edd801de77c736cf5efe6fa61cb0) Updated non-bundled google types folder with missing descriptors and added wrappers to core<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/0b0de2458a1ade1ccd4ceb789697be13290f856b) Replaced the ieee754 implementation for old browsers with a faster, use-case specific one + simple test case<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/99ad9cc08721b834a197d4bbb67fa152d7ad79aa) Added .create to statically generated types and uppercase nested elements to reflection namespaces, see [#576](https://github.com/dcodeIO/protobuf.js/issues/576)<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/99ad9cc08721b834a197d4bbb67fa152d7ad79aa) Also added Namespace#getEnum for completeness, see [#576](https://github.com/dcodeIO/protobuf.js/issues/576)<br />

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN -610 Bytes (97%) dist/protobuf.min.js.gz
Binary file not shown.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN -100 Bytes (98%) dist/runtime/protobuf.min.js.gz
Binary file not shown.
@@ -1,5 +1,4 @@
var gulp = require("gulp"),
gzip = require('gulp-gzip');
var gulp = require("gulp");
var bundle = require("./scripts/bundle");
@@ -14,14 +13,18 @@ gulp.task("bundle-production" , bundle.bind(this, false, false));
gulp.task("bundle-development-runtime", bundle.bind(this, true , true));
gulp.task("bundle-production-runtime" , bundle.bind(this, false, true));
gulp.task("gzip-production", [ "bundle-production" ], function() {
return gulp.src('./dist/protobuf.min.js')
.pipe(gzip({ gzipOptions: { level: 9 } }))
.pipe(gulp.dest('./dist'));
gulp.task("gzip-production", [ "bundle-production" ], function(cb) {
bundle.compress(
"./dist/protobuf.min.js",
"./dist/protobuf.min.js.gz",
cb
);
});
gulp.task("gzip-production-runtime", [ "bundle-production-runtime" ], function() {
return gulp.src('./dist/runtime/protobuf.min.js')
.pipe(gzip({ gzipOptions: { level: 9 } }))
.pipe(gulp.dest('./dist/runtime'));
gulp.task("gzip-production-runtime", [ "bundle-production-runtime" ], function(cb) {
bundle.compress(
"./dist/runtime/protobuf.min.js",
"./dist/runtime/protobuf.min.js.gz",
cb
);
});
@@ -76,6 +76,7 @@
"jaguarjs-jsdoc": "dcodeIO/jaguarjs-jsdoc",
"jsdoc": "^3.4.2",
"minimist": "^1.2.0",
"node-zopfli": "^2.0.2",
"tap-spec": "^4.1.1",
"tape": "^4.6.3",
"typescript": "^2.1.4",
@@ -1,28 +1,28 @@
module.exports = bundle;
var path = require('path');
var path = require("path");
var browserify = require('browserify');
var browserify = require("browserify");
var header = require('gulp-header');
var gulpif = require('gulp-if');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var gutil = require('gulp-util');
var header = require("gulp-header");
var gulpif = require("gulp-if");
var sourcemaps = require("gulp-sourcemaps");
var uglify = require("gulp-uglify");
var gutil = require("gulp-util");
var buffer = require('vinyl-buffer');
var vinylfs = require('vinyl-fs');
var source = require('vinyl-source-stream');
var buffer = require("vinyl-buffer");
var vinylfs = require("vinyl-fs");
var source = require("vinyl-source-stream");
var pkg = require(__dirname + '/../package.json');
var pkg = require(__dirname + "/../package.json");
var license = [
"/*!",
" * protobuf.js v${version} (c) 2016, Daniel Wirtz",
" * Compiled ${date}",
" * Licensed under the BSD-3-Clause license",
" * Licensed under the BSD-3-Clause License",
" * see: https://github.com/dcodeIO/protobuf.js for details",
" */"
].join('\n') + '\n';
].join("\n") + "\n";
function bundle(compress, runtime) {
var src = runtime
@@ -40,9 +40,9 @@ function bundle(compress, runtime) {
.external("long")
.exclude("process")
.exclude("_process")
.plugin(require('bundle-collapser/plugin'))
.plugin(require("bundle-collapser/plugin"))
.bundle()
.pipe(source(compress ? 'protobuf.min.js' : 'protobuf.js'))
.pipe(source(compress ? "protobuf.min.js" : "protobuf.js"))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(
@@ -53,11 +53,25 @@ function bundle(compress, runtime) {
}))
)
.pipe(header(license, {
date: (new Date()).toUTCString().replace('GMT', 'UTC'),
date: (new Date()).toUTCString().replace("GMT", "UTC"),
version: pkg.version
}))
.pipe(sourcemaps.write('.', { sourceRoot: '' }))
.pipe(sourcemaps.write(".", { sourceRoot: "" }))
.pipe(vinylfs.dest(dst))
.on("log", gutil.log)
.on("error", gutil.log);
}
var fs = require("fs");
var zopfli = require("node-zopfli");
bundle.compress = function compress(sourceFile, destinationFile, callback) {
var src = fs.createReadStream(sourceFile);
var dst = fs.createWriteStream(destinationFile);
src.on("error", callback);
dst.on("error", callback);
dst.on("close", function() {
callback(null);
});
src.pipe(zopfli.createGzip()).pipe(dst);
};
@@ -1,5 +1,5 @@
// $> pbts --name protobufjs --out types/protobuf.js.d.ts src
// Generated Tue, 20 Dec 2016 21:38:11 UTC
// Generated Wed, 21 Dec 2016 00:40:53 UTC
declare module "protobufjs" {
/**
@@ -86,6 +86,7 @@ declare module "protobufjs" {
* @property {Object} google/protobuf/empty.proto Empty
* @property {Object} google/protobuf/struct.proto Struct, Value, NullValue and ListValue
* @property {Object} google/protobuf/timestamp.proto Timestamp
* @property {Object} google/protobuf/wrappers.proto Wrappers
*/
function common(name: string, json: Object): void;

0 comments on commit bfee1cc

Please sign in to comment.