js codegen does not produce helper functions for Any when using closure imports
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript
- Área
- compilers
Línea de trabajo
Comienza en src/google/protobuf/compiler/js/js_generator.cc, especialmente en la lógica referenciada de GenerateFile y output-mode, y compara closure-generated any.js con commonjs any_pb.js de la reproducción. La tarea estará terminada cuando la salida con estilo Closure incluya los helpers esperados de pack/unpack de Any sin introducir regresiones en la salida commonjs.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What version of protobuf and what language are you using?
Version: v3.6.1 (binary downloaded from official releases)
Language: Javascript, when closure styled imports
What operating system (Linux, Windows, ...) and version?
Linux x86_64
What runtime / compiler are you using (e.g., python version or gcc version)
NA
What did you do?
Steps to reproduce the behavior:
root@ec834298ad98:/github/grpc-web-base/third_party/grpc/third_party/protobuf# mkdir -p /tmp/proto_out/closure /tmp/proto_out/commonjs
root@ec834298ad98:/github/grpc-web-base/third_party/grpc/third_party/protobuf# /tmp/bin/protoc -I /github/grpc-web-base/third_party/grpc/third_party/protobuf --js_out=import_style=closure,binary:/tmp/proto_out/closure google/protobuf/any.proto
root@ec834298ad98:/github/grpc-web-base/third_party/grpc/third_party/protobuf# /tmp/bin/protoc -I /github/grpc-web-base/third_party/grpc/third_party/protobuf --js_out=import_style=commonjs,binary:/tmp/proto_out/commonjs/ google/protobuf/any.proto
root@ec834298ad98:/github/grpc-web-base/third_party/grpc/third_party/protobuf# find /tmp/proto_out/ -type f
/tmp/proto_out/commonjs/google/protobuf/any_pb.js
/tmp/proto_out/closure/any.js
root@ec834298ad98:/github/grpc-web-base/third_party/grpc/third_party/protobuf# grep -rHin -C 5 unpack /tmp/proto_out/
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-240-};
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-241-
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-242-
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-243-/**
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-244- * @template T
/tmp/proto_out/commonjs/google/protobuf/any_pb.js:245: * Unpacks this Any into the given message object.
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-246- * @param {function(Uint8Array):T} deserialize Function that will deserialize
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-247- * the binary data properly.
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-248- * @param {string} name The expected type name of this message object.
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-249- * @return {?T} If the name matched the expected name, returns the deserialized
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-250- * object, otherwise returns null.
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-251- */
/tmp/proto_out/commonjs/google/protobuf/any_pb.js:252:proto.google.protobuf.Any.prototype.unpack = function(deserialize, name) {
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-253- if (this.getTypeName() == name) {
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-254- return deserialize(this.getValue_asU8());
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-255- } else {
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-256- return null;
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-257- }
What did you expect to see
I expect to see pack/unpack functions for closure import code output
What did you see instead?
I do not see pack/unpack. However, when I use commonjs outputs, I see pack/unpack as demonstrated in the repro steps.
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
Anything else we should know about your project / environment
@TeBoring had some investigation into the root cause:
https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/js/js_generator.cc#L3682
This line is only called in GenerateFile.
https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/js/js_generator.cc#L3515
When you specify closure style, options.output_mode() == GeneratorOptions::kOneOutputFilePerType, and GenerateFile is not called.
- Lenguaje dominante
- JavaScript
- Estrellas
- 471
- Forks
- 91
- Merge medio
- 3 h 57 min
- PR fusionados (30 d)
- 2
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de protocolbuffers/protobuf-javascript
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
protocolbuffers/protobuf-javascript#248 · 1 comentario · 13 reacciones ·
-
question
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
protocolbuffers/protobuf-javascript#222 · 9 comentarios ·
-
Why map.js sort keys? Abiertoenhancement port-fix triaged
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
protocolbuffers/protobuf-javascript#185 · 1 comentario ·
-
enhancement port-fix triaged
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
protocolbuffers/protobuf-javascript#182 · 3 comentarios · 1 reacción ·
Todos los issues de protocolbuffers/protobuf-javascript
Issues similares
-
bot:ai-assisted component:compact-js status:untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
midnightntwrk/midnight-sdk#403 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 86/100
DavidAnson/markdownlint-cli2#940 ·
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
githubnext/gh-aw-workshop#3692 ·
-
agent/guide documentation hive/hosted-available-lke648397-260827-5n31
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100