The Nimiq Web Client ships with support for Webpack.
Update your webpack.config.js
to enable the asyncWebAssembly
:
module.exports = {
experiments: { // [!code ++]
asyncWebAssembly: true, // [!code ++]
}, // [!code ++]
}
Now you are ready to go!
const Nimiq = await import('@nimiq/core') // You need to use await import() to load the WebAssembly module
const config = new Nimiq.ClientConfiguration()
const client = await Nimiq.Client.create(config.build())
await client.waitForConsensusEstablished()
You need to use await import()
to load the WebAssembly module and also experiment in your config.