softwarecurator / svelte-wagmi

71 stars 8 forks source link

buffer is not defined #1

Closed chtmorris closed 1 year ago

chtmorris commented 1 year ago

Great package - I really want to get this working!

I started a new project and added added this package. Builds fine, but the site fails to load. In the browser console I get the error:

Uncaught ReferenceError: buffer is not defined at main.js:9:2

softwarecurator commented 1 year ago

going to rebuilt some core functionality of this package soon but for it to build properly as is you must resolve your buffer on build in your vite config

softwarecurator commented 1 year ago

did some rework on the package try version 0.3.0! need to install peer dependencies viem and @wagmi/core

chtmorris commented 1 year ago

hmmm. I have just tried v 0.3.0, but I'm getting the same result that buffer is not defined. viem and @wagmi/core are both installed.

Any other ideas?

softwarecurator commented 1 year ago

it will using polyfills or setting your buffer in vite config

softwarecurator commented 1 year ago

@chtmorris

import { sveltekit } from '@sveltejs/kit/vite';

/** @type {import('vite').UserConfig} */
const config = {
    plugins: [sveltekit()],
    resolve: {
        alias: {
            stream: 'stream-browserify',
            util: 'util/',
            buffer: 'buffer/'
        }
    },
};

export default config;

this is myvite.config file for a random project maybe this may be of help you might want to try NodePolyfills if this doesn't help

chtmorris commented 1 year ago

So I'm an idiot and was trying to do this in a Svelte app and not a SvelteKit app. Now using SvelteKit and not having this buffer issue!

Thanks for your help!