diff --git a/packages/react/babel.config.js b/packages/react/babel.config.js index 07339f0..39bffc8 100644 --- a/packages/react/babel.config.js +++ b/packages/react/babel.config.js @@ -3,6 +3,33 @@ module.exports = api => { 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-export-default-from", + "@babel/plugin-proposal-class-properties", + "@babel/plugin-proposal-private-methods", + "@babel/plugin-proposal-nullish-coalescing-operator", + "@babel/plugin-proposal-optional-chaining", + "@babel/plugin-transform-react-jsx" + ] + }, browser: { presets: [ [ diff --git a/packages/react/package.json b/packages/react/package.json index 1749155..a9fbde3 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -25,12 +25,14 @@ }, "license": "MIT", "types": "types/index.d.ts", - "main": "./lib/index.js", + "main": "./dist/index.js", + "browser": "./lib/index.js", "module": "./module/index.js", "scripts": { "clean": "rimraf lib; rimraf module;", "build:browser": "cross-env BABEL_ENV=browser babel ./src --out-dir ./lib --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": { diff --git a/packages/react/src/SubspaceProvider.js b/packages/react/src/SubspaceProvider.js index 53fdc8e..17cb7e2 100644 --- a/packages/react/src/SubspaceProvider.js +++ b/packages/react/src/SubspaceProvider.js @@ -3,13 +3,13 @@ import PropTypes from "prop-types"; import Subspace from "@embarklabs/subspace"; import SubspaceContext from "./subspaceContext"; -function SubspaceProvider({children, web3}) { +function SubspaceProvider({children, web3, options}) { const [subspace, setSubspace] = useState(); useEffect(() => { let s; (async () => { - s = new Subspace(web3); + s = new Subspace(web3, options); await s.init(); setSubspace(s); })(); @@ -25,7 +25,8 @@ function SubspaceProvider({children, web3}) { } SubspaceProvider.defaultProps = { - children: null + children: null, + options: {} }; SubspaceProvider.propTypes = { diff --git a/packages/react/types/index.d.ts b/packages/react/types/index.d.ts index 0f376d2..05d5c3e 100644 --- a/packages/react/types/index.d.ts +++ b/packages/react/types/index.d.ts @@ -1,10 +1,11 @@ import Web3 from "web3"; import React from 'react'; -import Subspace from "@embarklabs/subspace" +import Subspace, { SubspaceOptions } from "@embarklabs/subspace" export interface SubspaceProviderProps { web3: Web3; children: React.ReactNode; + options: SubspaceOptions; } export const SubspaceProvider: React.Component;