ChainSafe / ChainSafe/lodestar-prover

Mixing of ESM and CJS dependencies

Open Beginner friendly
#10 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Nodejs does allow `cjs` and `esm` codebase only with synchronous [require](https://nodejs.org/api/esm.html#require).

> The CommonJS module require currently only supports loading synchronous ES modules (that is, ES modules that do not use top-level await).

Modern version of Vitest test to fully base on nodejs module resolution so causing this error.

```
Error: require() cannot be used on an ESM graph with top-level await. Use import() instead. To see where the top-level await comes from, use --experimental-print-required-tla.
From /lodestar/node_modules/@ethereumjs/ethash/dist/util.js
Requiring /lodestar/node_modules/bigint-crypto-utils/dist/index.node.esm.js
```

The reason is the use of very old version of `@@ethereumjs/*` packages in the `prover` package.

https://github.com/ChainSafe/lodestar/blob/688d5584ead0c6245007ece33175f6658169b662/packages/prover/package.json#L54-L61

The above issue can be fixed by upgrading these packages.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with packages/prover/package.json at the referenced dependency lines and inspect the current @ethereumjs/* versions. Reproduce the Vitest module-resolution error, upgrade the affected packages, and confirm the prover tests no longer fail with the ESM graph and top-level-await error.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.