This required that one function becomes async, which required some minor tweaks.
For testing... I realized it's not possible to test this in the dev version because wrtc is needed in node_modules in order for the typescript compiler to create the dist. So instead I built it (yarn build), manually removed wrtc from node_modules, and then ran the built version using node dist/index.js start .... This seemed to work -- i.e., it reported that it was not able to load wrtc, and carried on anyway. Great!
In doing the above, I discovered there was a packaging issue introduced in some of the recent changes. Server.ts now loads data from the ../../package.json file, but that wasn't getting copied to dist/ folder. So I updated the build command in package.json to copy that file over.
Finally, for the case of remote access with wrtc not loading, I modified Server.ts to print webrtc=0 in the output URL if it detected that wrtc could not be imported.
To address #50
Makes wrtc package an optional dependency (optionalDependencies in package.json) See: https://docs.npmjs.com/cli/v9/configuring-npm/package-json#optionaldependencies
Of course then at run time we'll need to detect whether we can import wrtc.
In order to do this, I needed to use the dynamic async import mechanism See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import
This required that one function becomes async, which required some minor tweaks.
For testing... I realized it's not possible to test this in the dev version because wrtc is needed in node_modules in order for the typescript compiler to create the dist. So instead I built it (yarn build), manually removed wrtc from node_modules, and then ran the built version using
node dist/index.js start ...
. This seemed to work -- i.e., it reported that it was not able to load wrtc, and carried on anyway. Great!In doing the above, I discovered there was a packaging issue introduced in some of the recent changes. Server.ts now loads data from the ../../package.json file, but that wasn't getting copied to dist/ folder. So I updated the build command in package.json to copy that file over.
Finally, for the case of remote access with wrtc not loading, I modified Server.ts to print webrtc=0 in the output URL if it detected that wrtc could not be imported.