Skip to content

Doesn't handle SvelteKit w/ changed base path #38

Open
@SenojLuap

Description

Describe the bug
When setting up the project as described in the Readme (onto a SvelteKit app), the application will not execute if the svelte config specifies an alternate base path:

svelte.config.js:

import adapter from '@sveltejs/adapter-auto';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	kit: {
		adapter: adapter(),
		paths: {
			base: '/subfolder'
		}
	}
};

export default config;

To Reproduce
Steps to reproduce the behavior:

  1. Create new SvelteKit project via 'npm create svelte@latest '
  2. Modify svelte.config.js as shown above (just set a base path).
  3. Follow steps as descibed in Readme to setup vite-plugin-rsw and create the default crate
  4. Start dev server with 'npm run dev'

Expected behavior
The dev server should correctly resolve the WASM module to its actual location; not adjusted by base path.

Screenshots
Not a screen shot, but here's the error I'm getting:

[1] Failed to load url /rsw-hello/pkg/rsw_hello.js (resolved id: D:/Git/demo-wasm/rsw-hello/pkg/rsw_hello.js). Does the file exist?
[1] Failed to load url /rsw-hello/pkg/rsw_hello.js (resolved id: D:/Git/demo-wasm/rsw-hello/pkg/rsw_hello.js). Does the file exist?
[1] Error: Not found: /subfolder/rsw-hello/pkg/rsw_hello.js
[1]     at resolve (/node_modules/@sveltejs/kit/src/runtime/server/respond.js:395:13)
[1]     at resolve (/node_modules/@sveltejs/kit/src/runtime/server/respond.js:236:5)
[1]     at #options.hooks.handle (/@fs/D:/Git/demo-wasm/node_modules/@sveltejs/kit/src/runtime/server/index.js:41:55)
[1]     at Module.respond (/node_modules/@sveltejs/kit/src/runtime/server/respond.js:233:40)
[1]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Note that the two URLs at the top (D:/Git/demo-wasm/rsw-hello/pkg/rsw_hello.js) are actually correct, and I've confirmed that the files actually are there.

Desktop (please complete the following information):

  • Windows 10
  • Firefox
  • vite-plugin-rsw: 2.0.11, vite: 4.04, @sveltejs/kit: 1.3.1

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions