-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Incorrect Paths generated when using paths.relative: true
in SPAs
#10235
Comments
I believe I'm running into this issue as well, but not 100% sure. It seems that on the generated SPA landing page, the initial imports are just wrong? I believe in the hydration below, that /_app w/ relative paths should be {
__sveltekit_7kovfn = {
base: "",
env: {}
};
const element = document.currentScript.parentElement;
Promise.all([
import("/_app/immutable/entry/start.5b4385b2.js"),
import("/_app/immutable/entry/app.75bcc3d0.js")
]).then(([kit, app]) => {
kit.start(app, element);
});
} |
If it can be useful, @npeeples, I've worked around it by creating a random page (literally, into Using the same file for fallback doesn't work, and without the pre-rendered page doesn't work either. |
@Giggiux appreciate that, that does the trick for the spa build files. Still need to track down if it's possible to accomplish a workaround on the |
Also having this issue still. The workaround did work for me though. |
Adding this to the 2.0 milestone in the sense of "look into this" - if we're changing the default to be |
It sounds like the issue here is that absolute paths are being generated when relative paths are expected, but that the app is still functioning. Assuming I got that correct, I probably wouldn't call this a 2.0 blocker and would say it could be fixed at any time. |
This sounds like expected behaviour. We can't use relative paths when creating a fallback page (i.e. the page that is served when you visit a route that wasn't explicitly prerendered), because We can update the docs to make that clearer, but I'm not sure there's anything else we could be doing here. |
Could we consider adding a new configuration parameter that functions as the "workaround" mentioned in this discussion? Perhaps even a brief section in the documentation would do the trick! On a related note, I am a bit rusty with this issue as several months have elapsed since I first opened it. However, I recall being surprised/confused at the time that the behavior I expected for SPAs with |
I'm not 100% sure I understand the workaround — are you saying that you used the If the extension always opens on the root route (i.e. it's not possible to deep-link to a page within the extension app) then yeah, just having an empty |
Based on my reading of https://dev.twitch.tv/docs/extensions/, it also sounds like all you need to do is prerender |
I'm going to close this, as the docs PR has been merged and I don't think there's a great deal else we can do |
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 thebuild
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, andbase: 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 lastupload-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 usingsveltekit-adapter-ipfs
, but without success (I am dealing with a separate issue related to a missingpaths-
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
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: