diff options
author | Josh Haberman <jhaberman@gmail.com> | 2016-02-02 15:18:34 -0800 |
---|---|---|
committer | Josh Haberman <jhaberman@gmail.com> | 2016-02-18 10:30:21 -0800 |
commit | 55cc3aa987159bcdb491550d864115c1e8daeebb (patch) | |
tree | 0bd5a441d679ffa6b8b600a755c8284d79208b6c /js | |
parent | c40f8c1f54f028b1ca73f3fb2dfdde500f94918f (diff) | |
download | protobuf-55cc3aa987159bcdb491550d864115c1e8daeebb.tar.gz protobuf-55cc3aa987159bcdb491550d864115c1e8daeebb.tar.bz2 protobuf-55cc3aa987159bcdb491550d864115c1e8daeebb.zip |
WIP.
Diffstat (limited to 'js')
-rw-r--r-- | js/commonjs_export.js | 10 | ||||
-rw-r--r-- | js/gulpfile.js | 39 | ||||
-rw-r--r-- | js/jasmine_commonjs.json | 11 | ||||
-rw-r--r-- | js/package.json | 6 |
4 files changed, 59 insertions, 7 deletions
diff --git a/js/commonjs_export.js b/js/commonjs_export.js new file mode 100644 index 00000000..44e63296 --- /dev/null +++ b/js/commonjs_export.js @@ -0,0 +1,10 @@ +/** + * @fileoverview Export symbols needed by generated code in CommonJS style. + */ + +exports = { + Message: jspb.Message, + BinaryReader: jspb.BinaryReader, + BinaryWriter: jspb.BinaryWriter, + ExtensionFieldInfo: jspb.ExtensionFieldInfo, +}; diff --git a/js/gulpfile.js b/js/gulpfile.js index 79095d65..a548a826 100644 --- a/js/gulpfile.js +++ b/js/gulpfile.js @@ -1,25 +1,45 @@ var gulp = require('gulp'); var exec = require('child_process').exec; -gulp.task('genproto', function (cb) { +gulp.task('genproto_closure', function (cb) { exec('../src/protoc --js_out=library=testproto_libs,binary:. -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto', function (err, stdout, stderr) { console.log(stdout); console.log(stderr); cb(err); }); -}) +}); + +gulp.task('genproto_commonjs', function (cb) { + exec('mkdir -p commonjs_out && ../src/protoc --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto', + function (err, stdout, stderr) { + console.log(stdout); + console.log(stderr); + cb(err); + }); +}); -gulp.task('deps', ['genproto'], function (cb) { +gulp.task('dist', function (cb) { + // TODO(haberman): minify this more aggressively. + // Will require proper externs/exports. + exec('./node_modules/google-closure-library/closure/bin/calcdeps.py -i message.js -i binary/reader.js -i binary/writer.js -p . -p node_modules/google-closure-library/closure -o compiled --compiler_jar node_modules/google-closure-compiler/compiler.jar > google-protobuf.js', + function (err, stdout, stderr) { + console.log(stdout); + console.log(stderr); + cb(err); + }); +}); + +gulp.task('deps', ['genproto_closure'], function (cb) { exec('./node_modules/google-closure-library/closure/bin/build/depswriter.py *.js binary/*.js > deps.js', function (err, stdout, stderr) { console.log(stdout); console.log(stderr); cb(err); }); -}) +}); -gulp.task('test', ['genproto', 'deps'], function (cb) { +gulp.task('test_closure', ['genproto_closure', 'deps'], function (cb) { exec('JASMINE_CONFIG_PATH=jasmine.json ./node_modules/.bin/jasmine', function (err, stdout, stderr) { console.log(stdout); @@ -27,3 +47,12 @@ gulp.task('test', ['genproto', 'deps'], function (cb) { cb(err); }); }); + +gulp.task('test_commonjs', ['genproto_commonjs', 'dist'], function (cb) { + exec('JASMINE_CONFIG_PATH=jasmine.json cp jasmine_commonjs.json commonjs_out/jasmine.json && cd commonjs_out && ../node_modules/.bin/jasmine', + function (err, stdout, stderr) { + console.log(stdout); + console.log(stderr); + cb(err); + }); +}); diff --git a/js/jasmine_commonjs.json b/js/jasmine_commonjs.json new file mode 100644 index 00000000..05444550 --- /dev/null +++ b/js/jasmine_commonjs.json @@ -0,0 +1,11 @@ +{ + "spec_dir": "", + "spec_files": [ + "*_test.js" + ], + "helpers": [ + "node_modules/google-closure-library/closure/goog/bootstrap/nodejs.js", + "node_loader.js", + "deps.js" + ] +} diff --git a/js/package.json b/js/package.json index be93286f..8c8f434b 100644 --- a/js/package.json +++ b/js/package.json @@ -2,13 +2,15 @@ "name": "google-protobuf", "version": "3.0.0-alpha.5", "description": "Protocol Buffers for JavaScript", - "main": "debug.js", + "main": "google-protobuf.js", "dependencies": { "google-closure-library": "~20160125.0.0", "gulp": "~3.9.0", "jasmine": "~2.4.1" }, - "devDependencies": {}, + "devDependencies": { + "google-closure-compiler": "~20151216.2.0" + }, "scripts": { "test": "./node_modules/gulp/bin/gulp.js test" }, |