Skip to content

srcset causes adapter-static build to fail #9369

@johnknoop

Description

@johnknoop

Describe the bug

I initially posted a comment in a separate issue but didn't get any response from that, so I'm creating a separate one instead.

Since upgrading from version 1.0.0-next.224 of SvelteKit, I can no longer have srcset attributes with multiple paths (which is the whole point with srcset attributes.

Current versions:

@sveltejs/kit: 1.9.3
@sveltejs/adapter-static: 2.0.1
svelte: 3.55.1
vite: 4.1.4

The versions I had before, where it worked:

@sveltejs/kit: 1.0.0-next.224
@sveltejs/adapter-static: 1.0.0-next.26
svelte: 3.48.0
vite: 2.7.13

Reproduction

<img
    srcset="/order_thumbnail_400px.png,
            /order_thumbnail_800px.png 1.5x"
    src="/order_thumbnail_400px.png"
    alt="" />

(Both png files are located in /static folder)

Expected result

A successful build

Observed result

Error: Not found: /order_thumbnail_400px.png,/order_thumbnail_800px.png
at resolve (file:///C:/work/hublinwebsite/.svelte-kit/output/server/index.js:2711:18)
at resolve (file:///C:/work/hublinwebsite/.svelte-kit/output/server/index.js:2586:34)
at #options.hooks.handle (file:///C:/work/hublinwebsite/.svelte-kit/output/server/index.js:2755:59)
at respond (file:///C:/work/hublinwebsite/.svelte-kit/output/server/index.js:2584:43)
file:///C:/work/hublinwebsite/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:53
throw new Error(format(details));
^

Error: 404 /order_thumbnail_400px.png,/order_thumbnail_800px.png (linked from /)
at file:///C:/work/hublinwebsite/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:53:12
at save (file:///C:/work/hublinwebsite/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:355:4)
at visit (file:///C:/work/hublinwebsite/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:204:3)

If I remove one of the paths from the srcset attribute:

<img
    srcset="/order_thumbnail_800px.png 1.5x"
    src="/order_thumbnail_400px.png"
    alt="" />

...then it builds successfully.

Logs

Error: Not found: /order_thumbnail_400px.png,/order_thumbnail_800px.png
at resolve (file:///C:/work/hublinwebsite/.svelte-kit/output/server/index.js:2711:18)
at resolve (file:///C:/work/hublinwebsite/.svelte-kit/output/server/index.js:2586:34)
at #options.hooks.handle (file:///C:/work/hublinwebsite/.svelte-kit/output/server/index.js:2755:59)
at respond (file:///C:/work/hublinwebsite/.svelte-kit/output/server/index.js:2584:43)
file:///C:/work/hublinwebsite/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:53
throw new Error(format(details));
^

Error: 404 /order_thumbnail_400px.png,/order_thumbnail_800px.png (linked from /)
at file:///C:/work/hublinwebsite/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:53:12
at save (file:///C:/work/hublinwebsite/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:355:4)
at visit (file:///C:/work/hublinwebsite/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:204:3)

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 12.78 GB / 31.73 GB
  Binaries:
    Node: 18.14.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 9.3.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (110.0.1587.63)
    Internet Explorer: 11.0.22000.120

Severity

blocking an upgrade

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions