Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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/real-taxis-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Enable removal of non-browser code from client builds
1 change: 1 addition & 0 deletions packages/kit/src/exports/vite/build/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export function get_default_build_config({ config, input, ssr, outDir }) {
__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',
__SVELTEKIT_DEV__: 'false'
},
publicDir: ssr ? false : config.kit.files.assets,
Expand Down
5 changes: 3 additions & 2 deletions packages/kit/src/exports/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,9 @@ function kit() {
}
},
define: {
__SVELTEKIT_DEV__: 'true',
__SVELTEKIT_APP_VERSION_POLL_INTERVAL__: '0'
__SVELTEKIT_APP_VERSION_POLL_INTERVAL__: '0',
__SVELTEKIT_BROWSER__: !config_env.ssrBuild,
__SVELTEKIT_DEV__: 'true'
},
publicDir: svelte_config.kit.files.assets,
resolve: {
Expand Down
10 changes: 6 additions & 4 deletions packages/kit/src/utils/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ export function make_trackable(url, callback) {
});
}

// @ts-ignore
tracked[Symbol.for('nodejs.util.inspect.custom')] = (depth, opts, inspect) => {
return inspect(url, opts);
};
if (!__SVELTEKIT_BROWSER__) {
// @ts-ignore
tracked[Symbol.for('nodejs.util.inspect.custom')] = (depth, opts, inspect) => {
return inspect(url, opts);
};
}

disable_hash(tracked);

Expand Down
1 change: 1 addition & 0 deletions packages/kit/types/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,5 +375,6 @@ declare global {
const __SVELTEKIT_APP_VERSION__: string;
const __SVELTEKIT_APP_VERSION_FILE__: string;
const __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: number;
const __SVELTEKIT_BROWSER__: boolean;
const __SVELTEKIT_DEV__: boolean;
}