eth-infinitism/bundler

clientVersion breaks webpack

skypigr opened this issue · 1 comments

How to reprodcue

  1. sync to v0.4.0
  2. at repo root, run yarn && yarn preprocess
  3. go to dockers/bundler and run ./dbuild.sh

The webpack command will throw an error as below:

✨  Done in 17.00s.
version=0.4.0
../../packages/bundler/src//types/hardhat.d.ts
../../packages/bundler/src//types/contracts/BundlerHelper.ts
webpacking..
ERROR in ../../packages/bundler/dist/src/UserOpMethodHandler.js 188:31-65
Module not found: Error: Can't resolve '../package.json' in '/Users/<user>/Documents/projects/eth-infinitism/bundler/packages/bundler/dist/src'
 @ ../../packages/bundler/dist/src/runBundler.js 14:30-62
 @ ../../packages/bundler/dist/src/exec.js 3:21-44

Root Cause: Path Resolution

Checking file UserOpMethodHandler.ts, the implementation of clientVersion() depends on the module's package.json, however, after been compiled to UserOpMethodHandler.js, there is no package.json anymore at its parent folder.

  clientVersion (): string {
    // eslint-disable-next-line
    return 'aa-bundler/' + require('../package.json').version
  }`

Solution

Maybe we should just hard code the version in clientVersion()?

fixed.