David Callanan
David Callanan

Reputation: 5790

Deno - access web apis

I am bundling my Deno code for the web using deno bundle and I know the browser has RTCPeerConnection from the WebRTC API which I would like to use.

I thought Deno was aiming to have web compatibility, so I don't see why WebRTC is not planned to be implemented.

But since it isn't at the moment, how can I tell Deno to trust that this global variable exists and to compile?

Upvotes: 0

Views: 393

Answers (1)

David Callanan
David Callanan

Reputation: 5790

Using deno bundle will actually run fine for many web APIs that are supported by the Deno language.

My temporary solution for other apis such as crypto is the following:

declare crypto: any;

This article might be useful to look at too (see the 'Compiling and bundling' section).


EDIT: in order to support a wide variety of environments, dependency injection can be a great solution in many cases.

Upvotes: 1

Related Questions