Skip to content

don't hardcode version in client bundle #7694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/calm-ways-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Don't hardcode version in client bundle
1 change: 0 additions & 1 deletion packages/kit/src/exports/vite/build/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ export function get_default_build_config({ config, input, ssr, outDir }) {
},
define: {
__SVELTEKIT_ADAPTER_NAME__: JSON.stringify(config.kit.adapter?.name),
__SVELTEKIT_APP_VERSION__: JSON.stringify(config.kit.version.name),
__SVELTEKIT_APP_VERSION_FILE__: JSON.stringify(`${config.kit.appDir}/version.json`),
__SVELTEKIT_APP_VERSION_POLL_INTERVAL__: JSON.stringify(config.kit.version.pollInterval),
__SVELTEKIT_BROWSER__: ssr ? 'false' : 'true',
Expand Down
7 changes: 4 additions & 3 deletions packages/kit/src/runtime/client/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { writable } from 'svelte/store';
import { assets } from '../paths.js';
import { version } from '../env.js';

/* global __SVELTEKIT_APP_VERSION__, __SVELTEKIT_APP_VERSION_FILE__, __SVELTEKIT_APP_VERSION_POLL_INTERVAL__ */
/* global __SVELTEKIT_APP_VERSION_FILE__, __SVELTEKIT_APP_VERSION_POLL_INTERVAL__ */

/** @param {HTMLDocument} doc */
export function get_base_uri(doc) {
Expand Down Expand Up @@ -143,8 +144,8 @@ export function create_updated_store() {
});

if (res.ok) {
const { version } = await res.json();
const updated = version !== __SVELTEKIT_APP_VERSION__;
const data = await res.json();
const updated = data.version !== version;

if (updated) {
set(true);
Expand Down