Flow JS SDK in Angular Framework
See original GitHub issueBased on the Flow App Quickstart ( https://docs.onflow.org/flow-js-sdk/flow-app-quickstart ), I am looking to rebuild the example using the flow-js-sdk with the Angular Framework.
However, the flow-js-sdk has a dependent library “@improbable-eng/grpc-web” which is using the http and https modules. Those modules cannot be used in the Angular web framework since version 6.
I am getting the following errors when running “ng serve”:
Error: ./node_modules/@improbable-eng/grpc-web-node-http-transport/lib/index.js Module not found: Error: Can't resolve 'http' in '...\node_modules\@improbable-eng\grpc-web-node-http-transport\lib'
Error: ./node_modules/@improbable-eng/grpc-web-node-http-transport/lib/index.js Module not found: Error: Can't resolve 'https' in '...\node_modules\@improbable-eng\grpc-web-node-http-transport\lib'
In the open issue https://github.com/onflow/flow-js-sdk/issues/271 it was suggested that it is planned to “remov[e] gRPC completely from the JS-SDK, and will instead be using standard http requests”.
Any timeline on that change? Or any suggested workarounds for the time being?
Issue Analytics
- State:
 - Created 3 years ago
 - Reactions:5
 - Comments:5 (4 by maintainers)
 

Top Related StackOverflow Question
Adding this to
package.jsonwould hide the issue (but not solve it):What is blocking here - at least in my limited understanding - is that
ngccwhich is the Angular Compiler tries to compile@improbable-engpackage wherehttpandhttpsmodules are used. It tries to compile those because somefclmethods likefcl.sendultimately use GRPC which is used in@improbable-eng. Therefor, it tries to compile the package for the browser which should not be the case I believe.Adding the snippet in
package.jsontells the compiler to exclude these modules from compiling according to this. However it will obviously leads to a fail while attempting to usefclfor a http call:ERROR Error: Uncaught (in promise): TypeError: https.request is not a functionwhich refers to this file:webpack:///./node_modules/@improbable-eng/grpc-web-node-http-transport/lib/index.js.In my opinion, going for a full JSON communication medium is the solution as mention here #321. Especially if it’s solve the issue for other framework like React Native.
That being said, they are other issues with Angular, I encountered some, but they are probably more:
Error: Uncaught (in promise): ReferenceError: Buffer is not definedwhen using afclmethod that usesBuffer(in my case it wassend). I don’t know much about it, but a workaround exists by adding this topolyfill.ts:ng serve --port=3000but we should obviously rather add the port 4200 to the allowed domain.Going to close this in favour of: https://github.com/onflow/flow-js-sdk/issues/679