Skip to content

Commit 4eac28c

Browse files
committed
Use protobuf/minimal when pbjs target is static-module
1 parent bb9f1fc commit 4eac28c

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

cli/pbjs.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ exports.main = function main(args, callback) {
3333
"force-long": "strict-long",
3434
"force-message": "strict-message"
3535
},
36-
string: [ "target", "out", "path", "wrap", "root", "lint" ],
36+
string: [ "target", "out", "path", "wrap", "dependency", "root", "lint" ],
3737
boolean: [ "create", "encode", "decode", "verify", "convert", "delimited", "beautify", "comments", "es6", "sparse", "keep-case", "force-long", "force-number", "force-enum-string", "force-message" ],
3838
default: {
3939
target: "json",
@@ -101,6 +101,8 @@ exports.main = function main(args, callback) {
101101
" es6 ES6 wrapper (implies --es6)",
102102
" closure Just a closure adding to protobuf.roots (see -r)",
103103
"",
104+
" --dependency Specifies which version of protobuf to require. Accepts any valid module id",
105+
"",
104106
" -r, --root Specifies an alternative protobuf.roots name.",
105107
"",
106108
" -l, --lint Linter configuration. Defaults to protobuf.js-compatible rules:",

cli/targets/json-module.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module.exports = json_module;
33

44
var util = require("../util");
55

6+
var protobuf = require("../..");
7+
68
json_module.description = "JSON representation as a module";
79

810
function json_module(root, options, callback) {
@@ -17,7 +19,7 @@ function json_module(root, options, callback) {
1719
}
1820
var json = util.jsonSafeProp(JSON.stringify(root.nested, null, 2).trim());
1921
output.push(".addJSON(" + json + ");");
20-
output = util.wrap(output.join(""), options);
22+
output = util.wrap(output.join(""), protobuf.util.merge({ dependency: "protobufjs/minimal" }, options));
2123
process.nextTick(function() {
2224
callback(null, output);
2325
});

cli/wrappers/amd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
define(["protobuf"], function($protobuf) {
1+
define([$DEPENDENCY], function($protobuf) {
22
"use strict";
33

44
$OUTPUT;

cli/wrappers/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(function(global, factory) { /* global define, require, module */
22

33
/* AMD */ if (typeof define === 'function' && define.amd)
4-
define(["protobuf"], factory);
4+
define([$DEPENDENCY], factory);
55

66
/* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports)
77
module.exports = factory(require($DEPENDENCY));

cli/wrappers/es6.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as $protobuf from "protobufjs";
1+
import * as $protobuf from $DEPENDENCY;
22

33
$OUTPUT;
44

0 commit comments

Comments
 (0)