Open odoe opened 3 years ago
I dug into this a bit to find that's it related to the web3 package requiring these
you can see this by adding the following to the top of a new app
import * as http from 'http';
console.info(http)
this looks like it's a result of - https://github.com/webpack/changelog-v5/blob/master/README.md#automatic-nodejs-polyfills-removed
by hacking @dojo/cli-build-app/config/dev.config.js and adding at line 107. the line above return config
config.node: { Buffer: true }
i was able to get my app to load.
I'd like to suggestion this change to src/dev.config.ts
and src/dist.config.ts
if (Array.isArray(args.polyfills)) {
config.node = args.polyfills.reduce(
(polyfills: webpack.Node, module: string) => {
polyfills[module] = true;
return polyfills;
},
{} as webpack.Node
);
}
so one could then add this to their .dojorc
file so resolve this issue.
{
'build-app': { node: [ 'Buffer' ] }
}
my first stab (i couldn't get the linter to not complain about using reduce) https://github.com/dojo/cli-build-app/commit/a62b866a0001eb68c6012cf4583b1e2010ef1822
why?
.dojorc
nothing happens, so unless one really needs it nothing happens. this seem in line with externals
.
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 thepackage-lock.json
andnode_modules
, I get a build time error.Package Version: 7.0 & 7.0.5
Code
sample repo
Expected behavior:
I would expect a build without errors and a workflow to build a Dapp with Dojo.
Actual behavior:
Node Version: 14.16.0 NPM Version: 6.17.11