-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use taquito with vite #1729
Comments
Thanks @itsnamangoyal |
ty @Innkst |
I made Taquito and the Beacon wallet work with Vite in this repo: https://github.com/claudebarde/taquito-bundlers-testing/tree/main/vitejs |
Still not fixed, I guess this could be due to the fact your repo is using taquito 11.x while I'm trying to use 13.x Also, I'm using react but that most probably is not the issue here |
@itsnamangoyal what about vite version? |
Sorry for late reply |
some news? |
Interestingly, I do get the |
@claudebarde what version of taquito, beacon sdk and vite you use? |
|
@claudebarde can you share vite config please? |
This is my
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import svgrPlugin from 'vite-plugin-svgr'
import path from 'path'
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import replace from 'rollup-plugin-re'
// https://vitejs.dev/config/
export default ({ command }) => {
const isBuild = command === 'build'
return defineConfig({
build: {
outDir: 'build',
emptyOutDir: true,
},
plugins: [
react(),
svgrPlugin({ svgrOptions: { icon: true } }),
{
...replace({
include: ['node_modules/@airgap/**', 'node_modules/@taquito/**'],
replaces: {
...(isBuild
? {
"import * as qrcode from 'qrcode-generator';":
"import qrcode from 'qrcode-generator';",
}
: {
'var libsodium_wrappers_1 = require("libsodium-wrappers")':
'var libsodium_wrappers_1 = require("libsodium-wrappers").default',
}),
},
}),
apply: 'build',
enforce: 'pre',
},
],
optimizeDeps: {
esbuildOptions: {
define: {
global: 'globalThis',
},
plugins: [
NodeGlobalsPolyfillPlugin({
buffer: true,
process: true,
}),
],
},
},
resolve: {
alias: [
{ find: '@', replacement: path.resolve(__dirname, 'src') },
{
find: '@airgap/beacon-sdk',
replacement: path.resolve(
__dirname,
`./node_modules/@taquito/beacon-wallet/node_modules/@airgap/beacon-sdk/dist/${
isBuild ? 'esm' : 'cjs'
}/index.js`
),
},
{
find: 'readable-stream',
replacement: 'vite-compatible-readable-stream',
},
{
find: 'stream',
replacement: 'vite-compatible-readable-stream',
},
],
},
})
} |
@RohitKaushal7 you should remove |
@souljorje I tried removing optimizeDeps: {
include: [
'@airgap/beacon-sdk',
'@taquito/beacon-wallet',
'@taquito/taquito',
],
} tried clearing cache. but same problem still persists. |
@RohitKaushal7 what is you vite versions? did you provide a full vite.config.js? |
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import svgrPlugin from 'vite-plugin-svgr'
import path from 'path'
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import replace from 'rollup-plugin-re'
// https://vitejs.dev/config/
export default ({ command }) => {
const isBuild = command === 'build'
return defineConfig({
build: {
outDir: 'build',
emptyOutDir: true,
},
plugins: [
react(),
svgrPlugin({ svgrOptions: { icon: true } }),
{
...replace({
include: ['node_modules/@airgap/**', 'node_modules/@taquito/**'],
replaces: {
...(isBuild
? {
"import * as qrcode from 'qrcode-generator';":
"import qrcode from 'qrcode-generator';",
}
: {
'var libsodium_wrappers_1 = require("libsodium-wrappers")':
'var libsodium_wrappers_1 = require("libsodium-wrappers").default',
}),
},
}),
enforce: 'pre',
},
],
optimizeDeps: {
include: [
'@airgap/beacon-sdk',
'@taquito/beacon-wallet',
'@taquito/taquito',
],
esbuildOptions: {
define: {
global: 'globalThis',
},
plugins: [
NodeGlobalsPolyfillPlugin({
buffer: true,
process: true,
}),
],
},
},
resolve: {
alias: [
{ find: '@', replacement: path.resolve(__dirname, 'src') },
{
find: '@airgap/beacon-sdk',
replacement: path.resolve(
__dirname,
`./node_modules/@airgap/beacon-sdk/dist/${
isBuild ? 'esm' : 'cjs'
}/index.js`
),
},
{
find: 'readable-stream',
replacement: 'vite-compatible-readable-stream',
},
{
find: 'stream',
replacement: 'vite-compatible-readable-stream',
},
],
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "./src/styles/common.scss" as *;`,
},
},
},
})
}
"vite": "^2.7.2", // 2.9.5
"@airgap/beacon-sdk": "^3.0.0", // 3.0.0
"@taquito/beacon-wallet": "^13", // 13.0.1
"@taquito/taquito": "^12", // 12.0.3 , 13.0.1
|
@souljorje do you know what is wrong with the package, can I manually fix it by changing the code in the node module itself using |
@RohitKaushal7 busy to explain right now and actually I kinda forgot what's wrong, will try answer later, for now I can say that this setup works on dev and on prod:
Also we have some diffs in build: {
target: 'esnext',
commonjsOptions: {
transformMixedEsModules: true,
},
},
optimizeDeps: {
esbuildOptions: {
target: 'es2021',
},
}, |
@souljorje can you create template with vite that works with airgab/taquito? |
@xsfunc I'll post a template tomorrow for Vite + Taquito/Beacon as I have a working dapp with that configuration |
@xsfunc in case if @claudebarde's template won't work, I'll post mine |
@claudebarde where I can see your template? taquito@14 Still not working for me. If I use only beacon sdk with upd: |
If someone is getting error -
while connecting to beacon wallet after building the app. add dependency
in the end ... You should at least have |
Thre is nothing here to be fixed |
Description
Can't connect to a wallet in vite.
Steps To Reproduce
Steps to reproduce the behavior:
Expected behavior
We should be able to connect to wallet without error
Screenshots
![image](https://user-images.githubusercontent.com/43905880/177401425-a3f8fa66-507c-4494-8646-8bc247b70ee0.png)
Desktop (please complete the following information):
Additional context
It works correctly in with CRA.
The text was updated successfully, but these errors were encountered: