Skip to content

Commit

Permalink
fix: change output from webpack to babel (#64)
Browse files Browse the repository at this point in the history
* fix: use webpack to transpile js code and removed webpack
* fix: update tests
* fix: node version
* fix: code review
  • Loading branch information
richard-ramos authored Feb 3, 2020
1 parent 2c8ca28 commit 4232fc3
Show file tree
Hide file tree
Showing 18 changed files with 1,519 additions and 2,278 deletions.
4 changes: 0 additions & 4 deletions .babelrc

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ TODO
test.js
/dist/
/react/
/lib/
/module/
/examples/react-example1/src/contract.json
79 changes: 79 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
module.exports = api => {
api.cache(true);

return {
env: {
development: {
presets: [
[
"@babel/preset-env",
{
corejs: 3,
shippedProposals: true,
targets: { node: "current" },
useBuiltIns: "usage"
}
]
],
plugins: [
[
"@babel/plugin-transform-runtime",
{
corejs: 3
}
],
"@babel/plugin-proposal-class-properties"
]
},
browser: {
presets: [
[
"@babel/preset-env",
{
corejs: 3,
modules: false,
shippedProposals: true,
targets: { browsers: "defaults" },
useBuiltIns: "usage"
}
]
],
plugins: [
[
"@babel/plugin-transform-runtime",
{
corejs: 3,
useESModules: true
}
],
"@babel/plugin-proposal-class-properties"
]
},
module: {
presets: [
[
"@babel/preset-env",
{
corejs: 3,
modules: false,
shippedProposals: true,
targets: { node: "current" },
useBuiltIns: "usage"
}
]
],
plugins: [
[
"@babel/plugin-transform-runtime",
{
corejs: 3,
useESModules: true
}
],
"@babel/plugin-proposal-class-properties"
]
}
},
sourceMaps: true
};
};
55 changes: 24 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,47 +24,40 @@
"url": "https://github.com/embark-framework/subspace/issues"
},
"license": "MIT",
"main": "./dist/node.js",
"browser": "./dist/browser.js",
"main": "./dist/index.js",
"browser": "./lib/index.js",
"module": "./module/index.js",
"scripts": {
"babel": "babel",
"babel:node": "npm-run-all babel:node:*",
"babel:node:src": "cross-env BABEL_ENV=node babel src --copy-files --extensions \".js\" --out-dir dist",
"webpack:dev": "webpack --config webpack.dev.js",
"webpack:prod": "webpack --config webpack.prod.js",
"build:dev": "npm-run-all clean webpack:dev",
"build:prod": "npm-run-all clean webpack:prod",
"build": "npm-run-all build:dev",
"clean": "rimraf dist; rimraf react"
"clean": "rimraf dist; rimraf lib; rimraf module; rimraf react;",
"build:browser": "cross-env BABEL_ENV=browser babel ./src --out-dir ./lib --source-maps --copy-files --ignore src/react/*",
"build:react": "cross-env BABEL_ENV=browser babel ./src/react --out-dir ./react --source-maps --copy-files",
"build:module": "cross-env BABEL_ENV=module babel ./src --out-dir ./module --source-maps --copy-files",
"build:node": "babel ./src --out-dir ./dist --source-maps --copy-files",
"build": "npm-run-all clean build:*"
},
"devDependencies": {
"@babel/cli": "^7.1.5",
"@babel/core": "^7.1.6",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-transform-runtime": "^7.6.2",
"@babel/preset-env": "^7.1.6",
"@babel/runtime": "^7.7.2",
"add-module-exports-webpack-plugin": "^1.0.0",
"babel-loader": "^8.0.4",
"cross-env": "^5.2.0",
"ganache-core": "^2.7.0",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.8.3",
"@babel/preset-env": "^7.8.4",
"cross-env": "^7.0.0",
"ganache-core": "^2.10.1",
"npm-run-all": "^4.1.5",
"rimraf": "^2.6.2",
"webpack": "4.39.1",
"webpack-bundle-analyzer": "^3.4.1",
"webpack-cli": "^3.3.6",
"webpack-merge": "^4.2.1",
"webpack-node-externals": "^1.7.2"
"rimraf": "^3.0.1"
},
"dependencies": {
"fast-deep-equal": "^2.0.1",
"@babel/runtime": "^7.8.4",
"@babel/runtime-corejs3": "^7.8.4",
"core-js": "^3.6.4",
"fast-deep-equal": "^3.1.1",
"hex2dec": "^1.1.2",
"lokijs": "^1.5.6",
"object-hash": "^1.3.1",
"object-hash": "^2.0.1",
"rxjs": "^6.5.2",
"web3-eth": "^1.2.1"
"web3-eth": "^1.2.6"
},
"optionalDependencies": {
"peerDependencies": {
"graphql": "^14.4.2",
"graphql-tag": "^2.10.1",
"graphql-tools": "^4.0.5",
Expand Down
2 changes: 1 addition & 1 deletion src/subspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import LogSyncer from './logSyncer';
export default class Subspace {

constructor(provider, options = {}) {
if (!!provider.on) {
if (!provider.on) {
// https://github.com/ethereum/web3.js/blob/1.x/packages/web3-core-subscriptions/src/subscription.js#L205
console.warn("subspace: the current provider doesn't support subscriptions. Falling back to http polling");
}
Expand Down
2 changes: 1 addition & 1 deletion test/test-graphql-2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { makeExecutableSchema } = require("graphql-tools");
const gql = require( "graphql-tag");
const graphql = require( "reactive-graphql").graphql;
const Subspace = require('../dist/node.js');
const Subspace = require('../dist/index.js').default;


const Web3Eth = require('web3-eth');
Expand Down
2 changes: 1 addition & 1 deletion test/test-graphql-3.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { makeExecutableSchema } = require("graphql-tools");
const gql = require( "graphql-tag");
const graphql = require( "reactive-graphql").graphql;
const Subspace = require('../dist/node.js');
const Subspace = require('../dist/index.js').default;
const { map, scan, last, distinctUntilChanged, pluck } = require('rxjs/operators');
const Web3Eth = require('web3-eth');
const {$average} = require('../src/operators');
Expand Down
5 changes: 2 additions & 3 deletions test/test1.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const { map, scan, last, distinctUntilChanged } = require('rxjs/operators');
const Web3Eth = require('web3-eth');
const {deployRatingContract} = require('./utils-web3');
const Subspace = require('../dist/node.js');

const Subspace = require('../dist/index.js').default;
let eth = new Web3Eth("http://localhost:8545");

let myscan = scan((acc, curr) => {
Expand Down Expand Up @@ -62,4 +61,4 @@ async function run() {
// await RatingContract.methods.doRating(1, 5).send({from: accounts[0]})
}

run()
run()
2 changes: 1 addition & 1 deletion test/test2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { map, scan, last, distinctUntilChanged } = require('rxjs/operators');
const Web3Eth = require('web3-eth');
const {deployEscrowContract} = require('./utils-web3');
const Subspace = require('../dist/node.js');
const Subspace = require('../dist/index.js').default;

let eth = new Web3Eth("ws://localhost:8545");

Expand Down
2 changes: 1 addition & 1 deletion test/test3.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { map, scan, last, distinctUntilChanged } = require('rxjs/operators');
const Web3Eth = require('web3-eth');
const Subspace = require('../dist/node.js');
const Subspace = require('../dist/index.js').default;

let eth = new Web3Eth("ws://localhost:8545");

Expand Down
2 changes: 1 addition & 1 deletion test/test4.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const ganache = require("ganache-core");
const Web3Eth = require('web3-eth');
const Subspace = require('../dist/node.js');
const Subspace = require('../dist/index.js').default;

console.log("The following error is emitted by ganache - https://github.com/trufflesuite/ganache-core/issues/267")
let eth = new Web3Eth(ganache.provider());
Expand Down
2 changes: 1 addition & 1 deletion test/test5.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Web3Eth = require('web3-eth');
const Subspace = require('../dist/node.js');
const Subspace = require('../dist/index.js').default;

let eth = new Web3Eth("ws://localhost:8545");

Expand Down
2 changes: 1 addition & 1 deletion test/test6.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Web3Eth = require('web3-eth');
const {deployRatingContract, mine} = require('./utils-web3');
const Subspace = require('../dist/node.js');
const Subspace = require('../dist/index.js').default;
const ganache = require("ganache-core");

console.log("The following error is emitted by ganache - https://github.com/trufflesuite/ganache-core/issues/267")
Expand Down
2 changes: 1 addition & 1 deletion test/test7.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Web3Eth = require('web3-eth');
const Subspace = require('../dist/node.js');
const Subspace = require('../dist/index.js').default;

let eth = new Web3Eth("wss://mainnet.infura.io/ws/v3/_____________");

Expand Down
107 changes: 0 additions & 107 deletions webpack.common.js

This file was deleted.

12 changes: 0 additions & 12 deletions webpack.dev.js

This file was deleted.

12 changes: 0 additions & 12 deletions webpack.prod.js

This file was deleted.

Loading

0 comments on commit 4232fc3

Please sign in to comment.