Open Elliott-Green opened 4 months ago
@Elliott-Green I was able to get it up and running with the following steps: First, ensure you have @rollup/plugin-commonjs installed:
npm install @rollup/plugin-commonjs --save-dev
Then, include it in your Vite configuration:
import commonjs from '@rollup/plugin-commonjs';
// Inside your Vite config
const config: UserConfig = {
plugins: [
sveltekit(),
commonjs({
include: /node_modules/ // Only transpile CommonJS modules from node_modules
}),
// Your other plugins...
],
// Your other config options...
};
Can you give that a try and let me know?
PR to get the example working : https://github.com/blocknative/web3-onboard/pull/2086
Hey @Adamj1232,
Thanks for looking into this.
I've picked the changes up from #2086 but alas, I'm still having the same issues.
Did you ever get a vercel deployment out for 2086? build+preview work locally, so looks ok, but will error on vercel.
Had a few other local issues that I managed to resolve, would recommend these packages get updated as they've been patched to work nicely with commonJS - or something, I have no idea, this side of js is a black box to me.
4:05:42 PM [vite] Error when evaluating SSR module /node_modules/@web3-onboard/core/node_modules/svelte-i18n/dist/runtime.esm.js: failed to import "intl-messageformat"
|- SyntaxError: [vite] Named export 'IntlMessageFormat' not found. The requested module 'intl-messageformat' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'intl-messageformat';
const {IntlMessageFormat} = pkg;
By overriding some of the package versions, I am able to resolve some of my build issues like:
"overrides": {
"@web3-onboard/core": {
"svelte-i18n": "^4.0.0",
"intl-messageformat": "^10.5.1",
"bnc-sdk": {
"rxjs": "^7.8.1"
}
},
"@web3-onboard/coinbase": {
"@coinbase/wallet-sdk": {
"rxjs": "^7.8.1"
}
},
// Not sure about this one, trying to fix atm
"@web3-onboard/trezor": {
"@ethereumjs/tx": "^5.2.1",
"eth-crypto": {
"@ethereumjs/tx": "^5.2.1"
}
}
}
https://stackoverflow.com/questions/77193468/syntaxerror-when-building-sveltekit-the-requested-module-intl-messageformat-i https://github.com/kaisermann/svelte-i18n/issues/232
error during build:
RollupError: [vite-plugin-sveltekit-compile] node_modules/eth-crypto/dist/es/sign-transaction.js (1:9): "Transaction" is not exported by "node_modules/eth-crypto/node_modules/@ethereumjs/tx/dist.browser/index.js", imported by "node_modules/eth-crypto/dist/es/sign-transaction.js".
file: /Users/elliott/Documents/GitHub/5725Cafe/node_modules/eth-crypto/dist/es/sign-transaction.js:1:9
1: import { Transaction } from '@ethereumjs/tx';
^
2: import { publicKeyByPrivateKey } from './public-key-by-private-key';
3: import { toAddress as addressByPublicKey } from './public-key';
file: /Users/elliott/Documents/GitHub/5725Cafe/node_modules/eth-crypto/dist/es/sign-transaction.js:1:9
1: import { Transaction } from '@ethereumjs/tx';
^
2: import { publicKeyByPrivateKey } from './public-key-by-private-key';
3: import { toAddress as addressByPublicKey } from './public-key';
Current Behavior
Deploying the sveltekit example repo here https://github.com/blocknative/web3-onboard/tree/main/examples/with-sveltekit to vercel causes an error
Expected Behavior
Deploying to vercel should return no error.
Steps To Reproduce
https://github.com/Elliott-Green/sk-web3-vercel-minrepo OR https://github.com/blocknative/web3-onboard/tree/main/examples/with-sveltekit
git clone https://github.com/Elliott-Green/sk-web3-vercel-minrepo.git npm i npm run build npm run preview git commit -m "[chore] poke build" vercel builds, errors with log
What package is effected by this issue?
@web3-onboard/core
Is this a build or a runtime issue?
Build
Package Version
2.21.0
Node Version
20.10.0
What browsers are you seeing the problem on?
Firefox
Relevant log output
Anything else?
No response
Sanity Check