Skip to content

Vite is not working with grpc-web generated code. #8926

Answered by sapphi-red
gyang274 asked this question in Q&A
Discussion options

You must be logged in to vote

Converted to discussion as it is not a bug.


Re Solution 1, @originjs/vite-plugin-commonjs says it only applies to dependencies. In this case generated protoc files are not a dependency.
https://github.com/originjs/vite-plugins/tree/main/packages/vite-plugin-commonjs
You could create package.json and some other files and use npm i -D ./src/proto to make it a dependency.


Re Solution 2, the error is coming from Vue. Vue uses JSON.stringify to stringify objects. client variable has a circular reference and so it fails to stringified. Just simply replace {{ client }} into {{ '' + client }} to fix the error.

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@gyang274
Comment options

@martinpokorny
Comment options

@adlion
Comment options

@boldt
Comment options

Answer selected by gyang274
Comment options

You must be logged in to vote
1 reply
@Shegl
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
8 participants
Converted from issue

This discussion was converted from issue #8922 on July 05, 2022 08:34.