From bceefc7197678ce99752be00dee76d3c93de2c5f Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Sun, 22 Jul 2018 21:07:50 -0400 Subject: [PATCH] Better browserify for English wordlist. --- gulpfile.js | 13 +++++-------- src.ts/shims/index.ts | 1 + src.ts/shims/wordlists.ts | 8 ++++++++ 3 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 src.ts/shims/wordlists.ts diff --git a/gulpfile.js b/gulpfile.js index 5fadb3730..735f37740 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -31,14 +31,13 @@ var empty = "module.exports = {};"; // We already have a random Uint8Array browser/node safe source // @TODO: Use path construction instead of ../.. -var brorand = "var randomBytes = require('../../src.ts/utils').randomBytes; module.exports = function(length) { return randomBytes(length); };"; +var brorand = "var randomBytes = require('../../utils').randomBytes; module.exports = function(length) { return randomBytes(length); };"; // setImmediate is installed globally by our src.browser/shims.ts, loaded from src.ts/index.ts -var process = "module.exports = { };"; +var process = "module.exports = { browser: true };"; var timers = "module.exports = { setImmediate: global.setImmediate }; "; var transforms = { -// 'ethers.js/package.json': JSON.stringify({ version: version }), // Remove the precomputed secp256k1 points "elliptic/lib/elliptic/precomputed/secp256k1.js": undef, @@ -64,8 +63,6 @@ var transforms = { "process/browser.js": process, "timers-browserify/main.js": timers, - // Browser doesn't automatically get wordlists (individual files avaialble) - "src.ts/wordlists/index.ts": "module.exports = { en: require('./lang-en').langEn }", }; function transformFile(path) { @@ -178,13 +175,13 @@ function taskBundle(name, options) { var result = browserify({ basedir: '.', debug: false, - entries: [ './src.ts/' ], - cache: {}, + entries: [ './index.js' ], + cache: { }, packageCache: {}, standalone: "ethers", transform: [ [ transform, { global: true } ] ], }) - .plugin(tsify) +// .plugin(tsify) .bundle() .pipe(source(options.filename)) diff --git a/src.ts/shims/index.ts b/src.ts/shims/index.ts index f10f32c6d..53ad7e650 100644 --- a/src.ts/shims/index.ts +++ b/src.ts/shims/index.ts @@ -9,4 +9,5 @@ import { } from './hmac'; import { } from './pbkdf2'; import { } from './random-bytes'; import { } from './shims'; +import { } from './wordlists'; import { } from './xmlhttprequest'; diff --git a/src.ts/shims/wordlists.ts b/src.ts/shims/wordlists.ts new file mode 100644 index 000000000..055d7949c --- /dev/null +++ b/src.ts/shims/wordlists.ts @@ -0,0 +1,8 @@ + +import { Wordlist } from '../wordlists/wordlist'; + +import { langEn as _en } from '../wordlists/lang-en'; + +const en: Wordlist = _en; + +export { en }