Svelte App build error
See original GitHub issueBuilding Svelte App with rollup fails, even with example (https://codesandbox.io/s/jekzo)
First error :
$ npm run build
...
[!] Error: Unexpected token (Note that you need @rollup/plugin-json to import JSON files)
node_modules/.pnpm/@ensdomains+ens@0.4.3/node_modules/@ensdomains/ens/build/contracts/ENS.json (2:16)
1: {
2: "contractName": "ENS",
^
3: "abi": [
4: {
Error: Unexpected token (Note that you need @rollup/plugin-json to import JSON files)
After adding @rollup/plugin-json , new error :
[!] Error: 'toBuffer' is not exported by node_modules/.pnpm/ethereumjs-util@7.1.0/node_modules/ethereumjs-util/dist/index.js, imported by node_modules/.pnpm/bnc-onboard@1.31.0/node_modules/bnc-onboard/dist/esm/index-9156d65a.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
node_modules/.pnpm/bnc-onboard@1.31.0/node_modules/bnc-onboard/dist/esm/index-9156d65a.js (35:9)
33: import 'bowser';
34: import '@ensdomains/ensjs';
35: import { toBuffer } from 'ethereumjs-util';
^
36: var HANDLE_PIN_PRESS = 'handlePinPress';
37: var BUTTON_COLOR = "#EBEBED";
Issue Analytics
- State:
- Created 2 years ago
- Comments:17 (1 by maintainers)
Top Results From Across the Web
How can I fix this error when trying to deploy my svelte app on ...
I am trying to deploy my svelte app on GitHub Pages and cannot get rid of these errors I get from running 'npm...
Read more >Errors • Docs • SvelteKit
Errors are an inevitable fact of software development. SvelteKit handles errors differently depending on where they occur, what kind of errors they are, ......
Read more >Build error starting with version 171 · Issue #2912 · sveltejs/kit
Describe the bug I am getting the following error when building, starting with version 171: > Using @sveltejs/adapter-node ...
Read more >Build error when trying to deploy SvelteKit app - Support
I'm getting this error when trying to deploy my SvelteKit app. ENOENT: no such file or directory, open 'build/_redirects'.
Read more >How to build a simple Svelte app - LogRocket Blog
In addition to logging Redux actions and state, LogRocket records console logs, JavaScript errors, stacktraces, network requests/responses with ...
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 Free
Top 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
Hey all,
Apologies for all the issues trying to get Onboard working nicely with Svelte. We use Svelte internally at Blocknative for all of our frontends, so we’d love to improve the developer experience here.
The main issue is that bundlers like Rollup, Vite and Snowpack (which are all commonly used with Svelte) don’t have good support for bundling in the node builtins, especially the
crypto
module. A lot of the wallets we support need these builtins to work correctly and that is what is causing a lot of the errors.We are actively working on a V2 of Onboard which (among other features) will separate all of the wallets in to it’s own mono repo with all of the packages so that we can isolate these dependency problems from the main library. We are also going to go through and reduce and hopefully remove the node builtin dependencies if possible or bundle the necessary deps in with the wallet modules.
In the meantime I have a working template repo for Svelte that you can check out. It uses Webpack 4 as the bundler. It seems to be a lot more difficult to bundle the node builtins in Webpack 5 so I couldn’t get that working at the moment.
Okay, so I installed web3-onboard and pasted the sveltekit config. The modal works, but I ran into a number of issues. Some were fixed in last night’s update, but two app breaking issues remained.
Here is a repository I made just for this https://github.com/jakubdonovan/web3-onboard-svelte
1: The app fails to build with npm run build
Lastly, adding ledger, trezor, or gnosis all results in the following error