From 47bb95a31784b935b9ced52aa773b9d66236105e Mon Sep 17 00:00:00 2001 From: dcodeIO Date: Wed, 22 Mar 2017 16:28:08 +0100 Subject: [PATCH] Other: Determine necessary aliases depending on config, see #712 --- cli/targets/static.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli/targets/static.js b/cli/targets/static.js index aa6949fa3..17ecc6ac7 100644 --- a/cli/targets/static.js +++ b/cli/targets/static.js @@ -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");