Skip to content
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

using grpc with webpack? #11435

Closed
slootzky opened this issue Jun 8, 2017 · 12 comments
Closed

using grpc with webpack? #11435

slootzky opened this issue Jun 8, 2017 · 12 comments
Assignees

Comments

@slootzky
Copy link

slootzky commented Jun 8, 2017

Hey ,
using google's pubsub node client and it depends on grp which depends on node-pre-gyp.
when using webpack (for serverless functions) I get the following runtime error :

package.json does not exist at...

this comes from pre-bindings.js :
if (!existsSync(package_json_path)) { throw new Error("package.json does not exist at " + package_json_path); }

and this because in grpc_extensions.js is using __dirname and then relative path :

var binding_path = binary.find(path.resolve(path.join(__dirname, '../../../package.json')));

@murgatroid99 murgatroid99 self-assigned this Jun 8, 2017
@murgatroid99
Copy link
Member

There's a bigger problem with using webpack: gRPC uses a Node C++ addon that interfaces with low-level Node C APIs. It's not going to work except on Node.

@wenbozhu
Copy link
Member

wenbozhu commented Jun 9, 2017

@slootzky We haven't yet released grpc-web which uses a different stack than grpc (due to browser limitation). Once grpc-web is available, we should consider making it deployable in Node (webpack etc).

If you need early access to grpc-web, let me know.

@slootzky
Copy link
Author

seems like it's also doesn't work on a nodejs Azure function

@wenbozhu
Copy link
Member

wenbozhu commented Jun 11, 2017

This is a separate issue, i.e. making grpc calls from Azure functions. We should verify.

@murgatroid99
Copy link
Member

@slootzky Can you elaborate? What problems did you experience when you tried to use gRPC in a Node.js Azure function?

@slootzky
Copy link
Author

slootzky commented Jun 13, 2017

@murgatroid99 it's because azure functions runs over edgejs
I got the same behaviour as this SO question

@raviqqe
Copy link

raviqqe commented Jun 18, 2017

By the way, the code in grpc_extensions.js @slootzky specified should use something like require("PATH") so that bundlers and optimizers like webpack, rollup, and prepack can detect loading files in external directories. I believe that bundling and optimization of JS code are getting popular even on server-side nowadays.

@slootzky
Copy link
Author

slootzky commented Jun 18, 2017

@raviqqe totally agree , especially when things like prepack become more stable , I think runtime optimization is always more than welcome.
Think that there shouldn't be boundaries between pure node.js to bundlers like webpack / react-native packager etc.

@rogerbell82
Copy link

Totally Agree.
Webpack / React are so popular now.
Its disappointing that I cannot integrate Google Cloud modules such as Vision into my project.

@raviqqe
Copy link

raviqqe commented Jun 20, 2017

It seems to be impossible because of limitation of node-pre-gyp's API.

@bradennapier
Copy link

bradennapier commented Oct 23, 2017

this sucks....,. you broke my entire app with this bs... there is no way to use any google products with any serverless products now... how do i make these work? ??????????

i dont give two shits about anything but node but this does not work on node either so.... uhh... .yeah......

Error: package.json does not exist at /package.json
    at Object.t.find (/Users/bradennapier/Desktop/Dash OS/IDE/projects/dash-lambda-apex/nodejs/functions/util_firebase/lib/index.js:1451:10748)
    at Object.<anonymous> (/Users/bradennapier/Desktop/Dash OS/IDE/projects/dash-lambda-apex/nodejs/functions/util_firebase/lib/index.js:154:26)
    at Object.<anonymous> (/Users/bradennapier/Desktop/Dash OS/IDE/projects/dash-lambda-apex/nodejs/functions/util_firebase/lib/index.js:154:183)
    at t (/Users/bradennapier/Desktop/Dash OS/IDE/projects/dash-lambda-apex/nodejs/functions/util_firebase/lib/index.js:1:177)

why would you close something that is clearly still a bug

@ondrowan
Copy link

@bradennapier You can exclude node_modules from webpack config using webpack-node-externals plugin or by defining externals manually. That way you can keep using libraries that depend on grpc with serverless framework. Another option is to not use serverless framework and webpack. There are other options how to deploy applications to Lambda, Kubeless etc.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants