Skip to content

Commit

Permalink
Add vite dts plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Apr 18, 2024
1 parent ba5886a commit e47c91f
Show file tree
Hide file tree
Showing 4 changed files with 315 additions and 31 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"typescript-docs-verifier": "^2.5.0",
"vite-plugin-node-polyfills": "^0.21.0",
"vite-plugin-top-level-await": "^1.4.1",
"vite-plugin-dts": "^3.8.3",
"vite": "^5.2.9",
"vitest": "^1.5.0",
"vitest-when": "^0.3.1",
Expand Down
8 changes: 5 additions & 3 deletions packages/light-client/src/index.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export * from "./index.js";

// To kep the consistent interface as npm package and browser
// Use consistent names as named exports
export * as utils from "./utils/index.js";
export * as validation from "./validation.js";
export * as transport from "./transport/index.js";
import * as utils from "./utils/index.js";
import * as validation from "./validation.js";
import * as transport from "./transport/index.js";

export {utils, validation, transport};
15 changes: 4 additions & 11 deletions packages/light-client/test/unit/webEsmBundle.browser.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call */
import {expect, describe, it, beforeEach, vi} from "vitest";
import "../../dist/lightclient.min.mjs";
import {expect, describe, it, vi} from "vitest";
import {Lightclient, LightclientEvent, utils, transport} from "../../dist/lightclient.min.mjs";

describe("web bundle for lightclient", () => {
vi.setConfig({testTimeout: 10_000});

let lightclient: any;

beforeEach(() => {
lightclient = (window as any)["lodestar"]["lightclient"];
});

it("should have a global interface", () => {
expect(lightclient).toBeDefined();
expect((window as any)["lodestar"]["lightclient"]).toBeDefined();
});

it("should have all relevant exports", () => {
const lightclient = (window as any)["lodestar"]["lightclient"];
expect(lightclient).toHaveProperty("Lightclient");
expect(lightclient).toHaveProperty("LightclientEvent");
expect(lightclient).toHaveProperty("RunStatusCode");
Expand All @@ -29,8 +24,6 @@ describe("web bundle for lightclient", () => {
});

it("should start the lightclient and sync", async () => {
const {Lightclient, LightclientEvent, transport, utils} = lightclient;

const logger = utils.getConsoleLogger({logDebug: true});
const config = utils.getChainForkConfigFromNetwork("mainnet");

Expand Down
Loading

0 comments on commit e47c91f

Please sign in to comment.