question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fragment URL issue using static-adapter

See original GitHub issue

Describe the bug

When you have something like this

├── routes
    ├── index.svelte
    └── test
        └── route.svelte

Route.svelte:

<a href="#something" id='something'>Text</a>

the page will see the URL as /test/route#something adapter-static will check the wrong URL (/test) which doesn’t exist, Error: (404 /test (linked from /test/route))

adding an index.svelte fixes the issue, but you may not always want an index.svelte

├── routes
    ├── index.svelte
    └── test
        ├── index.svelte
        └── route.svelte

Reproduction

https://github.com/JeremyMoeglich/href-fragment-issue

npm install npm run build

Logs

npm run build

> href-fragment-issue@0.0.1 build
> svelte-kit build

vite v2.7.10 building for production...
✓ 15 modules transformed.
.svelte-kit/output/client/_app/manifest.json                         1.47 KiB
.svelte-kit/output/client/_app/layout.svelte-091e4ac8.js             0.53 KiB / gzip: 0.35 KiB
.svelte-kit/output/client/_app/error.svelte-b6279998.js              1.56 KiB / gzip: 0.75 KiB
.svelte-kit/output/client/_app/pages/index.svelte-58aa7df0.js        0.70 KiB / gzip: 0.42 KiB
.svelte-kit/output/client/_app/pages/test/route.svelte-8aa31dfa.js   0.75 KiB / gzip: 0.44 KiB
.svelte-kit/output/client/_app/assets/start-61d1577b.css             0.16 KiB / gzip: 0.15 KiB
.svelte-kit/output/client/_app/start-e1e03bcc.js                     19.73 KiB / gzip: 6.81 KiB
.svelte-kit/output/client/_app/chunks/vendor-a7db36b2.js             7.07 KiB / gzip: 2.91 KiB
vite v2.7.10 building SSR bundle for production...
✓ 13 modules transformed.
.svelte-kit/output/server/manifest.json                        1.12 KiB
.svelte-kit/output/server/app.js                               46.60 KiB
.svelte-kit/output/server/entries/pages/layout.svelte.js       0.24 KiB
.svelte-kit/output/server/entries/pages/error.svelte.js        0.72 KiB
.svelte-kit/output/server/entries/pages/index.svelte.js        0.31 KiB
.svelte-kit/output/server/entries/pages/test/route.svelte.js   0.34 KiB
.svelte-kit/output/server/chunks/index-2dc61825.js             2.24 KiB

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-static
> 404 /test (linked from /test/route)
Error: 404 /test (linked from /test/route)
    at file:///C:/Users/jerem/Desktop/dev/Web/href-fragment-issue/node_modules/@sveltejs/kit/dist/chunks/index5.js:167:11
    at visit (file:///C:/Users/jerem/Desktop/dev/Web/href-fragment-issue/node_modules/@sveltejs/kit/dist/chunks/index5.js:326:5)

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor
    Memory: 15.94 GB / 31.92 GB
  Binaries:
    Node: 17.2.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.1.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    @sveltejs/adapter-static: ^1.0.0-next.24 => 1.0.0-next.24
    @sveltejs/kit: next => 1.0.0-next.216
    svelte: ^3.44.0 => 3.45.0

Severity

serious, but I can work around it

Additional Information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
geoffrichcommented, Feb 25, 2022

@sharu725 I don’t think that error is related to this issue, which was about fragment URLs. To customize SvelteKit’s behavior when it encounters a broken link, you can pass a function to prerender.onError: https://kit.svelte.dev/docs/configuration#prerender.

1reaction
benmccanncommented, Jan 16, 2022

this is broken again. I believe by https://github.com/sveltejs/kit/pull/3288

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Using static fragment in Fragment Page Adapter - Stack ...
I'm trying to develop tabs based application, and I'm using FragmentPageAdapter to do that. My class which extends FragmentPageAdapter is static class ...
Read more >
Binding adapters - Android Developers
A static binding adapter method with the BindingAdapter annotation allows you to customize how a setter for an attribute is called.
Read more >
Securing Applications and Services Guide - Keycloak
This section describes how you can secure applications and services with OpenID Connect using either Keycloak adapters or generic OpenID Connect ...
Read more >
Android TabLayout and ViewPager - DigitalOcean
It's generally used in conjunction with fragments. Let's modify our layout from the previous tutorial as below. activity_main.xml
Read more >
Android Fragments Tutorial: An Introduction with Kotlin
In this Android Fragments with Kotlin tutorial you will learn the fundamental ... Binding Adapters; Navigating the Fragment Back Stack ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found