From 4eac28c7d3acefb0af7b82c62cf8d19bf3e7d37b Mon Sep 17 00:00:00 2001 From: Vitalii Ishchenko Date: Tue, 30 May 2017 13:37:36 +0300 Subject: [PATCH] Use protobuf/minimal when pbjs target is static-module --- cli/pbjs.js | 4 +++- cli/targets/json-module.js | 4 +++- cli/wrappers/amd.js | 2 +- cli/wrappers/default.js | 2 +- cli/wrappers/es6.js | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cli/pbjs.js b/cli/pbjs.js index 1ab84af5a..83025a859 100644 --- a/cli/pbjs.js +++ b/cli/pbjs.js @@ -33,7 +33,7 @@ exports.main = function main(args, callback) { "force-long": "strict-long", "force-message": "strict-message" }, - string: [ "target", "out", "path", "wrap", "root", "lint" ], + string: [ "target", "out", "path", "wrap", "dependency", "root", "lint" ], boolean: [ "create", "encode", "decode", "verify", "convert", "delimited", "beautify", "comments", "es6", "sparse", "keep-case", "force-long", "force-number", "force-enum-string", "force-message" ], default: { target: "json", @@ -101,6 +101,8 @@ exports.main = function main(args, callback) { " es6 ES6 wrapper (implies --es6)", " closure Just a closure adding to protobuf.roots (see -r)", "", + " --dependency Specifies which version of protobuf to require. Accepts any valid module id", + "", " -r, --root Specifies an alternative protobuf.roots name.", "", " -l, --lint Linter configuration. Defaults to protobuf.js-compatible rules:", diff --git a/cli/targets/json-module.js b/cli/targets/json-module.js index 388e56a3a..cf67d5c49 100644 --- a/cli/targets/json-module.js +++ b/cli/targets/json-module.js @@ -3,6 +3,8 @@ module.exports = json_module; var util = require("../util"); +var protobuf = require("../.."); + json_module.description = "JSON representation as a module"; function json_module(root, options, callback) { @@ -17,7 +19,7 @@ function json_module(root, options, callback) { } var json = util.jsonSafeProp(JSON.stringify(root.nested, null, 2).trim()); output.push(".addJSON(" + json + ");"); - output = util.wrap(output.join(""), options); + output = util.wrap(output.join(""), protobuf.util.merge({ dependency: "protobufjs/minimal" }, options)); process.nextTick(function() { callback(null, output); }); diff --git a/cli/wrappers/amd.js b/cli/wrappers/amd.js index 8f65b5e5a..c43dd73c3 100644 --- a/cli/wrappers/amd.js +++ b/cli/wrappers/amd.js @@ -1,4 +1,4 @@ -define(["protobuf"], function($protobuf) { +define([$DEPENDENCY], function($protobuf) { "use strict"; $OUTPUT; diff --git a/cli/wrappers/default.js b/cli/wrappers/default.js index 748c27a97..34b29ec7c 100644 --- a/cli/wrappers/default.js +++ b/cli/wrappers/default.js @@ -1,7 +1,7 @@ (function(global, factory) { /* global define, require, module */ /* AMD */ if (typeof define === 'function' && define.amd) - define(["protobuf"], factory); + define([$DEPENDENCY], factory); /* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports) module.exports = factory(require($DEPENDENCY)); diff --git a/cli/wrappers/es6.js b/cli/wrappers/es6.js index adafb7ee9..5bdc43c6d 100644 --- a/cli/wrappers/es6.js +++ b/cli/wrappers/es6.js @@ -1,4 +1,4 @@ -import * as $protobuf from "protobufjs"; +import * as $protobuf from $DEPENDENCY; $OUTPUT;