Deno - access web apis

374 Views Asked by At

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?

1

There are 1 best solutions below

0
David Callanan On BEST ANSWER

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.