-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds "from_object" parameter that adds fromObject() signatures #136
base: master
Are you sure you want to change the base?
Conversation
- Plugin parameter can be comma-separated - If parameter list contains "from_object", the generator adds a static fromObject() method to each message. Currently, fromObject is only added by protoc-gen-js if you custom-build it (see protocolbuffers/protobuf-javascript#162 for an example patch).
Thanks a lot for your pr, let me have a look :) |
Hi @nicksieger , I've made some investigation. Just like what you said, seems the release version has no such feature for now. I tested the latest version with
Seems no I'd like to test and apply your pr when it's officially released. |
Sure, here's a Dockerfile snippet, or you can run these commands manually on Debian or Ubuntu. FROM node:18-bookworm
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /root
RUN apt update && apt install -y bazel-bootstrap protobuf-compiler && rm -rf /var/lib/apt/lists/*
RUN curl -sL https://github.com/protocolbuffers/protobuf-javascript/archive/refs/tags/v3.21.2.tar.gz | tar zxf -
# Apply patch to enable 'fromClass' generation from https://github.com/protocolbuffers/protobuf-javascript/pull/162
RUN cd protobuf-javascript-3.21.2 && \
curl -sL https://github.com/protocolbuffers/protobuf-javascript/commit/a3c4522bbdab5784de0361049437242980df07d0.diff | patch -u -p1 && \
bazel build :plugin_files && cp bazel-bin/generator/protoc-gen-js /usr/local/bin |
FYI, I'm using regular protoc \
--plugin=protoc-gen-js="$(which protoc-gen-js)" \
--js_out=import_style=commonjs,binary:./protos \
--plugin=protoc-gen-grpc="$(which grpc_tools_node_protoc_plugin)" \
--grpc_out=grpc_js:./protos \
--plugin=protoc-gen-ts="$(which protoc-gen-ts)" \
--ts_out=grpc_js,from_object:./protos \
my-service.proto |
I have 2 questions:
|
|
method to each message.
Currently, fromObject is only added by protoc-gen-js if you custom-build it (see
protocolbuffers/protobuf-javascript#162 for an example patch).