From 88ca8f0d1eb334646ca2625c78e63fdd57221408 Mon Sep 17 00:00:00 2001 From: dcodeIO Date: Wed, 22 Mar 2017 18:29:33 +0100 Subject: [PATCH] Other: Retain alias order in static code for what it's worth, see #712 --- cli/targets/static.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cli/targets/static.js b/cli/targets/static.js index 17ecc6ac7..27dbc0e03 100644 --- a/cli/targets/static.js +++ b/cli/targets/static.js @@ -24,15 +24,18 @@ static_target.description = "Static code without reflection (non-functional on i function static_target(root, options, callback) { config = options; try { - if (config.comments) - push("// Common aliases"); - var aliases = ["util"]; - if (config.encode) - aliases.push("Writer"); + var aliases = []; if (config.decode) aliases.push("Reader"); - push((config.es6 ? "const " : "var ") + aliases.map(function(name) { return "$" + name + " = $protobuf." + name; }).join(", ")); - push(""); + if (config.encode) + aliases.push("Writer"); + aliases.push("util"); + if (aliases.length) { + if (config.comments) + push("// Common aliases"); + push((config.es6 ? "const " : "var ") + aliases.map(function(name) { return "$" + name + " = $protobuf." + name; }).join(", ") + ";"); + push(""); + } if (config.comments) push("// Lazily resolved type references"); push((config.es6 ? "const" : "var") + " $lazyTypes = [];");