Better use of Webpack #3471

This commit is contained in:
Nicolas Gotchac 2016-11-16 19:16:55 +01:00
parent 6c60aaec08
commit 3ad7e873e1
4 changed files with 19 additions and 13 deletions

View File

@ -138,7 +138,6 @@
"mobx-react": "^3.5.8", "mobx-react": "^3.5.8",
"mobx-react-devtools": "^4.2.9", "mobx-react-devtools": "^4.2.9",
"moment": "^2.14.1", "moment": "^2.14.1",
"node-fetch": "^1.6.3",
"qs": "^6.3.0", "qs": "^6.3.0",
"react": "^15.2.1", "react": "^15.2.1",
"react-ace": "^4.0.0", "react-ace": "^4.0.0",

View File

@ -27,6 +27,7 @@
}, },
"dependencies": { "dependencies": {
"bignumber.js": "^2.3.0", "bignumber.js": "^2.3.0",
"js-sha3": "^0.5.2" "js-sha3": "^0.5.2",
"node-fetch": "^1.6.3"
} }
} }

View File

@ -18,17 +18,16 @@ import 'babel-polyfill/dist/polyfill.js';
import es6Promise from 'es6-promise'; import es6Promise from 'es6-promise';
es6Promise.polyfill(); es6Promise.polyfill();
try { const isNode = typeof global !== 'undefined' && typeof global !== 'undefined';
if (typeof self.window !== 'undefined') { const isBrowser = typeof self !== 'undefined' && typeof self.window !== 'undefined';
self.window.fetch = require('isomorphic-fetch');
}
} catch (e) {}
try { if (isBrowser) {
if (typeof global !== 'undefined') { require('whatwg-fetch');
global.fetch = require('node-fetch'); }
}
} catch (e) {} if (isNode) {
global.fetch = require('node-fetch');
}
import Api from './api'; import Api from './api';
import './dev.parity.html'; import './dev.parity.html';
@ -38,7 +37,7 @@ module.exports = { Api };
// es6 default export compatibility // es6 default export compatibility
module.exports.default = module.exports; module.exports.default = module.exports;
if (typeof self !== 'undefined' && typeof self.window !== 'undefined') { if (isBrowser) {
const api = new Api(new Api.Transport.Http('/rpc/')); const api = new Api(new Api.Transport.Http('/rpc/'));
self.window.parity = { self.window.parity = {

View File

@ -39,7 +39,14 @@ module.exports = {
library: '[name].js', library: '[name].js',
libraryTarget: 'umd' libraryTarget: 'umd'
}, },
externals: {
'node-fetch': 'node-fetch',
'vertx': 'vertx'
},
module: { module: {
noParse: [
/babel-polyfill/
],
loaders: [ loaders: [
{ {
test: /\.js$/, test: /\.js$/,