Skip to content

Commit 47bb95a

Browse files
committed
Other: Determine necessary aliases depending on config, see #712
1 parent 3ad28ec commit 47bb95a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cli/targets/static.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ function static_target(root, options, callback) {
2626
try {
2727
if (config.comments)
2828
push("// Common aliases");
29-
push((config.es6 ? "const" : "var") + " $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;");
29+
var aliases = ["util"];
30+
if (config.encode)
31+
aliases.push("Writer");
32+
if (config.decode)
33+
aliases.push("Reader");
34+
push((config.es6 ? "const " : "var ") + aliases.map(function(name) { return "$" + name + " = $protobuf." + name; }).join(", "));
3035
push("");
3136
if (config.comments)
3237
push("// Lazily resolved type references");

0 commit comments

Comments
 (0)