diff --git a/package.json b/package.json index d58aaee86..a6d60da25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@interlay/interbtc-api", - "version": "2.5.0", + "version": "2.5.1", "description": "JavaScript library to interact with interBTC", "main": "build/src/index.js", "type": "module", diff --git a/src/interfaces/definitions.ts b/src/interfaces/definitions.ts index 38e154cb5..fb24b40e3 100644 --- a/src/interfaces/definitions.ts +++ b/src/interfaces/definitions.ts @@ -1,9 +1,9 @@ import { RpcFunctionDefinition } from "@interlay/interbtc-types"; -import fs from "fs"; +import { createRequire } from "module"; -// hacky, but cannot import json "the old way" in esnext -const definitionsString = fs.readFileSync("./node_modules/@interlay/interbtc-types/definitions.json", "utf-8"); -const definitions = JSON.parse(definitionsString); +// need to use "require" to be able to import json file from @interlay/interbtc-types +const moduleRequire = createRequire(import.meta.url); +const definitions = moduleRequire("@interlay/interbtc-types/definitions.json"); interface DecoratedRpcFunctionDefinition extends RpcFunctionDefinition { aliasSection: string; diff --git a/tsconfig.json b/tsconfig.json index 301907bd6..49adaa575 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,8 +4,8 @@ }, "compilerOptions": { "skipLibCheck": true, - "target": "ES6", - "module": "ES6", + "target": "esnext", + "module": "esnext", "outDir": "build", "declaration": true, "strict": true,