The `link` HTTP header in SSR breaks the import maps
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
I'm using node adaptor and I found when doing SSR, the server adds a link HTPP header to indicate the browser to preload things.
However, I'm using import maps as well. According to the standard, the import map must be declared and processed before any <script> elements, so those scripts preloaded in the link header break my import maps.
Reproduction
https://github.com/hronro/sveltekit-http-link-importmap-issue
The problem only exists in production build.
Logs
No response
System Info
System:
OS: Linux 6.6 Arch Linux
CPU: (14) x64 AMD Ryzen 7 5800X 8-Core Processor
Memory: 24.67 GB / 27.41 GB
Container: Yes
Shell: 3.6.1 - /usr/bin/fish
Binaries:
Node: 21.2.0 - /usr/bin/node
Yarn: 1.22.19 - /usr/bin/yarn
npm: 10.2.4 - /usr/bin/npm
pnpm: 8.10.2 - /usr/bin/pnpm
bun: 1.0.0 - /usr/local/bin/bun
npmPackages:
@sveltejs/adapter-auto: ^2.0.0 => 2.1.1
@sveltejs/adapter-node: ^1.3.1 => 1.3.1
@sveltejs/kit: ^1.27.4 => 1.27.6
svelte: ^4.0.5 => 4.2.4
vite: ^4.4.2 => 4.5.0
Severity
blocking all usage of SvelteKit
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the linked reproduction in a production build with the node adapter and import maps enabled. Inspect the SSR response handling that adds the HTTP Link preload header; done means import maps are processed correctly without incompatible preloads, while other SSR behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend, frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100