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
|
||||
// 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 Api from './api';
|
||||
|
||||
export {
|
||||
Abi,
|
||||
Api
|
||||
};
|
||||
module.exports = { Api, Abi };
|
||||
|
@ -14,34 +14,19 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// 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';
|
||||
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 './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/'));
|
||||
|
||||
self.window.parity = {
|
||||
window.parity = {
|
||||
Api,
|
||||
api
|
||||
};
|
||||
}
|
||||
|
@ -24,13 +24,23 @@ const isProd = ENV === 'production';
|
||||
|
||||
module.exports = {
|
||||
context: path.join(__dirname, './src'),
|
||||
target: 'node',
|
||||
entry: 'library.js',
|
||||
output: {
|
||||
path: path.join(__dirname, '.npmjs'),
|
||||
filename: 'library.js',
|
||||
libraryTarget: 'commonjs'
|
||||
library: 'Parity',
|
||||
libraryTarget: 'umd',
|
||||
umdNamedDefine: true
|
||||
},
|
||||
externals: {
|
||||
'node-fetch': 'node-fetch',
|
||||
'vertx': 'vertx'
|
||||
},
|
||||
module: {
|
||||
noParse: [
|
||||
/babel-polyfill/
|
||||
],
|
||||
loaders: [
|
||||
{
|
||||
test: /(\.jsx|\.js)$/,
|
||||
|
Loading…
Reference in New Issue
Block a user