diff --git a/package.json b/package.json index c7043c2..f296d3b 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,18 @@ "name": "redstone-smartweave", "version": "0.3.10-alpha.1", "description": "An implementation of the SmartWeave SDK.", - "main": "lib/index.js", - "types": "lib/index.d.ts", + "main": "./lib/cjs/index.js", + "module": "./lib/esm/index.js", + "types": "./lib/types/index.d.ts", + "sideEffects": false, + "engines": { + "node": ">=12" + }, "scripts": { - "build": "yarn run clean && tsc && 'tsc-alias'", + "build:cjs": "tsc -b tsconfig.json && tsc-alias -p tsconfig.json", + "build:esm": "tsc -b tsconfig.esm.json && tsc-alias -p tsconfig.esm.json", + "build:types": "tsc -b tsconfig.types.json && tsc-alias -p tsconfig.types.json", + "build": "yarn run clean && yarn build:cjs && yarn build:esm && yarn build:types", "format": "prettier --write 'src/**/*.ts'", "clean": "rimraf ./lib", "lint": "eslint . --ext .ts", diff --git a/src/contract/Contract.ts b/src/contract/Contract.ts index 898e5a6..57cdcd7 100644 --- a/src/contract/Contract.ts +++ b/src/contract/Contract.ts @@ -1,4 +1,4 @@ -import { EvalStateResult, EvaluationOptions, HandlerApi, InteractionResult, InteractionTx } from '@smartweave'; +import { EvalStateResult, EvaluationOptions, InteractionResult, InteractionTx } from '@smartweave'; import { JWKInterface } from 'arweave/node/lib/wallet'; /** diff --git a/src/contract/HandlerBasedContract.ts b/src/contract/HandlerBasedContract.ts index 4a3ce31..d17663c 100644 --- a/src/contract/HandlerBasedContract.ts +++ b/src/contract/HandlerBasedContract.ts @@ -1,10 +1,12 @@ import { ArTransfer, + ArWallet, Benchmark, Contract, ContractInteraction, createTx, DefaultEvaluationOptions, + emptyTransfer, EvalStateResult, EvaluationOptions, ExecutionContext, @@ -12,11 +14,9 @@ import { InteractionResult, InteractionTx, LoggerFactory, + sleep, SmartWeave, - Tags, - ArWallet, - emptyTransfer, - sleep + Tags } from '@smartweave'; import { TransactionStatusResponse } from 'arweave/node/transactions'; import { NetworkInfoInterface } from 'arweave/node/network'; diff --git a/src/core/modules/StateEvaluator.ts b/src/core/modules/StateEvaluator.ts index 79c0b04..1cb2b1b 100644 --- a/src/core/modules/StateEvaluator.ts +++ b/src/core/modules/StateEvaluator.ts @@ -1,4 +1,4 @@ -import { ExecutionContext, GQLNodeInterface, HandlerApi } from '@smartweave'; +import { ExecutionContext, GQLNodeInterface } from '@smartweave'; /** * Implementors of this class are responsible for evaluating contract's state diff --git a/src/core/modules/impl/ContractDefinitionLoader.ts b/src/core/modules/impl/ContractDefinitionLoader.ts index 926ff4b..b47e406 100644 --- a/src/core/modules/impl/ContractDefinitionLoader.ts +++ b/src/core/modules/impl/ContractDefinitionLoader.ts @@ -1,12 +1,4 @@ -import { - Benchmark, - ContractDefinition, - DefinitionLoader, - getTag, - LoggerFactory, - SmartWeaveTags, - SwCache -} from '@smartweave'; +import { ContractDefinition, DefinitionLoader, getTag, LoggerFactory, SmartWeaveTags, SwCache } from '@smartweave'; import Arweave from 'arweave'; import Transaction from 'arweave/web/lib/transaction'; diff --git a/src/logging/LoggerFactory.ts b/src/logging/LoggerFactory.ts index c4c4b99..b238ac0 100644 --- a/src/logging/LoggerFactory.ts +++ b/src/logging/LoggerFactory.ts @@ -1,7 +1,6 @@ -import { RedStoneLogger, LogLevel } from '@smartweave'; -import { ConsoleLoggerFactory } from './web/ConsoleLoggerFactory'; -import { TsLogFactory } from './node/TsLogFactory'; +import { ConsoleLoggerFactory, LogLevel, RedStoneLogger } from '@smartweave'; import { ISettingsParam } from 'tslog'; +import { TsLogFactory } from './node/TsLogFactory'; export class LoggerFactory { static readonly INST: LoggerFactory = typeof window === 'undefined' ? new TsLogFactory() : new ConsoleLoggerFactory(); diff --git a/src/logging/index.ts b/src/logging/index.ts index 83c0890..8dc6086 100644 --- a/src/logging/index.ts +++ b/src/logging/index.ts @@ -1,6 +1,5 @@ export * from './web/ConsoleLogger'; export * from './web/ConsoleLoggerFactory'; -export * from './node/TsLogFactory'; export * from './RedStoneLogger'; export * from './LoggerFactory'; export * from './Benchmark'; diff --git a/src/logging/web/ConsoleLoggerFactory.ts b/src/logging/web/ConsoleLoggerFactory.ts index d597a85..4c39e70 100644 --- a/src/logging/web/ConsoleLoggerFactory.ts +++ b/src/logging/web/ConsoleLoggerFactory.ts @@ -1,4 +1,4 @@ -import { RedStoneLogger, LogLevel } from '@smartweave'; +import { LogLevel, RedStoneLogger } from '@smartweave'; import { ConsoleLogger } from './ConsoleLogger'; import { ISettingsParam } from 'tslog'; diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 0000000..5241262 --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "esnext", + "outDir": "lib/esm" + } +} diff --git a/tsconfig.json b/tsconfig.json index 88ac8a2..403b935 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,13 +1,18 @@ { + "$schema": "http://json.schemastore.org/tsconfig", + "compileOnSave": false, "compilerOptions": { - "sourceMap": true, "target": "es2019", "module": "commonjs", - "declaration": true, - "outDir": "./lib", - "esModuleInterop": true, + "types": ["jest", "node"], + "moduleResolution": "node", + "sourceMap": true, "skipLibCheck": true, - "resolveJsonModule": true, + "outDir": "./lib/cjs", + "isolatedModules": true, + "esModuleInterop": true, + "suppressImplicitAnyIndexErrors": true, + "allowSyntheticDefaultImports": true, "baseUrl": "./src", "paths": { "@smartweave/cache": ["cache/index"], diff --git a/tsconfig.types.json b/tsconfig.types.json new file mode 100644 index 0000000..d3369d7 --- /dev/null +++ b/tsconfig.types.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "esnext", + "target": "es2019", + "removeComments": false, + "declaration": true, + "declarationMap": true, + "declarationDir": "./lib/types", + "outDir": "./lib/types", + "emitDeclarationOnly": true + } +}