question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] How to generate `require('@grpc/grpc-js')` instead of `require('grpc')`

See original GitHub issue

I 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 requires 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:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:18 (12 by maintainers)

github_iconTop GitHub Comments

8reactions
Wamboucommented, May 25, 2020

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.

4reactions
mpminardicommented, Sep 30, 2019

@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 changed ServiceDefinition to have MethodDefinition<any, any> instead of MethodDefinition<object, object> and it seems to be working (albeit with modifications still needed to the generated code to do the require('@grpc/grpc-js') change among other things).

I can try making a pull-request if there is still interest.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found