feat: add commonjs config and missing subspace option in provider (#82)
* feat: add options to SubspaceProvider * fix: add commonjs config * fix: entry points
This commit is contained in:
parent
8c0e85c586
commit
c658f56440
|
@ -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: [
|
||||
[
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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<SubspaceProviderProps>;
|
||||
|
|
Loading…
Reference in New Issue