My project has a folder named kaspa
that was placed at the root directory. That folder are already been built by external parties so it must be left as is when running pnpm build
.
I have set these options on my config file
nitro: {
esbuild: {
options: {
target: 'esnext',
exclude: ['kaspa/kaspa.js', 'kaspa/kaspa_bg.wasm'],
},
},
},
vite: {
optimizeDeps: {
include: ['kaspa/kaspa.js'],
exclude: ['kaspa/kaspa_bg.wasm'],
},
},
as well as adding a .nuxtconfig
file with the same content:
kaspa/kaspa.js
kaspa/kaspa_bg.wasm
But it doesn't work.
Nuxt keeps rebuilding it, and compiled it as .nuxt/dist/server/_nuxt/kaspa-CvShH_pb.js
. I don't want this because it replaces the classes to a minified object that causes this kind of error:
object constructor `et` does not match expected class `Resolver`
class Resolver
itself is part of kaspa.js
. What can I do to make this work?
EDIT
To make it clear, I've attached a code snipped how kaspa
was used in the project; it is consumed inside a pinia store.
import * as kaspa from '~/kaspa/kaspa'
export const useKaspaStore = defineStore('kaspa', () => {
const rpc = shallowRef<kaspa.RpcClient>()
const init = async () => {
await kaspa.default()
rpc.value = new kaspa.RpcClient({
encoding: kaspa.Encoding.Borsh,
networkId: networkId.value,
resolver: new kaspa.Resolver(),
})
await rpc.value.connect()
}
}
This pinia store are then consumed by a layout.