dojo / dojo/cli-build-app

Builds fail with web3

Open
#457 3 comments 0 reactions 0 assignees View on GitHub
discussion
Dominant language
TypeScript
Stars
9
Forks
28
PR merge metrics
No merged PRs in 30d

Description

**Bug / Enhancement**

I was trying to use `web3` in a Dojo app, but I get some odd errors.

With a vanilla `dojo create app --name dojo-web3 --tsx`, it will build but throws a runtime error. If I delete the `package-lock.json` and `node_modules`, I get a build time error.

Package Version: 7.0 & 7.0.5

**Code**

```ts
import Web3 from 'web3';

import routes from './routes';
import App from './App';

const registry = new Registry();
registerRouterInjector(routes, registry);

// this could be window.ethereum if a wallet browser installed
const web3 = new Web3('ws://localhost:8546');
```

[sample repo](https://github.com/odoe/dojo-web3-error)

**Expected behavior:**

I would expect a build without errors and a workflow to build a Dapp with Dojo.

**Actual behavior:**

```
// dojo vanilla install
// builds no errors, fails in the browser
util.js:103 Uncaught (in promise) ReferenceError: Buffer is not defined
at Object../node_modules/core-util-is/lib/util.js (util.js:103)
at __webpack_require__ (bootstrap:68)
at Object. (_stream_readable.js:67)
at Object../node_modules/readable-stream/lib/_stream_readable.js (main.js:49474)
at __webpack_require__ (bootstrap:68)
at Object../node_modules/readable-stream/readable-browser.js (readable-browser.js:1)
at __webpack_require__ (bootstrap:68)
at Object. (response.js:3)
at Object../node_modules/stream-http/lib/response.js (response.js:224)
at __webpack_require__ (bootstrap:68)

// dojo after delete package-lock.json and node_modules and reinstall
./node_modules/stream-browserify/index.js
Module not found: Error: Can't resolve 'readable-stream/duplex.js' in '/home/odoe/dev/block
chain-dev/dojo-web3/node_modules/stream-browserify'
resolve 'readable-stream/duplex.js' in '/home/odoe/dev/blockchain-dev/dojo-web3/node_module
s/stream-browserify'
Parsed request is a module
using description file: /home/odoe/dev/blockchain-dev/dojo-web3/node_modules/stream-brows
erify/package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
looking for modules in /home/odoe/dev/blockchain-dev/dojo-web3

```

Node Version: 14.16.0
NPM Version: 6.17.11

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.