From 24cd81a1bdcfa9271c697d8aa3ba88f07fe122d0 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 28 Jun 2017 12:45:38 -0700 Subject: [PATCH] webpack: use -browser convention instead of aliases. --- ...256k1-elliptic.js => secp256k1-browser.js} | 0 lib/crypto/secp256k1.js | 2 +- lib/http/base-browser.js | 2 + lib/http/client-browser.js | 2 + lib/http/request-browser.js | 2 + lib/http/rpcclient-browser.js | 2 + lib/http/server-browser.js | 2 + lib/http/wallet-browser.js | 2 + lib/native-browser.js | 1 + lib/net/socks-browser.js | 2 + lib/utils/fs-browser.js | 2 + lib/wallet/client-browser.js | 2 + lib/wallet/http-browser.js | 2 + lib/wallet/server-browser.js | 2 + lib/workers/cp-browser.js | 2 + lib/workers/cp.js | 3 ++ lib/workers/workerpool.js | 2 +- package.json | 39 ------------------- webpack.config.js | 2 +- 19 files changed, 31 insertions(+), 42 deletions(-) rename lib/crypto/{secp256k1-elliptic.js => secp256k1-browser.js} (100%) create mode 100644 lib/http/base-browser.js create mode 100644 lib/http/client-browser.js create mode 100644 lib/http/request-browser.js create mode 100644 lib/http/rpcclient-browser.js create mode 100644 lib/http/server-browser.js create mode 100644 lib/http/wallet-browser.js create mode 100644 lib/native-browser.js create mode 100644 lib/net/socks-browser.js create mode 100644 lib/utils/fs-browser.js create mode 100644 lib/wallet/client-browser.js create mode 100644 lib/wallet/http-browser.js create mode 100644 lib/wallet/server-browser.js create mode 100644 lib/workers/cp-browser.js create mode 100644 lib/workers/cp.js diff --git a/lib/crypto/secp256k1-elliptic.js b/lib/crypto/secp256k1-browser.js similarity index 100% rename from lib/crypto/secp256k1-elliptic.js rename to lib/crypto/secp256k1-browser.js diff --git a/lib/crypto/secp256k1.js b/lib/crypto/secp256k1.js index 04d113dc..4f14413b 100644 --- a/lib/crypto/secp256k1.js +++ b/lib/crypto/secp256k1.js @@ -18,4 +18,4 @@ if (+process.env.BCOIN_USE_ELLIPTIC !== 1) { module.exports = native ? require('./secp256k1-native') - : require('./secp256k1-elliptic'); + : require('./secp256k1-browser'); diff --git a/lib/http/base-browser.js b/lib/http/base-browser.js new file mode 100644 index 00000000..5df3feef --- /dev/null +++ b/lib/http/base-browser.js @@ -0,0 +1,2 @@ +// Empty module for browserify. +exports.unsupported = true; diff --git a/lib/http/client-browser.js b/lib/http/client-browser.js new file mode 100644 index 00000000..5df3feef --- /dev/null +++ b/lib/http/client-browser.js @@ -0,0 +1,2 @@ +// Empty module for browserify. +exports.unsupported = true; diff --git a/lib/http/request-browser.js b/lib/http/request-browser.js new file mode 100644 index 00000000..5df3feef --- /dev/null +++ b/lib/http/request-browser.js @@ -0,0 +1,2 @@ +// Empty module for browserify. +exports.unsupported = true; diff --git a/lib/http/rpcclient-browser.js b/lib/http/rpcclient-browser.js new file mode 100644 index 00000000..5df3feef --- /dev/null +++ b/lib/http/rpcclient-browser.js @@ -0,0 +1,2 @@ +// Empty module for browserify. +exports.unsupported = true; diff --git a/lib/http/server-browser.js b/lib/http/server-browser.js new file mode 100644 index 00000000..5df3feef --- /dev/null +++ b/lib/http/server-browser.js @@ -0,0 +1,2 @@ +// Empty module for browserify. +exports.unsupported = true; diff --git a/lib/http/wallet-browser.js b/lib/http/wallet-browser.js new file mode 100644 index 00000000..5df3feef --- /dev/null +++ b/lib/http/wallet-browser.js @@ -0,0 +1,2 @@ +// Empty module for browserify. +exports.unsupported = true; diff --git a/lib/native-browser.js b/lib/native-browser.js new file mode 100644 index 00000000..7b814419 --- /dev/null +++ b/lib/native-browser.js @@ -0,0 +1 @@ +exports.binding = null; diff --git a/lib/net/socks-browser.js b/lib/net/socks-browser.js new file mode 100644 index 00000000..5df3feef --- /dev/null +++ b/lib/net/socks-browser.js @@ -0,0 +1,2 @@ +// Empty module for browserify. +exports.unsupported = true; diff --git a/lib/utils/fs-browser.js b/lib/utils/fs-browser.js new file mode 100644 index 00000000..5df3feef --- /dev/null +++ b/lib/utils/fs-browser.js @@ -0,0 +1,2 @@ +// Empty module for browserify. +exports.unsupported = true; diff --git a/lib/wallet/client-browser.js b/lib/wallet/client-browser.js new file mode 100644 index 00000000..5df3feef --- /dev/null +++ b/lib/wallet/client-browser.js @@ -0,0 +1,2 @@ +// Empty module for browserify. +exports.unsupported = true; diff --git a/lib/wallet/http-browser.js b/lib/wallet/http-browser.js new file mode 100644 index 00000000..5df3feef --- /dev/null +++ b/lib/wallet/http-browser.js @@ -0,0 +1,2 @@ +// Empty module for browserify. +exports.unsupported = true; diff --git a/lib/wallet/server-browser.js b/lib/wallet/server-browser.js new file mode 100644 index 00000000..5df3feef --- /dev/null +++ b/lib/wallet/server-browser.js @@ -0,0 +1,2 @@ +// Empty module for browserify. +exports.unsupported = true; diff --git a/lib/workers/cp-browser.js b/lib/workers/cp-browser.js new file mode 100644 index 00000000..5df3feef --- /dev/null +++ b/lib/workers/cp-browser.js @@ -0,0 +1,2 @@ +// Empty module for browserify. +exports.unsupported = true; diff --git a/lib/workers/cp.js b/lib/workers/cp.js new file mode 100644 index 00000000..6f3d6fa2 --- /dev/null +++ b/lib/workers/cp.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('child_process'); diff --git a/lib/workers/workerpool.js b/lib/workers/workerpool.js index 30c9556a..4d1949c8 100644 --- a/lib/workers/workerpool.js +++ b/lib/workers/workerpool.js @@ -10,7 +10,7 @@ var assert = require('assert'); var EventEmitter = require('events').EventEmitter; var os = require('os'); -var cp = require('child_process'); +var cp = require('./cp'); var util = require('../utils/util'); var co = require('../utils/co'); var Network = require('../protocol/network'); diff --git a/package.json b/package.json index 3cf32a41..9d7ab6f2 100644 --- a/package.json +++ b/package.json @@ -65,44 +65,5 @@ "test-browser": "BCOIN_NO_NATIVE=1 BCOIN_USE_ELLIPTIC=1 mocha --reporter spec test/*-test.js", "test-file": "mocha --reporter spec", "webpack": "webpack" - }, - "browser": { - "child_process": "./browser/empty.js", - "crypto": "./browser/empty.js", - "dgram": "./browser/empty.js", - "dns": "./browser/empty.js", - "fs": "./browser/empty.js", - "net": "./browser/empty.js", - "bcoin-native": "./browser/empty.js", - "secp256k1": "./browser/empty.js", - "socket.io": "./browser/empty.js", - "./lib/bcoin": "./lib/bcoin-browser.js", - "./lib/blockchain/layout.js": "./lib/blockchain/layout-browser.js", - "./lib/crypto/aes.js": "./lib/crypto/aes-browser.js", - "./lib/crypto/digest.js": "./lib/crypto/digest-browser.js", - "./lib/crypto/pbkdf2.js": "./lib/crypto/pbkdf2-browser.js", - "./lib/crypto/random.js": "./lib/crypto/random-browser.js", - "./lib/crypto/rsa.js": "./lib/crypto/rsa-browser.js", - "./lib/crypto/secp256k1.js": "./lib/crypto/secp256k1-elliptic.js", - "./lib/db/backends.js": "./lib/db/backends-browser.js", - "./lib/hd/wordlist": "./lib/hd/wordlist-browser.js", - "./lib/http/base": "./browser/empty.js", - "./lib/http/client": "./browser/empty.js", - "./lib/http/request": "./browser/empty.js", - "./lib/http/rpcclient": "./browser/empty.js", - "./lib/http/server": "./browser/empty.js", - "./lib/http/wallet": "./browser/empty.js", - "./lib/mempool/layout": "./lib/mempool/layout-browser.js", - "./lib/native": "./browser/empty.js", - "./lib/net/dns": "./lib/net/dns-browser.js", - "./lib/net/external": "./lib/net/external-browser.js", - "./lib/net/socks": "./browser/empty.js", - "./lib/net/tcp": "./lib/net/tcp-browser.js", - "./lib/net/upnp": "./lib/net/upnp-browser.js", - "./lib/utils/fs": "./browser/empty.js", - "./lib/utils/nfkd": "./lib/utils/nfkd-browser.js", - "./lib/wallet/http": "./browser/empty.js", - "./lib/wallet/layout": "./lib/wallet/layout-browser.js", - "./lib/wallet/server": "./browser/empty.js" } } diff --git a/webpack.config.js b/webpack.config.js index 36a85f94..2fd68616 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -16,7 +16,7 @@ module.exports = { resolve: { descriptionFiles: ['package.json'], modules: ['node_modules'], - extensions: ['.js', '.json'], + extensions: ['-browser.js', '.js', '.json'], aliasFields: ['browser'] }, module: {