ethers and rollup
See original GitHub issueHey, I want to use ethers (v5) in a rollup based web app and I am hitting a few warning and I am not sure if there are issues :
(!) Missing shims for Node.js built-ins
Creating a browser bundle that depends on 'http', 'https' and 'url'. You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins
LiveReload enabled
(!) `this` has been rewritten to `undefined`
https://rollupjs.org/guide/en/#error-this-is-undefined
node_modules\@ethersproject\contracts\lib.esm\index.js
1: "use strict";
2: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
^
3: function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4: return new (P || (P = Promise))(function (resolve, reject) {
...and 1 other occurrence
node_modules\@ethersproject\providers\lib.esm\base-provider.js
1: "use strict";
2: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
^
3: function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4: return new (P || (P = Promise))(function (resolve, reject) {
...and 1 other occurrence
node_modules\@ethersproject\providers\lib.esm\cloudflare-provider.js
1: "use strict";
2: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
^
3: function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4: return new (P || (P = Promise))(function (resolve, reject) {
...and 1 other occurrence
...and 10 other files
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
http (imported by node_modules\@ethersproject\web\lib.esm\geturl.js)
url (imported by node_modules\@ethersproject\web\lib.esm\geturl.js)
https (imported by node_modules\@ethersproject\web\lib.esm\geturl.js)
(!) Missing global variable names
Use output.globals to specify browser global variable names corresponding to external modules
http (guessing 'http')
https (guessing 'https')
url (guessing 'url$1')
created dist\build\bundle.js in 6.5s
When I use
rollup-plugin-node-builtins
in an attempt to fix the warning about http/https/url
I get the following error :
[!] Error: 'URL' is not exported by node_modules\rollup-plugin-node-builtins\src\es6\url.js, imported by node_modules\@ethersproject\web\lib.esm\geturl.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
node_modules\@ethersproject\web\lib.esm\geturl.js (13:9)
11: import http from "http";
12: import https from "https";
13: import { URL } from "url";
^
14: import { Logger } from "@ethersproject/logger";
15: import { version } from "./_version";
Error: 'URL' is not exported by node_modules\rollup-plugin-node-builtins\src\es6\url.js, imported by node_modules\@ethersproject\web\lib.esm\geturl.js
Any idea?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Ethers and Rollup · Issue #1179 · ethers-io/ethers.js - GitHub
Hello, I am struggling to get ethers.js to work with rollup. The specific error that I am encountering in browser is: Uncaught SyntaxError: ......
Read more >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 ... To summarize, a rollup takes a batch...
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 >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
Hey @wighawag would you mind sharing your rollup config? Also trying to use rollup
Cool, that was the mainFields thing, thanks!