@sveltejs/kit 2.7.2 → 2.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/package.json +2 -2
- package/src/core/config/index.js +1 -1
- package/src/core/config/options.js +8 -8
- package/src/core/postbuild/prerender.js +6 -6
- package/src/core/sync/write_ambient.js +1 -1
- package/src/core/sync/write_tsconfig.js +1 -1
- package/src/exports/public.d.ts +54 -55
- package/src/exports/vite/dev/index.js +1 -1
- package/src/exports/vite/index.js +20 -3
- package/src/exports/vite/preview/index.js +7 -0
- package/src/runtime/app/paths/types.d.ts +2 -2
- package/src/runtime/app/stores.js +2 -2
- package/src/runtime/client/client.js +16 -9
- package/src/runtime/client/fetcher.js +1 -1
- package/src/runtime/server/fetch.js +1 -1
- package/src/runtime/server/page/actions.js +9 -1
- package/src/runtime/server/page/index.js +2 -2
- package/src/runtime/server/page/load_data.js +1 -1
- package/src/runtime/server/page/render.js +3 -4
- package/src/types/ambient.d.ts +7 -7
- package/src/types/synthetic/$env+dynamic+private.md +1 -1
- package/src/types/synthetic/$env+dynamic+public.md +1 -1
- package/src/types/synthetic/$env+static+private.md +2 -2
- package/src/types/synthetic/$env+static+public.md +1 -1
- package/src/types/synthetic/$lib.md +2 -2
- package/src/version.js +1 -1
- package/types/index.d.ts +67 -68
- package/types/index.d.ts.map +1 -1
|
@@ -93,7 +93,7 @@ const warning_preprocessor = {
|
|
|
93
93
|
|
|
94
94
|
const message =
|
|
95
95
|
`\n${colors.bold().red(path.relative('.', filename))}\n` +
|
|
96
|
-
`\`${match[1]}\` will be ignored — move it to ${fixed} instead. See https://
|
|
96
|
+
`\`${match[1]}\` will be ignored — move it to ${fixed} instead. See https://svelte.dev/docs/kit/page-options for more information.`;
|
|
97
97
|
|
|
98
98
|
if (!warned.has(message)) {
|
|
99
99
|
console.log(message);
|
|
@@ -147,6 +147,7 @@ export async function sveltekit() {
|
|
|
147
147
|
preprocess,
|
|
148
148
|
onwarn: svelte_config.onwarn,
|
|
149
149
|
compilerOptions: {
|
|
150
|
+
// @ts-ignore - ignore this property when running `pnpm check` against Svelte 5 in the ecosystem CI
|
|
150
151
|
hydratable: isSvelte5Plus() ? undefined : true,
|
|
151
152
|
...svelte_config.compilerOptions
|
|
152
153
|
},
|
|
@@ -352,6 +353,9 @@ async function kit({ svelte_config }) {
|
|
|
352
353
|
}
|
|
353
354
|
};
|
|
354
355
|
|
|
356
|
+
/** @type {Map<string, string>} */
|
|
357
|
+
const import_map = new Map();
|
|
358
|
+
|
|
355
359
|
/** @type {import('vite').Plugin} */
|
|
356
360
|
const plugin_virtual_modules = {
|
|
357
361
|
name: 'vite-plugin-sveltekit-virtual-modules',
|
|
@@ -372,6 +376,8 @@ async function kit({ svelte_config }) {
|
|
|
372
376
|
`Cannot import ${id} into service-worker code. Only the modules $service-worker and $env/static/public are available in service workers.`
|
|
373
377
|
);
|
|
374
378
|
}
|
|
379
|
+
|
|
380
|
+
import_map.set(id, importer);
|
|
375
381
|
}
|
|
376
382
|
|
|
377
383
|
// treat $env/static/[public|private] as virtual
|
|
@@ -398,7 +404,18 @@ async function kit({ svelte_config }) {
|
|
|
398
404
|
})
|
|
399
405
|
) {
|
|
400
406
|
const relative = normalize_id(id, normalized_lib, normalized_cwd);
|
|
401
|
-
|
|
407
|
+
|
|
408
|
+
const illegal_module = strip_virtual_prefix(relative);
|
|
409
|
+
|
|
410
|
+
if (import_map.has(illegal_module)) {
|
|
411
|
+
const importer = path.relative(
|
|
412
|
+
cwd,
|
|
413
|
+
/** @type {string} */ (import_map.get(illegal_module))
|
|
414
|
+
);
|
|
415
|
+
throw new Error(`Cannot import ${illegal_module} into client-side code: ${importer}`);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
throw new Error(`Cannot import ${illegal_module} into client-side code`);
|
|
402
419
|
}
|
|
403
420
|
}
|
|
404
421
|
|
|
@@ -900,7 +917,7 @@ async function kit({ svelte_config }) {
|
|
|
900
917
|
} else {
|
|
901
918
|
console.log(colors.bold().yellow('\nNo adapter specified'));
|
|
902
919
|
|
|
903
|
-
const link = colors.bold().cyan('https://
|
|
920
|
+
const link = colors.bold().cyan('https://svelte.dev/docs/kit/adapters');
|
|
904
921
|
console.log(
|
|
905
922
|
`See ${link} to learn how to configure your app to run on the platform of your choosing`
|
|
906
923
|
);
|
|
@@ -131,6 +131,13 @@ export async function preview(vite, vite_config, svelte_config) {
|
|
|
131
131
|
let filename = normalizePath(
|
|
132
132
|
join(svelte_config.kit.outDir, 'output/prerendered/pages' + pathname)
|
|
133
133
|
);
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
filename = decodeURI(filename);
|
|
137
|
+
} catch {
|
|
138
|
+
// malformed URI
|
|
139
|
+
}
|
|
140
|
+
|
|
134
141
|
let prerendered = is_file(filename);
|
|
135
142
|
|
|
136
143
|
if (!prerendered) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A string that matches [`config.kit.paths.base`](https://
|
|
2
|
+
* A string that matches [`config.kit.paths.base`](https://svelte.dev/docs/kit/configuration#paths).
|
|
3
3
|
*
|
|
4
4
|
* Example usage: `<a href="{base}/your-page">Link</a>`
|
|
5
5
|
*/
|
|
6
6
|
export let base: '' | `/${string}`;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* An absolute path that matches [`config.kit.paths.assets`](https://
|
|
9
|
+
* An absolute path that matches [`config.kit.paths.assets`](https://svelte.dev/docs/kit/configuration#paths).
|
|
10
10
|
*
|
|
11
11
|
* > [!NOTE] If a value for `config.kit.paths.assets` is specified, it will be replaced with `'/_svelte_kit_assets'` during `vite dev` or `vite preview`, since the assets don't yet live at their eventual URL.
|
|
12
12
|
*/
|
|
@@ -53,7 +53,7 @@ export const navigating = {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* A readable store whose initial value is `false`. If [`version.pollInterval`](https://
|
|
56
|
+
* A readable store whose initial value is `false`. If [`version.pollInterval`](https://svelte.dev/docs/kit/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update the store value to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling.
|
|
57
57
|
*
|
|
58
58
|
* On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.
|
|
59
59
|
* @type {import('svelte/store').Readable<boolean> & { check(): Promise<boolean> }}
|
|
@@ -88,7 +88,7 @@ function get_store(name) {
|
|
|
88
88
|
} catch {
|
|
89
89
|
throw new Error(
|
|
90
90
|
`Cannot subscribe to '${name}' store on the server outside of a Svelte component, as it is bound to the current request via component context. This prevents state from leaking between users.` +
|
|
91
|
-
'For more information, see https://
|
|
91
|
+
'For more information, see https://svelte.dev/docs/kit/state-management#avoid-shared-state-on-the-server'
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -1529,6 +1529,7 @@ function setup_preload() {
|
|
|
1529
1529
|
|
|
1530
1530
|
/** @param {Event} event */
|
|
1531
1531
|
function tap(event) {
|
|
1532
|
+
if (event.defaultPrevented) return;
|
|
1532
1533
|
preload(/** @type {Element} */ (event.composedPath()[0]), 1);
|
|
1533
1534
|
}
|
|
1534
1535
|
|
|
@@ -1574,7 +1575,7 @@ function setup_preload() {
|
|
|
1574
1575
|
`Preloading data for ${intent.url.pathname} failed with the following error: ${result.state.error.message}\n` +
|
|
1575
1576
|
'If this error is transient, you can ignore it. Otherwise, consider disabling preloading for this route. ' +
|
|
1576
1577
|
'This route was preloaded due to a data-sveltekit-preload-data attribute. ' +
|
|
1577
|
-
'See https://
|
|
1578
|
+
'See https://svelte.dev/docs/kit/link-options for more info'
|
|
1578
1579
|
);
|
|
1579
1580
|
}
|
|
1580
1581
|
});
|
|
@@ -1717,12 +1718,12 @@ export function disableScrollHandling() {
|
|
|
1717
1718
|
* Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`.
|
|
1718
1719
|
* For external URLs, use `window.location = url` instead of calling `goto(url)`.
|
|
1719
1720
|
*
|
|
1720
|
-
* @param {string | URL} url Where to navigate to. Note that if you've set [`config.kit.paths.base`](https://
|
|
1721
|
+
* @param {string | URL} url Where to navigate to. Note that if you've set [`config.kit.paths.base`](https://svelte.dev/docs/kit/configuration#paths) and the URL is root-relative, you need to prepend the base path if you want to navigate within the app.
|
|
1721
1722
|
* @param {Object} [opts] Options related to the navigation
|
|
1722
1723
|
* @param {boolean} [opts.replaceState] If `true`, will replace the current `history` entry rather than creating a new one with `pushState`
|
|
1723
1724
|
* @param {boolean} [opts.noScroll] If `true`, the browser will maintain its scroll position rather than scrolling to the top of the page after navigation
|
|
1724
1725
|
* @param {boolean} [opts.keepFocus] If `true`, the currently focused element will retain focus after navigation. Otherwise, focus will be reset to the body
|
|
1725
|
-
* @param {boolean} [opts.invalidateAll] If `true`, all `load` functions of the page will be rerun. See https://
|
|
1726
|
+
* @param {boolean} [opts.invalidateAll] If `true`, all `load` functions of the page will be rerun. See https://svelte.dev/docs/kit/load#rerunning-load-functions for more info on invalidation.
|
|
1726
1727
|
* @param {App.PageState} [opts.state] An optional object that will be available on the `$page.state` store
|
|
1727
1728
|
* @returns {Promise<void>}
|
|
1728
1729
|
*/
|
|
@@ -1861,7 +1862,7 @@ export function preloadCode(pathname) {
|
|
|
1861
1862
|
}
|
|
1862
1863
|
|
|
1863
1864
|
/**
|
|
1864
|
-
* Programmatically create a new history entry with the given `$page.state`. To use the current URL, you can pass `''` as the first argument. Used for [shallow routing](https://
|
|
1865
|
+
* Programmatically create a new history entry with the given `$page.state`. To use the current URL, you can pass `''` as the first argument. Used for [shallow routing](https://svelte.dev/docs/kit/shallow-routing).
|
|
1865
1866
|
*
|
|
1866
1867
|
* @param {string | URL} url
|
|
1867
1868
|
* @param {App.PageState} state
|
|
@@ -1905,7 +1906,7 @@ export function pushState(url, state) {
|
|
|
1905
1906
|
}
|
|
1906
1907
|
|
|
1907
1908
|
/**
|
|
1908
|
-
* Programmatically replace the current history entry with the given `$page.state`. To use the current URL, you can pass `''` as the first argument. Used for [shallow routing](https://
|
|
1909
|
+
* Programmatically replace the current history entry with the given `$page.state`. To use the current URL, you can pass `''` as the first argument. Used for [shallow routing](https://svelte.dev/docs/kit/shallow-routing).
|
|
1909
1910
|
*
|
|
1910
1911
|
* @param {string | URL} url
|
|
1911
1912
|
* @param {App.PageState} state
|
|
@@ -2089,8 +2090,11 @@ function _start_router() {
|
|
|
2089
2090
|
|
|
2090
2091
|
if (download) return;
|
|
2091
2092
|
|
|
2093
|
+
const [nonhash, hash] = url.href.split('#');
|
|
2094
|
+
const same_pathname = nonhash === strip_hash(location);
|
|
2095
|
+
|
|
2092
2096
|
// Ignore the following but fire beforeNavigate
|
|
2093
|
-
if (external || options.reload) {
|
|
2097
|
+
if (external || (options.reload && (!same_pathname || !hash))) {
|
|
2094
2098
|
if (_before_navigate({ url, type: 'link' })) {
|
|
2095
2099
|
// set `navigating` to `true` to prevent `beforeNavigate` callbacks
|
|
2096
2100
|
// being called when the page unloads
|
|
@@ -2105,8 +2109,7 @@ function _start_router() {
|
|
|
2105
2109
|
// Check if new url only differs by hash and use the browser default behavior in that case
|
|
2106
2110
|
// This will ensure the `hashchange` event is fired
|
|
2107
2111
|
// Removing the hash does a full page navigation in the browser, so make sure a hash is present
|
|
2108
|
-
|
|
2109
|
-
if (hash !== undefined && nonhash === strip_hash(location)) {
|
|
2112
|
+
if (hash !== undefined && same_pathname) {
|
|
2110
2113
|
// If we are trying to navigate to the same hash, we should only
|
|
2111
2114
|
// attempt to scroll to that element and avoid any history changes.
|
|
2112
2115
|
// Otherwise, this can cause Firefox to incorrectly assign a null
|
|
@@ -2121,7 +2124,11 @@ function _start_router() {
|
|
|
2121
2124
|
if (hash === '' || (hash === 'top' && a.ownerDocument.getElementById('top') === null)) {
|
|
2122
2125
|
window.scrollTo({ top: 0 });
|
|
2123
2126
|
} else {
|
|
2124
|
-
a.ownerDocument.getElementById(decodeURIComponent(hash))
|
|
2127
|
+
const element = a.ownerDocument.getElementById(decodeURIComponent(hash));
|
|
2128
|
+
if (element) {
|
|
2129
|
+
element.scrollIntoView();
|
|
2130
|
+
element.focus();
|
|
2131
|
+
}
|
|
2125
2132
|
}
|
|
2126
2133
|
|
|
2127
2134
|
return;
|
|
@@ -53,7 +53,7 @@ if (DEV && BROWSER) {
|
|
|
53
53
|
|
|
54
54
|
if (in_load_heuristic && !used_kit_fetch) {
|
|
55
55
|
console.warn(
|
|
56
|
-
`Loading ${url} using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://
|
|
56
|
+
`Loading ${url} using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://svelte.dev/docs/kit/load#making-fetch-requests`
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -97,7 +97,7 @@ export function create_fetch({ event, options, manifest, state, get_cookie_heade
|
|
|
97
97
|
return new Response(state.read(file), {
|
|
98
98
|
headers: type ? { 'content-type': type } : {}
|
|
99
99
|
});
|
|
100
|
-
} else if (read_implementation) {
|
|
100
|
+
} else if (read_implementation && file in manifest._.server_assets) {
|
|
101
101
|
const length = manifest._.server_assets[file];
|
|
102
102
|
const type = manifest.mimeTypes[file.slice(file.lastIndexOf('.'))];
|
|
103
103
|
|
|
@@ -197,7 +197,7 @@ export async function handle_action_request(event, server) {
|
|
|
197
197
|
function check_named_default_separate(actions) {
|
|
198
198
|
if (actions.default && Object.keys(actions).length > 1) {
|
|
199
199
|
throw new Error(
|
|
200
|
-
'When using named actions, the default action cannot be used. See the docs for more info: https://
|
|
200
|
+
'When using named actions, the default action cannot be used. See the docs for more info: https://svelte.dev/docs/kit/form-actions#named-actions'
|
|
201
201
|
);
|
|
202
202
|
}
|
|
203
203
|
}
|
|
@@ -280,6 +280,14 @@ function try_deserialize(data, fn, route_id) {
|
|
|
280
280
|
// If we're here, the data could not be serialized with devalue
|
|
281
281
|
const error = /** @type {any} */ (e);
|
|
282
282
|
|
|
283
|
+
// if someone tries to use `json()` in their action
|
|
284
|
+
if (data instanceof Response) {
|
|
285
|
+
throw new Error(
|
|
286
|
+
`Data returned from action inside ${route_id} is not serializable. Form actions need to return plain objects or fail(). E.g. return { success: true } or return fail(400, { message: "invalid" });`
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// if devalue could not serialize a property on the object, etc.
|
|
283
291
|
if ('path' in error) {
|
|
284
292
|
let message = `Data returned from action inside ${route_id} is not serializable: ${error.message}`;
|
|
285
293
|
if (error.path !== '') message += ` (data.${error.path})`;
|
|
@@ -105,12 +105,12 @@ export async function render_page(event, page, options, manifest, state, resolve
|
|
|
105
105
|
if (DEV && action_result && !event.request.headers.has('x-sveltekit-action')) {
|
|
106
106
|
if (action_result.type === 'error') {
|
|
107
107
|
console.warn(
|
|
108
|
-
"The form action returned an error, but +error.svelte wasn't rendered because SSR is off. To get the error page with CSR, enhance your form with `use:enhance`. See https://
|
|
108
|
+
"The form action returned an error, but +error.svelte wasn't rendered because SSR is off. To get the error page with CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#progressive-enhancement-use-enhance"
|
|
109
109
|
);
|
|
110
110
|
} else if (action_result.data) {
|
|
111
111
|
/// case: lost data
|
|
112
112
|
console.warn(
|
|
113
|
-
"The form action returned a value, but it isn't available in `$page.form`, because SSR is off. To handle the returned value in CSR, enhance your form with `use:enhance`. See https://
|
|
113
|
+
"The form action returned a value, but it isn't available in `$page.form`, because SSR is off. To handle the returned value in CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#progressive-enhancement-use-enhance"
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -348,7 +348,7 @@ export function create_universal_fetch(event, state, fetched, csr, resolve_opts)
|
|
|
348
348
|
const included = resolve_opts.filterSerializedResponseHeaders(lower, value);
|
|
349
349
|
if (!included) {
|
|
350
350
|
throw new Error(
|
|
351
|
-
`Failed to get response header "${lower}" — it must be included by the \`filterSerializedResponseHeaders\` option: https://
|
|
351
|
+
`Failed to get response header "${lower}" — it must be included by the \`filterSerializedResponseHeaders\` option: https://svelte.dev/docs/kit/hooks#Server-hooks-handle (at ${event.route.id})`
|
|
352
352
|
);
|
|
353
353
|
}
|
|
354
354
|
}
|
|
@@ -480,7 +480,7 @@ export async function render_response({
|
|
|
480
480
|
if (page_config.csr) {
|
|
481
481
|
if (transformed.split('<!--').length < html.split('<!--').length) {
|
|
482
482
|
// the \u001B stuff is ANSI codes, so that we don't need to add a library to the runtime
|
|
483
|
-
// https://svelte.dev/
|
|
483
|
+
// https://svelte.dev/playground/1b3f49696f0c44c881c34587f2537aa2?version=4.2.19
|
|
484
484
|
console.warn(
|
|
485
485
|
"\u001B[1m\u001B[31mRemoving comments in transformPageChunk can break Svelte's hydration\u001B[39m\u001B[22m"
|
|
486
486
|
);
|
|
@@ -566,9 +566,8 @@ function get_data(event, options, nodes, csp, global) {
|
|
|
566
566
|
str = devalue.uneval({ id, data, error }, replacer);
|
|
567
567
|
}
|
|
568
568
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
);
|
|
569
|
+
const nonce = csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : '';
|
|
570
|
+
push(`<script${nonce}>${global}.resolve(${str})</script>\n`);
|
|
572
571
|
if (count === 0) done();
|
|
573
572
|
}
|
|
574
573
|
);
|
package/src/types/ambient.d.ts
CHANGED
|
@@ -29,30 +29,30 @@ declare namespace App {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* The interface that defines `event.locals`, which can be accessed in [hooks](https://
|
|
32
|
+
* The interface that defines `event.locals`, which can be accessed in server [hooks](https://svelte.dev/docs/kit/hooks) (`handle`, and `handleError`), server-only `load` functions, and `+server.js` files.
|
|
33
33
|
*/
|
|
34
34
|
export interface Locals {}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* Defines the common shape of the [$page.data store](https://
|
|
37
|
+
* Defines the common shape of the [$page.data store](https://svelte.dev/docs/kit/$app-stores#page) - that is, the data that is shared between all pages.
|
|
38
38
|
* The `Load` and `ServerLoad` functions in `./$types` will be narrowed accordingly.
|
|
39
39
|
* Use optional properties for data that is only present on specific pages. Do not add an index signature (`[key: string]: any`).
|
|
40
40
|
*/
|
|
41
41
|
export interface PageData {}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* The shape of the `$page.state` object, which can be manipulated using the [`pushState`](https://
|
|
44
|
+
* The shape of the `$page.state` object, which can be manipulated using the [`pushState`](https://svelte.dev/docs/kit/$app-navigation#pushState) and [`replaceState`](https://svelte.dev/docs/kit/$app-navigation#replaceState) functions from `$app/navigation`.
|
|
45
45
|
*/
|
|
46
46
|
export interface PageState {}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* If your adapter provides [platform-specific context](https://
|
|
49
|
+
* If your adapter provides [platform-specific context](https://svelte.dev/docs/kit/adapters#platform-specific-context) via `event.platform`, you can specify it here.
|
|
50
50
|
*/
|
|
51
51
|
export interface Platform {}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
* This module is only available to [service workers](https://
|
|
55
|
+
* This module is only available to [service workers](https://svelte.dev/docs/kit/service-workers).
|
|
56
56
|
*/
|
|
57
57
|
declare module '$service-worker' {
|
|
58
58
|
/**
|
|
@@ -66,7 +66,7 @@ declare module '$service-worker' {
|
|
|
66
66
|
*/
|
|
67
67
|
export const build: string[];
|
|
68
68
|
/**
|
|
69
|
-
* An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](https://
|
|
69
|
+
* An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](https://svelte.dev/docs/kit/configuration)
|
|
70
70
|
*/
|
|
71
71
|
export const files: string[];
|
|
72
72
|
/**
|
|
@@ -75,7 +75,7 @@ declare module '$service-worker' {
|
|
|
75
75
|
*/
|
|
76
76
|
export const prerendered: string[];
|
|
77
77
|
/**
|
|
78
|
-
* See [`config.kit.version`](https://
|
|
78
|
+
* See [`config.kit.version`](https://svelte.dev/docs/kit/configuration#version). It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
|
|
79
79
|
*/
|
|
80
80
|
export const version: string;
|
|
81
81
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
This module provides access to runtime environment variables, as defined by the platform you're running on. For example if you're using [`adapter-node`](https://github.com/sveltejs/kit/tree/main/packages/adapter-node) (or running [`vite preview`](https://
|
|
1
|
+
This module provides access to runtime environment variables, as defined by the platform you're running on. For example if you're using [`adapter-node`](https://github.com/sveltejs/kit/tree/main/packages/adapter-node) (or running [`vite preview`](https://svelte.dev/docs/kit/cli)), this is equivalent to `process.env`. This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://svelte.dev/docs/kit/configuration#env) (if configured).
|
|
2
2
|
|
|
3
3
|
This module cannot be imported into client-side code.
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Similar to [`$env/dynamic/private`](https://
|
|
1
|
+
Similar to [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private), but only includes variables that begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code.
|
|
2
2
|
|
|
3
3
|
Note that public dynamic environment variables must all be sent from the server to the client, causing larger network requests — when possible, use `$env/static/public` instead.
|
|
4
4
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Environment variables [loaded by Vite](https://vitejs.dev/guide/env-and-mode.html#env-files) from `.env` files and `process.env`. Like [`$env/dynamic/private`](https://
|
|
1
|
+
Environment variables [loaded by Vite](https://vitejs.dev/guide/env-and-mode.html#env-files) from `.env` files and `process.env`. Like [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private), this module cannot be imported into client-side code. This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://svelte.dev/docs/kit/configuration#env) (if configured).
|
|
2
2
|
|
|
3
|
-
_Unlike_ [`$env/dynamic/private`](https://
|
|
3
|
+
_Unlike_ [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private), the values exported from this module are statically injected into your bundle at build time, enabling optimisations like dead code elimination.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
import { API_KEY } from '$env/static/private';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Similar to [`$env/static/private`](https://
|
|
1
|
+
Similar to [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private), except that it only includes environment variables that begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code.
|
|
2
2
|
|
|
3
3
|
Values are replaced statically at build time.
|
|
4
4
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
This is a simple alias to `src/lib`, or whatever directory is specified as [`config.kit.files.lib`](https://
|
|
1
|
+
This is a simple alias to `src/lib`, or whatever directory is specified as [`config.kit.files.lib`](https://svelte.dev/docs/kit/configuration#files). It allows you to access common components and utility modules without `../../../../` nonsense.
|
|
2
2
|
|
|
3
3
|
### `$lib/server`
|
|
4
4
|
|
|
5
|
-
A subdirectory of `$lib`. SvelteKit will prevent you from importing any modules in `$lib/server` into client-side code. See [server-only modules](https://
|
|
5
|
+
A subdirectory of `$lib`. SvelteKit will prevent you from importing any modules in `$lib/server` into client-side code. See [server-only modules](https://svelte.dev/docs/kit/server-only-modules).
|
package/src/version.js
CHANGED