webpack: use -browser convention instead of aliases.

This commit is contained in:
Christopher Jeffrey 2017-06-28 12:45:38 -07:00
parent 3763b5309a
commit 24cd81a1bd
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
19 changed files with 31 additions and 42 deletions

View File

@ -18,4 +18,4 @@ if (+process.env.BCOIN_USE_ELLIPTIC !== 1) {
module.exports = native
? require('./secp256k1-native')
: require('./secp256k1-elliptic');
: require('./secp256k1-browser');

2
lib/http/base-browser.js Normal file
View File

@ -0,0 +1,2 @@
// Empty module for browserify.
exports.unsupported = true;

View File

@ -0,0 +1,2 @@
// Empty module for browserify.
exports.unsupported = true;

View File

@ -0,0 +1,2 @@
// Empty module for browserify.
exports.unsupported = true;

View File

@ -0,0 +1,2 @@
// Empty module for browserify.
exports.unsupported = true;

View File

@ -0,0 +1,2 @@
// Empty module for browserify.
exports.unsupported = true;

View File

@ -0,0 +1,2 @@
// Empty module for browserify.
exports.unsupported = true;

1
lib/native-browser.js Normal file
View File

@ -0,0 +1 @@
exports.binding = null;

2
lib/net/socks-browser.js Normal file
View File

@ -0,0 +1,2 @@
// Empty module for browserify.
exports.unsupported = true;

2
lib/utils/fs-browser.js Normal file
View File

@ -0,0 +1,2 @@
// Empty module for browserify.
exports.unsupported = true;

View File

@ -0,0 +1,2 @@
// Empty module for browserify.
exports.unsupported = true;

View File

@ -0,0 +1,2 @@
// Empty module for browserify.
exports.unsupported = true;

View File

@ -0,0 +1,2 @@
// Empty module for browserify.
exports.unsupported = true;

View File

@ -0,0 +1,2 @@
// Empty module for browserify.
exports.unsupported = true;

3
lib/workers/cp.js Normal file
View File

@ -0,0 +1,3 @@
'use strict';
module.exports = require('child_process');

View File

@ -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');

View File

@ -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"
}
}

View File

@ -16,7 +16,7 @@ module.exports = {
resolve: {
descriptionFiles: ['package.json'],
modules: ['node_modules'],
extensions: ['.js', '.json'],
extensions: ['-browser.js', '.js', '.json'],
aliasFields: ['browser']
},
module: {