[question] How to generate `require('@grpc/grpc-js')` instead of `require('grpc')`
See original GitHub issueI am not sure if this is the correct place to ask…
I would like to use @grpc/grpc-js
instead of grpc
in the generated JS code to overcome an issue inside a bundled electron application.
Is it possible to staticly generate the JS code with require('@grpc/grpc-js')
instead of require('grpc')
. My current approach is to generate it with require('grpc')
, then parse the generated files and replace the require
s in a manual step 😞 Is there a flag I can tweak to adjust the generator?
I was unable to find the solution, so I set up a bare minimum example, perhaps someone can advise.
Thank you!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:18 (12 by maintainers)
Top Results From Across the Web
@grpc/grpc-js - npm
If you are currently loading packages generated by grpc-tools , you should instead generate your files using the generate_package_definition ...
Read more >Quick start | C++ - gRPC
Build and locally install gRPC and Protocol Buffers. Setup; Install cmake; Install other required tools; Clone the grpc repo; Build and install ...
Read more >node.js - Can't install grpc npm-package - Stack Overflow
Please, make sure to install this library ($ npm install grpc) to take advantage of ServerGrpc. But with node 16, it works fine:...
Read more >What is gRPC? How to implement gRPC in Node.js - SPRKL
Each language serves a purpose, and they need to connect together. If we were to try using gRPC in a browser, it would...
Read more >The Weird World of gRPC Tooling for Node.js, Part 2 - Medium
You can create a gRPC server in Node.js with static code generation, ... is run using a Docker image, so you'll need Docker...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi,
Since I am passing by and seeing this issues, I managed to generate code that uses
require('@grpc/grpc-js')
by using--grpc_out=grpc_js:<path>
.I still need to test if it works properly.
@murgatroid99 @paambaati has there been any progress on this?
I modified
index.d.ts
locally to export the types I needed (e.g., ServiceDefinition, handleUnaryCall, etc.) and changedServiceDefinition
to haveMethodDefinition<any, any>
instead ofMethodDefinition<object, object>
and it seems to be working (albeit with modifications still needed to the generated code to do therequire('@grpc/grpc-js')
change among other things).I can try making a pull-request if there is still interest.