Skip to content

Incorrect Paths generated when using paths.relative: true in SPAs #10235

@Giggiux

Description

@Giggiux

Describe the bug

As suggested in #595, I attempted to use kit.paths.relative: true to enable my Single Page Application (SPA) to load from any path. However, upon building the application, I noticed that the output in the build folder contains only absolute paths.

This issue only occurs when ssr = false and there are no pre-rendered pages. If there is at least one pre-rendered page, the paths are indeed relative (./ on the scripts, and base: new URL(".", location).pathname.slice(0, -1)).

My use case is somewhat specialized: I am attempting to build a Twitch Extension, which technically operates as a static website. Hence, I need my app to be an SPA.
Twitch extensions encounter a similar issue to IPFS: one doesn't know the base path until the extension is opened on the site. The URL is composed like so: [extension-host-domain]/[twitch-extension-id]/[extension-version]/[upload-id], with the last upload-id being the unknown variable. This is my understanding based on the documentation and inspection.

From my interpretation of #595, the kit.paths.relative: true configuration should have resolved this issue, but it appears not to function as expected. I also tried using sveltekit-adapter-ipfs, but without success (I am dealing with a separate issue related to a missing paths- file).

I have created a simple repository where pnpm build generates these incorrect paths.

Perhaps I am making a mistake, but I cannot understand what it is.

Regards,
Luigi

Reproduction

https://github.com/Giggiux/reproduce-no-ssr-relative

Logs

No response

System Info

System:
    OS: macOS 13.4.1
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 15.44 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/.volta/tools/image/node/18.16.0/bin/node
    Yarn: 3.5.1 - ~/.volta/tools/image/yarn/3.5.1/bin/yarn
    npm: 9.6.6 - ~/.volta/tools/image/npm/9.6.6/bin/npm
  Browsers:
    Brave Browser: 114.1.52.126
    Chrome: 114.0.5735.133
    Safari: 16.5.1
  npmPackages:
    @sveltejs/adapter-auto: ^2.0.0 => 2.1.0
    @sveltejs/adapter-static: ^2.0.2 => 2.0.2
    @sveltejs/kit: ^1.20.4 => 1.20.5
    svelte: ^4.0.0 => 4.0.0
    vite: ^4.3.6 => 4.3.9

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions