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:
RichΛrd 2020-04-03 11:30:32 -04:00 committed by GitHub
parent 8c0e85c586
commit c658f56440
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 5 deletions

View File

@ -3,6 +3,33 @@ module.exports = api => {
return { return {
env: { 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: { browser: {
presets: [ presets: [
[ [

View File

@ -25,12 +25,14 @@
}, },
"license": "MIT", "license": "MIT",
"types": "types/index.d.ts", "types": "types/index.d.ts",
"main": "./lib/index.js", "main": "./dist/index.js",
"browser": "./lib/index.js",
"module": "./module/index.js", "module": "./module/index.js",
"scripts": { "scripts": {
"clean": "rimraf lib; rimraf module;", "clean": "rimraf lib; rimraf module;",
"build:browser": "cross-env BABEL_ENV=browser babel ./src --out-dir ./lib --source-maps --copy-files", "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: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:*" "build": "npm-run-all clean build:*"
}, },
"devDependencies": { "devDependencies": {

View File

@ -3,13 +3,13 @@ import PropTypes from "prop-types";
import Subspace from "@embarklabs/subspace"; import Subspace from "@embarklabs/subspace";
import SubspaceContext from "./subspaceContext"; import SubspaceContext from "./subspaceContext";
function SubspaceProvider({children, web3}) { function SubspaceProvider({children, web3, options}) {
const [subspace, setSubspace] = useState(); const [subspace, setSubspace] = useState();
useEffect(() => { useEffect(() => {
let s; let s;
(async () => { (async () => {
s = new Subspace(web3); s = new Subspace(web3, options);
await s.init(); await s.init();
setSubspace(s); setSubspace(s);
})(); })();
@ -25,7 +25,8 @@ function SubspaceProvider({children, web3}) {
} }
SubspaceProvider.defaultProps = { SubspaceProvider.defaultProps = {
children: null children: null,
options: {}
}; };
SubspaceProvider.propTypes = { SubspaceProvider.propTypes = {

View File

@ -1,10 +1,11 @@
import Web3 from "web3"; import Web3 from "web3";
import React from 'react'; import React from 'react';
import Subspace from "@embarklabs/subspace" import Subspace, { SubspaceOptions } from "@embarklabs/subspace"
export interface SubspaceProviderProps { export interface SubspaceProviderProps {
web3: Web3; web3: Web3;
children: React.ReactNode; children: React.ReactNode;
options: SubspaceOptions;
} }
export const SubspaceProvider: React.Component<SubspaceProviderProps>; export const SubspaceProvider: React.Component<SubspaceProviderProps>;