Skip to content

Commit 996b3fa

Browse files
committed
Fix static codegen issues with uglifyjs3; New: Explicitly define service method names when generating static code, see #857
1 parent b611875 commit 996b3fa

File tree

15 files changed

+54
-56
lines changed

15 files changed

+54
-56
lines changed

cli/targets/static.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,9 @@ var shortVars = {
172172
function beautifyCode(code) {
173173
// Add semicolons
174174
code = UglifyJS.minify(code, {
175-
fromString: true,
176175
compress: false,
177176
mangle: false,
178-
output: {
179-
beautify: true
180-
}
177+
output: { beautify: true }
181178
}).code;
182179
// Properly beautify
183180
var ast = espree.parse(code);
@@ -653,11 +650,11 @@ function buildService(ref, service) {
653650
"@returns {undefined}",
654651
"@variation 1"
655652
]);
656-
push(escapeName(service.name) + ".prototype" + util.safeProp(lcName) + " = function " + escapeName(lcName) + "(request, callback) {");
653+
push("Object.defineProperty(" + escapeName(service.name) + ".prototype" + util.safeProp(lcName) + " = function " + escapeName(lcName) + "(request, callback) {");
657654
++indent;
658655
push("return this.rpcCall(" + escapeName(lcName) + ", $root." + exportName(method.resolvedRequestType) + ", $root." + exportName(method.resolvedResponseType) + ", request, callback);");
659656
--indent;
660-
push("};");
657+
push("}, \"name\", { value: " + JSON.stringify(method.name) + " });");
661658
if (config.comments)
662659
push("");
663660
pushComment([

dist/light/protobuf.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/light/protobuf.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/minimal/protobuf.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/minimal/protobuf.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

google/protobuf/field_mask.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

google/protobuf/field_mask.proto

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/gencommons.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ var pbjs = require("../cli/pbjs");
44
[
55
"google/protobuf/api.proto",
66
"google/protobuf/descriptor.proto",
7-
"google/protobuf/field_mask.proto",
87
"google/protobuf/source_context.proto",
98
"google/protobuf/type.proto",
109

0 commit comments

Comments
 (0)