Ethers and Rollup
See original GitHub issueHello,
I am struggling to get ethers.js to work with rollup.
The specific error that I am encountering in browser is:
Uncaught SyntaxError: The requested module './../../../bn.js/lib/bn.js' does not provide an export named 'default'
Here is a repo to reproduce the error: https://github.com/GradientCap/Graph
Rollup config: https://github.com/GradientCap/Graph/blob/main/rollup.config.js
I’ve tried setting mainfields and using the commonjs plugin configuration from the ethers repo to no avail.
Any help would be appreciated.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:13 (3 by maintainers)
Top Results From Across the Web
What Are Rollups? ZK Rollups and Optimistic Rollups Explained
Rollups process transactions on another, faster blockchain (known as a ... with ether (ETH) or ERC-20 tokens – tokens that are compliant ...
Read more >Optimistic Rollups | ethereum.org
An optimistic rollup is an approach to scaling Ethereum that involves moving computation and state storage off-chain. Optimistic rollups execute transactions ...
Read more >Ethereum: a beginner-ish guide to Rollups | by Raphael Meyer
A basic transfer of Ether cost about $5 in November 2021, while a DeFi transaction (Uniswap for example) can cost more than $100....
Read more >Contributing and Hacking - ethers
The ethers.js library is something that I've written out of necessity, ... several intermediate builds, scripts and for various rollup scripts to execute....
Read more >Ethereum Rollups Explained - Liquid Blog
Rollups process all the computational works of a transaction in their ... is and how it can affect the blockchain and the value...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll add here that I did just a quick experiment by going to
node_modules
andbn.js
package where I patchedpackage.config
to have"module": "lib/bn.esm.js"
, created a file with that name and copy-pasted the contents ofbn.js
to there and echanged the module export toexport default { BN }
and it compiled. Another idea could something likeimport BN from "bn.js";
->import * as _BN from "bn.js";
and doing it to all modules that import like that, but it wouldn’t work on runtime.There’s more links in the SO thread, but it looks to me RollupJS checks
module
field and due to recent changed it may be@rollup/plugin-commonjs
does not catch the CJS module exports in the files and so consequently they are not transpiled to ESM ones in expeced format.I am not sure how laborious would it be to turn the file into ES modules locally and add default exports, but maybe I try later next week. Looking quickly at packages, most are maintained by @ricmoo already or have a TS/Rollup builds that just do not provide ES builds yet. 😃 (As an aside, it appears to be web advocates from communities like lit.dev, open-wc etc. note to provide ES6 builds with modern code and let users to transpile if they need specific polyfills etc.)
Once the beta of v6 is out, I would love wools to experiment with various bundlers. I personally only use rollup (you can check out the various rollup configs in the project for some ideas if you are having problems) and webpack as part of the ReactNative tests.