Skip to content

Commit

Permalink
fix build for optimized npm package, add example, improve tsconfig fo…
Browse files Browse the repository at this point in the history
… d.ts files
  • Loading branch information
Leouarz committed Jun 16, 2023
1 parent d3dd3b4 commit e1e483a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
/build
build
.env*
.vscode
.DS_Store
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "avail-js-sdk",
"version": "0.0.3",
"version": "0.0.6",
"description": "Avail library of functions to interact with blockchain and manipulate transactions",
"main": "./build/index.js",
"scripts": {
"start": "ts-node src/index.ts",
"dev": "nodemon src/index.ts",
"build": "rimraf build && tsc && node ./src/_scripts/build.mjs",
"publish-avail": "npm run lint && npm run format && npm run build && cd build && npm publish && cd ..",
"test": "npx jest --config jest.config.ts",
"format": "prettier --write .",
"lint": "eslint ./src --ext .js,.ts"
Expand Down
28 changes: 16 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { disconnect, initialize, isConnected } from "./chain"

const main = async () => {
const api = await initialize()
const chain = await api.rpc.system.chain()
console.log(`Chain: ${chain} - Is connected: ${isConnected()}`)
await disconnect()
}
main()
// const main = async () => {
// const api = await initialize()
// const chain = await api.rpc.system.chain()
// console.log(`Chain: ${chain} - Is connected: ${isConnected()}`)
// await disconnect()
// }
// main()

export * from './chain'
export * from './spec'
export * from '@polkadot/api'
// Allows for generic imports (eg. import {...} from 'avail-js-sdk')
export * from "./chain"
export * from "./spec"

export * as chain from './chain'
export * as spec from './spec'
// Allows for custom imports (eg. import {...} from 'avail-js-sdk/chain')
export * as chain from "./chain"
export * as spec from "./spec"

// Re-exports to avoid duplicattion
export * from "@polkadot/api"
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"outDir": "./build",
"outDir": "build",
"declaration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
"skipLibCheck": true,
"noUnusedParameters": true
},
"include": ["src"],
"exclude": ["node_modules", "build"]
Expand Down

0 comments on commit e1e483a

Please sign in to comment.