*Remove all requires

*Switch to commonjs target
This commit is contained in:
Derrick Hammer 2022-08-03 02:02:40 -04:00
parent 451f646fb2
commit 5a17b6befd
9 changed files with 16 additions and 14 deletions

View File

@ -1,4 +1,5 @@
const esbuild = require("esbuild");
esbuild.buildSync({
entryPoints: ["build/index.js"],
outdir: "node-dist",

View File

@ -11,7 +11,7 @@
"scripts": {
"compile": "tsc",
"prebuild": "bash prebuild.sh",
"bundle": "node esbuild.config.js",
"bundle": "node build.js",
"package": "pkg -c pkg.json node-dist/index.js -t linux --no-bytecode --public",
"package-debug": "pkg -c pkg.json node-dist/index.js -b -t linux --no-bytecode --public",
"build": "npm run compile && npm run prebuild && npm run bundle && npm run package",

View File

@ -1,7 +1,8 @@
//const require = createRequire(import.meta.url);
//import { createRequire } from "module";
const DHT = require("@hyperswarm/dht");
// @ts-ignore
import DHT from "@hyperswarm/dht";
import {
deriveMyskyRootKeypair,
Ed25519Keypair,

View File

@ -1,7 +1,7 @@
import { start as startRpc } from "./rpc.js";
import { start as startRelay } from "./relay.js";
import log from "loglevel";
import config from "./config";
import config from "./config.js";
log.setDefaultLevel(config.str("log-level"));
@ -13,5 +13,5 @@ async function boot() {
boot();
process.on("uncaughtException", function (err) {
console.log("Caught exception: " + err);
console.log(`Caught exception: ${err.message} ${err.stack}`);
});

View File

@ -9,13 +9,12 @@ import NodeCache from "node-cache";
import { get as getDHT } from "./dht.js";
import { rpcMethods } from "./rpc/index.js";
import { start as startDns } from "./dns.js";
const {
import {
Configuration,
HttpRpcProvider,
PocketAAT,
Pocket,
} = require("@pokt-network/pocket-js/dist/index.js");
} from "@pokt-network/pocket-js/dist/index.js";
import {
JSONRPCError,
JSONRPCRequest,
@ -25,8 +24,9 @@ import {
import config, { updateUsePocketGateway, usePocketGateway } from "./config.js";
import { ERR_NOT_READY, errorExit } from "./error.js";
import log from "loglevel";
// @ts-ignore
import stringify from "json-stable-stringify";
const stringify = require("json-stable-stringify");
const pendingRequests = new NodeCache();
const processedRequests = new NodeCache({
stdTTL: 60 * 60 * 12,

View File

@ -3,8 +3,8 @@
import { isIp } from "../util.js";
import { RpcMethodList } from "./index.js";
const bns = require("bns");
// @ts-ignore
import bns from "bns";
const { StubResolver, RecursiveResolver } = bns;
const resolverOpt = {

View File

@ -8,8 +8,8 @@ import rand from "random-key";
import SPVNode from "hsd/lib/node/spvnode.js";
import config from "../config.js";
import { ERR_NOT_READY } from "../error.js";
const { NodeClient } = require("hs-client");
// @ts-ignore
import { NodeClient } from "hs-client";
let hsdServer: SPVNode;

View File

@ -1,6 +1,6 @@
import { proxyRpcMethod } from "./common.js";
import { RpcMethodList } from "./index.js";
import * as chainNetworks from "../networks.json";
import chainNetworks from "../networks.json";
export default {
getAccountInfo: proxyRpcMethod("getAccountInfo", [

View File

@ -1,4 +1,4 @@
import * as chainNetworks from "./networks.json";
import chainNetworks from "./networks.json";
type networks = { [net: string]: string };