Skip to content

Commit

Permalink
fix(nats): change in the way nats is referenced
Browse files Browse the repository at this point in the history
changed the way nats.ws is referenced according to document https://github.com/nats-io/nats.ws/blob/master/developer_notes.md
  • Loading branch information
Passerino committed Sep 29, 2021
1 parent 301e86e commit b4fd123
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 26 deletions.
36 changes: 14 additions & 22 deletions bili.config.ts
@@ -1,28 +1,20 @@
import { Config } from "bili";

const config: Config = {
plugins: {
typescript2: {
tsconfigOverride: {
include: ["src", "ethers"]
}
}
},
extendConfig: config => ({
...config,
// The default externals are the package.json dependencies and can only bundle node_modules that are not a dependency.
// So need to clear out all externals, to bundle nats.ws package.
externals: []
}),
// nats.ws is bundled because using standard import/require does not work for cjs format.
// nat.ws only provides a .mjs file which cannot be required.
// include tslib for clients using older version of tslib
bundleNodeModules: ["nats.ws", "tslib"],
input: "src/iam-client-lib.ts",
output: {
format: ["cjs", "esm"],
minify: false
}
plugins: {
typescript2: {
tsconfigOverride: {
include: ["src", "ethers"],
},
},
},
// include tslib for clients using older version of tslib
bundleNodeModules: ["tslib"],
input: "src/iam-client-lib.ts",
output: {
format: ["cjs", "esm"],
minify: false,
},
};

export default config;
2 changes: 1 addition & 1 deletion src/iam.ts
Expand Up @@ -63,7 +63,7 @@ import {
proof_type_hash,
typedMsgPrefix,
} from "./utils/constants";
import { Subscription } from "nats.ws";
import { Subscription } from "../node_modules/nats.ws/lib/src/mod.js";
import { AxiosError } from "axios";
import { DIDDocumentFull } from "@ew-did-registry/did-document";
import { Methods } from "@ew-did-registry/did";
Expand Down
2 changes: 1 addition & 1 deletion src/iam/iam-base.ts
Expand Up @@ -25,7 +25,7 @@ import { ClaimManager } from "../../ethers/ClaimManager";
import { JWT } from "@ew-did-registry/jwt";
import { ICacheServerClient } from "../cacheServerClient/ICacheServerClient";
import { detectExecutionEnvironment, ExecutionEnvironment } from "../utils/detectEnvironment";
import { connect, NatsConnection, JSONCodec, Codec } from "nats.ws";
import { connect, NatsConnection, Codec, JSONCodec } from "../../node_modules/nats.ws/lib/src/mod.js";
import { ERROR_MESSAGES } from "../errors";
import { ClaimData } from "../cacheServerClient/cacheServerClient.types";
import difference from "lodash.difference";
Expand Down
2 changes: 1 addition & 1 deletion test/claimsTests/enrollmentClaimsTests.ts
Expand Up @@ -2,7 +2,7 @@ import { PreconditionType } from "@energyweb/iam-contracts";
import { Methods } from "@ew-did-registry/did";
import { addressOf } from "@ew-did-registry/did-ethr-resolver";
import { Wallet, utils } from "ethers";
import { Codec } from "nats.ws";
import { Codec } from "../../node_modules/nats.ws/lib/src/mod.js";
import { IAM, RegistrationTypes, IRoleDefinition, NATS_EXCHANGE_TOPIC } from "../../src/iam-client-lib";
import { createIam, root, rootOwner } from "../iam.test";
import { claimManager, replenish } from "../setup_contracts";
Expand Down
2 changes: 1 addition & 1 deletion test/testUtils/mocks.ts
@@ -1,5 +1,5 @@
import { IRoleDefinition } from "@energyweb/iam-contracts";
import { JSONCodec } from "nats.ws";
import { JSONCodec } from "../../node_modules/nats.ws/lib/src/mod.js";
import { Claim } from "../../src/cacheServerClient/cacheServerClient.types";
import { IAM } from "../../src/iam";

Expand Down

0 comments on commit b4fd123

Please sign in to comment.