Use the right webpack file // Export to window.Parity #3471
This commit is contained in:
parent
3ad7e873e1
commit
6fd17540f3
@ -14,10 +14,22 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'babel-polyfill/dist/polyfill.js';
|
||||||
|
import es6Promise from 'es6-promise';
|
||||||
|
es6Promise.polyfill();
|
||||||
|
|
||||||
|
const isNode = typeof global !== 'undefined' && typeof global !== 'undefined';
|
||||||
|
const isBrowser = typeof self !== 'undefined' && typeof self.window !== 'undefined';
|
||||||
|
|
||||||
|
if (isBrowser) {
|
||||||
|
require('whatwg-fetch');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isNode) {
|
||||||
|
global.fetch = require('node-fetch');
|
||||||
|
}
|
||||||
|
|
||||||
import Abi from './abi';
|
import Abi from './abi';
|
||||||
import Api from './api';
|
import Api from './api';
|
||||||
|
|
||||||
export {
|
module.exports = { Api, Abi };
|
||||||
Abi,
|
|
||||||
Api
|
|
||||||
};
|
|
||||||
|
@ -14,34 +14,19 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import 'babel-polyfill/dist/polyfill.js';
|
import 'babel-polyfill';
|
||||||
|
import 'whatwg-fetch';
|
||||||
|
|
||||||
import es6Promise from 'es6-promise';
|
import es6Promise from 'es6-promise';
|
||||||
es6Promise.polyfill();
|
es6Promise.polyfill();
|
||||||
|
|
||||||
const isNode = typeof global !== 'undefined' && typeof global !== 'undefined';
|
|
||||||
const isBrowser = typeof self !== 'undefined' && typeof self.window !== 'undefined';
|
|
||||||
|
|
||||||
if (isBrowser) {
|
|
||||||
require('whatwg-fetch');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isNode) {
|
|
||||||
global.fetch = require('node-fetch');
|
|
||||||
}
|
|
||||||
|
|
||||||
import Api from './api';
|
import Api from './api';
|
||||||
|
|
||||||
import './dev.parity.html';
|
import './dev.parity.html';
|
||||||
|
|
||||||
// commonjs
|
|
||||||
module.exports = { Api };
|
|
||||||
// es6 default export compatibility
|
|
||||||
module.exports.default = module.exports;
|
|
||||||
|
|
||||||
if (isBrowser) {
|
|
||||||
const api = new Api(new Api.Transport.Http('/rpc/'));
|
const api = new Api(new Api.Transport.Http('/rpc/'));
|
||||||
|
|
||||||
self.window.parity = {
|
window.parity = {
|
||||||
Api,
|
Api,
|
||||||
api
|
api
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
@ -24,13 +24,23 @@ const isProd = ENV === 'production';
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
context: path.join(__dirname, './src'),
|
context: path.join(__dirname, './src'),
|
||||||
|
target: 'node',
|
||||||
entry: 'library.js',
|
entry: 'library.js',
|
||||||
output: {
|
output: {
|
||||||
path: path.join(__dirname, '.npmjs'),
|
path: path.join(__dirname, '.npmjs'),
|
||||||
filename: 'library.js',
|
filename: 'library.js',
|
||||||
libraryTarget: 'commonjs'
|
library: 'Parity',
|
||||||
|
libraryTarget: 'umd',
|
||||||
|
umdNamedDefine: true
|
||||||
|
},
|
||||||
|
externals: {
|
||||||
|
'node-fetch': 'node-fetch',
|
||||||
|
'vertx': 'vertx'
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
|
noParse: [
|
||||||
|
/babel-polyfill/
|
||||||
|
],
|
||||||
loaders: [
|
loaders: [
|
||||||
{
|
{
|
||||||
test: /(\.jsx|\.js)$/,
|
test: /(\.jsx|\.js)$/,
|
||||||
|
Loading…
Reference in New Issue
Block a user