Set up setImmediate for browsers.

This commit is contained in:
Richard Moore 2018-06-22 02:07:57 -04:00
parent dde33aa5a5
commit b2be7c807f
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295
4 changed files with 9 additions and 2 deletions

@ -33,7 +33,9 @@ var empty = "module.exports = {};";
// @TODO: Use path construction instead of ../..
var brorand = "var randomBytes = require('../../src.ts/utils').randomBytes; module.exports = function(length) { return randomBytes(length); };";
var process = "if (!global.setImmediate) { global.setImmedaite = setTimeout; };";
// setImmediate is installed globally by our src.browser/shims.ts, loaded from src.ts/index.ts
var process = "module.exports = { };";
var timers = "module.exports = { setImmediate: global.setImmediate }; ";
var transforms = {
// 'ethers.js/package.json': JSON.stringify({ version: version }),
@ -61,7 +63,7 @@ var transforms = {
// Used by sha3 if it exists; (so make it no exist)
// "process/.*": undef,
"process/browser.js": process,
"timers-browserify/main.js": empty,
"timers-browserify/main.js": timers,
};
function transformFile(path) {

1
src.browser/shims.ts Normal file

@ -0,0 +1 @@
require('setimmediate');

@ -1,5 +1,8 @@
'use strict';
// This is empty in node, and used by browserify to inject extra goodies
import './utils/shims';
import { Contract, Interface } from './contracts';
import * as providers from './providers';
import * as errors from './utils/errors';

1
src.ts/utils/shims.ts Normal file

@ -0,0 +1 @@
/* no shims for node */