Open mvolfik opened 2 years ago
Is this still occurring? I cloned the repro and updated svelte.config.js to support newer versions of SvelteKit, and it built fine — the outputted index.html
looks like this...
<p><img src="/_app/assets/kitten1-d3409436"></p>
<p><img src="/_app/assets/kitten1-d3409436"></p>
...and _app/assets
contains kitten1-d3409436
as expected. It's possible that it was fixed in Vite since this issue was raised?
Thanks for checking. The issue is unfortunately still there - it just seemed to disappear because Vite 2.7.0 slightly changed the plugin API (ssr: bool
became options?: { ssr?: bool }
, so the comparison was always false. I pushed updated version of the reproduction repo, which reproduces the bug with latest dependencies
Finally took another look at this and yes, it's still happening. I don't think it's in SvelteKit's power to fix though, this is a Vite/Rollup issue. It might be worth trying to create a non-SvelteKit repro and filing it on the Vite tracker if you're still affected by this.
Describe the bug
Vite (thankfully) deduplicates byte-to-byte equal asset files. In my project I create the assets dynamically with a custom plugin using
pluginContext.emitFile()
. However, I heavily use async, so the order of the emit calls is not deterministic, therefore the single file from vite deduplication has different name in client-side and server-side code. And I build with adapter-static, which crawls ssr code, but copies client assets, so it finds a non-existing file.Reproduction
https://github.com/mvolfik/probable-waffle
In plugin.js, the same file is emitted for both imports with different name. Manual delays are added to emit kitten2 first in ssr mode, and kitten1 otherwise.
Logs
System Info
Severity
blocking an upgrade
Additional Information
No response