Skip to content

Commit

Permalink
Other: Determine necessary aliases depending on config, see #712
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Mar 22, 2017
1 parent 3ad28ec commit 47bb95a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cli/targets/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ function static_target(root, options, callback) {
try {
if (config.comments)
push("// Common aliases");
push((config.es6 ? "const" : "var") + " $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;");
var aliases = ["util"];
if (config.encode)
aliases.push("Writer");
if (config.decode)
aliases.push("Reader");
push((config.es6 ? "const " : "var ") + aliases.map(function(name) { return "$" + name + " = $protobuf." + name; }).join(", "));
push("");
if (config.comments)
push("// Lazily resolved type references");
Expand Down

0 comments on commit 47bb95a

Please sign in to comment.