diff --git a/package.json b/package.json index 044a9be..8f31149 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,14 @@ "scripts": { "testCommand": "jest", "prepare": "npm run build", - "build": "tsc -p ./tsconfig-es.json && tsc -p ./tsconfig-cjs.json && webpack", + "build": "rm -rf ./es && tsc -p ./tsconfig-es.json && rm -rf ./cjs && tsc -p ./tsconfig-cjs.json && webpack", "test": "node-state -e -n -m typescript -o ./test/_state.ts -r" }, "dependencies": { "@types/node-fetch": "^2.5.4", "@waves/bignumber": "^1.1.1", "@waves/ts-types": "^1.0.6-beta.7", - "node-fetch": "^3.1.1", + "cross-fetch": "^3.1.5", "typed-ts-events": "^1.1.1" }, "files": [ diff --git a/src/tools/request.ts b/src/tools/request.ts index 3853fd7..ee256dd 100644 --- a/src/tools/request.ts +++ b/src/tools/request.ts @@ -1,8 +1,7 @@ import resolve from './resolve'; import parse from './parse'; - -const request = typeof fetch === 'function' ? fetch : require('node-fetch'); +import request from 'cross-fetch'; export default function (params: IRequestParams): Promise { return request(resolve(params.url, params.base), updateHeaders(params.options)) @@ -23,7 +22,7 @@ function tryParse(message: string) { function updateHeaders(options: RequestInit = Object.create(null)) { return { - credentials: 'include', + credentials: ('include' as any), ...options }; } @@ -31,7 +30,7 @@ function updateHeaders(options: RequestInit = Object.create(null)) { export interface IRequestParams { url: string; base: string; - options?: RequestInit | undefined; + options?: any; // TODO RequestInit; } // RequestInit is a DOM interface. It needs to be explicitly defined here for usage in nodejs environment diff --git a/tsconfig-cjs.json b/tsconfig-cjs.json index 1764958..27d3def 100644 --- a/tsconfig-cjs.json +++ b/tsconfig-cjs.json @@ -2,9 +2,9 @@ "extends": "./tsconfig.json", "compilerOptions": { "module": "CommonJS", - "target": "ES5", + "target": "es2017", "outDir": "./cjs", - "declaration": true + "declaration": true, }, "include": [ "src" diff --git a/tsconfig.json b/tsconfig.json index b454946..9775c96 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,6 @@ "downlevelIteration": true, "lib": [ "es5", - "dom", "es2015.iterable", "es2015.promise" ]