Arweave-JS doesn't currently work with Webpack 5 in the browser
See original GitHub issueCurrently, importing Arweave-JS in a browser based project that uses Webpack 5 will result in a build-time error of the below sort: ERROR in ./node_modules/arweave/web/lib/merkle.js 9:15-30 Module not found: Error: Can’t resolve ‘util’ in ‘/home/jim/development/monkeys1/node_modules/arweave/web/lib’
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.
This can be worked around at present by adding the below to webpack.configs.js
:
module.exports = {
...
plugins: [
//Polyfill needed nodejs plugins for Arweave-js
new webpack.ProvidePlugin({
process: 'process/browser',
}), new webpack.ProvidePlugin({
util: 'util/',
}),
...
}
and then npm i --save-dev util process
to add these two node-js polyfill libraries to a given project.
Ideally, these dependencies would be resolved by browser-compatible imports within arweave/web//lib/merkle
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:11 (5 by maintainers)
Top GitHub Comments
Hi @fewwwww. Yes it should be working. Here’s a demo: https://github.com/hzhu/ar-cra-demo
Hi hzhu, how did you solve it? I just cannot make it working with vanilla cra……