Skip to content

Commit

Permalink
[fix] dont hardcode version in client bundle (#7694)
Browse files Browse the repository at this point in the history
fixes #7144
  • Loading branch information
Rich-Harris authored Nov 17, 2022
1 parent 172e792 commit d3a5db3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
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

0 comments on commit d3a5db3

Please sign in to comment.