-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
Describe the bug
Hi! I am trying to setup SvelteKit with WASM (compiled using rollup-plugin-assemblyscript). My wasm-module loads on client using onMount hook:
onMount(async () => {
const wasmUrl = await import("asc:@/core/add.as");
WebAssembly.instantiateStreaming(fetch(wasmUrl)).then(({ instance }) =>
console.log(instance.exports.add(40, 2))
);
});After successful build I receive such error on client:
TypeError: Failed to construct 'URL': Invalid URL
at add-ff7f1bae.js:1
Inside generated add-*.js file:
const e = new URL("../assets/add-5e595341.wasm",{}.url).href;
export {e as default, e as wasmUrl};Looks like missing import.meta.url, but I'm not sure.
Reproduction
You can reproduce described error here:
https://github.com/stanf0rd/rasseki-game/tree/wasm-setup
Just
npm install
npm run build
npm previewand look into browser console on localhost:3000
Logs
Build logs:
> svelte-kit build
vite v2.5.10 building for production...
✓ 18 modules transformed.
.svelte-kit/output/client/_app/assets/add-5e595341.wasm 0.09 KiB
.svelte-kit/output/client/_app/manifest.json 1.73 KiB
.svelte-kit/output/client/_app/pages/__layout.svelte-b6ef297e.js 0.54 KiB / brotli: 0.31 KiB
.svelte-kit/output/client/_app/pages/index.svelte-893d5051.js 1.64 KiB / brotli: 0.71 KiB
.svelte-kit/output/client/_app/error.svelte-641ac797.js 1.56 KiB / brotli: 0.64 KiB
.svelte-kit/output/client/_app/chunks/add-ff7f1bae.js 0.09 KiB / brotli: 0.09 KiB
.svelte-kit/output/client/_app/chunks/preload-helper-ec9aa979.js 0.50 KiB / brotli: 0.28 KiB
.svelte-kit/output/client/_app/assets/start-61d1577b.css 0.16 KiB / brotli: 0.11 KiB
.svelte-kit/output/client/_app/assets/pages/__layout.svelte-dd72df29.css 0.16 KiB / brotli: 0.10 KiB
.svelte-kit/output/client/_app/assets/pages/index.svelte-1ecc56f5.css 0.96 KiB / brotli: 0.30 KiB
.svelte-kit/output/client/_app/chunks/vendor-af0f2ef7.js 6.98 KiB / brotli: 2.60 KiB
.svelte-kit/output/client/_app/start-6f9adcce.js 17.30 KiB / brotli: 5.51 KiB
vite v2.5.10 building SSR bundle for production...
✓ 18 modules transformed.
.svelte-kit/output/server/app.js 58.62 KiB
Run npm run preview to preview your production build locally.
> Using @sveltejs/adapter-node
✔ done
Client logs:
add-ff7f1bae.js:formatted:1 Uncaught (in promise) TypeError: Failed to construct 'URL': Invalid URL
at add-ff7f1bae.js:formatted:1
(anonymous) @ add-ff7f1bae.js:formatted:1
Promise.then (async)
i @ index.svelte-893d5051.js:1
(anonymous) @ index.svelte-893d5051.js:1
E.e @ index.svelte-893d5051.js:1
(anonymous) @ index.svelte-893d5051.js:1
e @ vendor-af0f2ef7.js:1
(anonymous) @ vendor-af0f2ef7.js:1
W @ vendor-af0f2ef7.js:1
rt @ vendor-af0f2ef7.js:1
W @ start-6f9adcce.js:1
_init @ start-6f9adcce.js:1
start @ start-6f9adcce.js:1
async function (async)
start @ start-6f9adcce.js:1
nt @ start-6f9adcce.js:1
(anonymous) @ (index):22System Info
System:
OS: macOS 11.6
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 2.26 GB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.9.1 - /usr/local/bin/node
npm: 7.21.1 - /usr/local/bin/npm
Browsers:
Chrome: 93.0.4577.82
Safari: 15.0
npmPackages:
@sveltejs/adapter-node: ^1.0.0-next.46 => 1.0.0-next.49
@sveltejs/kit: next => 1.0.0-next.171
svelte: ^3.34.0 => 3.43.0Severity
blocking all usage of SvelteKit
Additional Information
Looks similar with that case, but there was an error at build step with SSR feature.
#1896: Error "new URL(url, import.meta.url) is not supported in SSR." with ssr: false & adapter-static
Reactions are currently unavailable