sveltejs / sveltejs/kit

Image without `?enhanced` fails only in production and not development

Open
#15,334 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

pkg:enhanced-img
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug

Build created with @sveltejs/enhanced-img and rolldown-vite (or vite 8@beta) is failing to run.

Reproduction
<script>
	import MyImage from '$lib/assets/tama66-typewriter-8622984_1280.jpg';
</script>

<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p>
<enhanced:img src={MyImage} alt="Typewriter by the window" />

https://github.com/sukeshpabolu/enhanced-img-bug

  • install build
  • run pnpm build or npm build
  • run pnpm preview or npm preview
Logs

System Info
System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz
    Memory: 3.99 GB / 15.73 GB
  Binaries:
    Node: 22.22.0 - C:\Users\abcdefg\nodejs\node.EXE
    Yarn: 1.22.22 - C:\Users\abcdefg\nodejs\yarn.CMD
    npm: 10.9.4 - C:\Users\abcdefg\nodejs\npm.CMD
    pnpm: 10.29.3 - C:\Users\abcdefg\nodejs\pnpm.CMD
    bun: 1.3.8 - C:\Users\abcdefg\.bun\bin\bun.EXE
    Deno: 2.5.4 - C:\Users\abcdefg\.deno\bin\deno.EXE
  Browsers:
    Edge: Chromium (143.0.3650.80)
    Firefox: 133.0.3 - C:\Program Files\Mozilla Firefox\firefox.exe
    Internet Explorer: 11.0.19041.5794
  npmPackages:
    @sveltejs/adapter-node: ^5.5.3 => 5.5.3
    @sveltejs/enhanced-img: ^0.10.2 => 0.10.2
    @sveltejs/kit: ^2.52.0 => 2.52.0
    @sveltejs/vite-plugin-svelte: 7.0.0-next.0 => 7.0.0-next.0
    svelte: ^5.51.3 => 5.51.3
    vite: 8.0.0-beta.13 => 8.0.0-beta.13
Severity

annoyance

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked enhanced-img-bug reproduction and run its pnpm build and pnpm preview commands using the reported Vite and SvelteKit versions. Compare development and production handling of the image import, then verify that the enhanced image works in the production preview without requiring ?enhanced.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, vite
Domain
build-system, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.