Converting an undefined kit.version.name in to a Date.now(), a hardcoded timestamp gets added and generates unique static files for each build
See original GitHub issueDescribe the bug
When you do not include a version.name, Svelte uses a Date.now().toString() (https://kit.svelte.dev/docs/configuration). This has the added benefit of always rendering a unique version. The downside of this is that this gets passed on and hardcoded in the singletons.js during a build. Consequently making the singletons.hash.js unique to each build. If your hosting does not “share” build assets while scaling horizontally this creates a problem in that you get 404’s (each container has a unique set of files).
Reproduction
- install sveltekit
- run a build
- rename output folder (to prevent overwriting it)
- run a second build (without any code changes)
- observe that build/_app/immutable/chunks/singletons-[hash].js is now different from the previous build
Logs
No response
System Info
System:
OS: macOS 12.6
CPU: (10) arm64 Apple M1 Pro
Memory: 106.39 MB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
Browsers:
Brave Browser: 105.1.43.93
Chrome: 105.0.5195.125
Firefox Developer Edition: 106.0
Safari: 16.0
npmPackages:
@sveltejs/adapter-static: ^1.0.0-next.42 => 1.0.0-next.43
@sveltejs/kit: next => 1.0.0-next.491
svelte: ^3.44.0 => 3.50.1
vite: ^3.1.3 => 3.1.3
Severity
annoyance
Additional Information
Perhaps the singletons could uses a pointer to the version, and not a hardcoded version?
the original code can be found here: https://github.com/sveltejs/kit/blob/master/packages/kit/src/runtime/client/utils.js#L140 which gets its contents from here: https://github.com/sveltejs/kit/blob/master/packages/kit/src/exports/vite/build/utils.js#L136
CC @s-rd
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:8 (5 by maintainers)
Unless we were to expose it?
Perhaps if we didn’t embed the version in the generated files, but instead included it in the rendered HTML…
…then it wouldn’t matter so much, since the assets themselves would retain the same hashes.