-
Notifications
You must be signed in to change notification settings - Fork 42
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
[Web Client]: Error: [commonjs--resolver] Could not load @nimiq+core-web@2.0.0-alpha.20.3
. Unable to build Web Client.
#2374
Comments
@sisou If you are fine, I would also like to update the docs to have an easy copy-paste documentation. Something like this ViteInstallnpm install @nimiq/core-web@next vite-plugin-wasm vite-plugin-top-level-await Update config// vite.config.ts
import { defineConfig } from 'vite'
import wasm from 'vite-plugin-wasm'
import topLevelAwait from 'vite-plugin-top-level-await'
export default defineConfig({
plugins: [
wasm(),
topLevelAwait(),
],
optimizeDeps: {
exclude: ['@nimiq/core-web'],
},
}) I think it is much faster this than reading though the packages. Wdyt? |
Is this a bug report or solution report? The error tells you:
Does that work for you? |
I guess both. I am not sure if this is a bug or a documentation problem. Or maybe both.
That's the problem. I cannot apply that solution without patching the library. The lib fetches the wasm for me. Looking at the file from the lib async function __wbg_init(input) {
if (wasm !== undefined) return wasm;
if (typeof input === 'undefined') {
input = new URL('index_bg.wasm', import.meta.url);
}
const imports = __wbg_get_imports();
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
input = fetch(input);
}
__wbg_init_memory(imports);
const { instance, module } = await __wbg_load(await input, imports);
return __wbg_finalize_init(instance, module);
} So not sure how can I apply I only initialise the lib as shown in the docs. See my network store. When running |
OK, so your messaging is confusing for me. You report a problem and then in the next comment report how you'd update the documentation. But it doesn't actually work? I think for vite the |
Ok, thanks. It is working now. Something like this import init, { Client, ClientConfiguration, type ConsensusState } from '@nimiq/core-web/web'
let client: Client
async function startClient() {
await init()
const config = new ClientConfiguration()
config.network('devalbatross')
client = await Client.create(config.build())
} |
It works for in dev with that? Does it also still work after building and running from dist? |
I'm not sure if it works because testnet is down and I don't know how to test it (#2404). But it compiles, which is why I opened the issue. |
New issue checklist
README
General information
I am trying to build a web app with the new
@nimiq-core
web client.Bug report
Expected behavior
Build successfully.
Actual behavior
When running
pnpm build
I get an errorExpand to see error
Steps to reproduce
Question or Feature Request
I followed all the current instructions from the docs.
Maybe I miss a configuration option or something, but I might not be the only one, so instead of fixing the error in a private channel, I think is good to have the solution posted publicly.
Related libs
The text was updated successfully, but these errors were encountered: