Skip to content

Commit

Permalink
Fixes for dist builds without injected XMLHttpRequest (ethers-io#789, e…
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Apr 18, 2020
1 parent 3f2c012 commit c04bc9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Richard Moore <me@ricmoo.com>",
"browser": {
"./ipc-provider": "./lib/browser-ipc-provider.js",
"./lib/ipc-provider": "./lib/browser-ipc-provider.js",
"net": "./lib/browser-net.js",
"ws": "./lib/browser-ws.js"
},
Expand Down
7 changes: 5 additions & 2 deletions src.ts/browser-ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import { Logger } from "@ethersproject/logger";
import { version } from "./_version";

let WS = (WebSocket as any);
let WS: any = null;

if (WS == null) {
try {
WS = (WebSocket as any);
if (WS == null) { throw new Error("inject please"); }
} catch (error) {
const logger = new Logger(version);
WS = function() {
logger.throwError("WebSockets not supported in this environment", Logger.errors.UNSUPPORTED_OPERATION, {
Expand Down

0 comments on commit c04bc9f

Please sign in to comment.