Skip to content

Commit

Permalink
Update the build process
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Apr 19, 2024
1 parent d4279de commit 67204f0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 27 deletions.
3 changes: 2 additions & 1 deletion packages/api/src/beacon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type {Api} from "./routes/index.js";

// NOTE: Don't export server here so it's not bundled to all consumers

export * as routes from "./routes/index.js";
import * as routes from "./routes/index.js";
export {routes};
export {getClient} from "./client/index.js";
export type {Api};

Expand Down
6 changes: 1 addition & 5 deletions packages/api/src/beacon/routes/beacon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import * as rewards from "./rewards.js";

// NOTE: We choose to split the block, pool, and state namespaces so the files are not too big.
// However, for a consumer all these methods are within the same service "beacon"

export * as block from "./block.js";
export * as pool from "./pool.js";
export * as state from "./state.js";
export * as rewards from "./rewards.js";
export {block, pool, state, rewards};
export {BroadcastValidation} from "./block.js";
export type {BlockId, BlockHeaderResponse} from "./block.js";
export type {AttestationFilters} from "./pool.js";
Expand Down
19 changes: 10 additions & 9 deletions packages/api/src/beacon/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import {Api as NodeApi} from "./node.js";
import {Api as ProofApi} from "./proof.js";
import {Api as ValidatorApi} from "./validator.js";

export * as beacon from "./beacon/index.js";
export * as config from "./config.js";
export * as debug from "./debug.js";
export * as events from "./events.js";
export * as lightclient from "./lightclient.js";
export * as lodestar from "./lodestar.js";
export * as node from "./node.js";
export * as proof from "./proof.js";
export * as validator from "./validator.js";
import * as beacon from "./beacon/index.js";
import * as config from "./config.js";
import * as debug from "./debug.js";
import * as events from "./events.js";
import * as lightclient from "./lightclient.js";
import * as lodestar from "./lodestar.js";
import * as node from "./node.js";
import * as proof from "./proof.js";
import * as validator from "./validator.js";
export {beacon, config, debug, events, lightclient, lodestar, node, proof, validator};

export type Api = {
beacon: BeaconApi;
Expand Down
5 changes: 5 additions & 0 deletions packages/light-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ NOTE: Due to `top-level-await` used in one of dependent library, the package wil
}, 50);
});
</script>

**Typescript support**

The web bundle comes with the types support. Unfortunately due to following [issue](https://github.com/microsoft/rushstack/issues/1128#issuecomment-2066257538) we can't bundle all types. A workaround would be to add `@chainsafe/as-sha256` as a devDependency to your project.

```

## Contributors
Expand Down
7 changes: 4 additions & 3 deletions packages/light-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ export class Lightclient {
}

// To export these name spaces to the bundle JS
export * as utils from "./utils.js";
export * as validation from "./validation.js";
export * as transport from "./transport.js";
import * as utils from "./utils.js";
import * as validation from "./validation.js";
import * as transport from "./transport.js";
export {utils, validation, transport};
12 changes: 3 additions & 9 deletions packages/light-client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@ export default mergeConfig(
defineConfig({
plugins: [
dts({
entryRoot: "src",
// It would be better to rollup all types into one file, But the current package.json.types field
// is pointing to other file that conflict with the entry file for bundle. If we decide to use one
// entry file for both package and bundle then this issue could be resolved
//
rollupTypes: false,
bundledPackages: ["@lodestar/*", "@chainsafe/*"],
exclude: ["test/**/*", "*.config.ts"],
rollupTypes: true,
bundledPackages: ["@lodestar/*", "@chainsafe/persistent-merkle-tree", "@chainsafe/bls", "@chainsafe/ssz"],
async afterBuild() {
await fs.rename(
path.join(import.meta.dirname, "dist", "index.browser.d.ts"),
path.join(import.meta.dirname, "dist", "index.d.ts"),
path.join(import.meta.dirname, "dist", "lightclient.min.d.mts")
);
},
Expand Down

0 comments on commit 67204f0

Please sign in to comment.