@sveltejs/kit 1.0.0-next.559 → 1.0.0-next.560
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/package.json +1 -1
- package/src/core/config/options.js +4 -1
- package/src/core/prerender/prerender.js +1 -6
- package/src/exports/vite/build/build_server.js +2 -2
- package/src/exports/vite/graph_analysis/index.js +4 -12
- package/src/exports/vite/preview/index.js +1 -1
- package/src/runtime/app/environment.js +1 -1
- package/src/runtime/env.js +3 -3
- package/types/ambient.d.ts +6 -6
- package/types/index.d.ts +0 -1
- package/types/internal.d.ts +1 -1
package/package.json
CHANGED
|
@@ -238,7 +238,10 @@ const options = object(
|
|
|
238
238
|
(keypath) =>
|
|
239
239
|
`${keypath} has been removed. You can set it inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
|
|
240
240
|
),
|
|
241
|
-
enabled:
|
|
241
|
+
enabled: error(
|
|
242
|
+
(keypath) =>
|
|
243
|
+
`${keypath} has been removed. You can wrap any code that should not be executed during build in a \`if (!building) {...}\` block. See the discussion for more information: https://github.com/sveltejs/kit/discussions/7716`
|
|
244
|
+
),
|
|
242
245
|
entries: validate(['*'], (input, keypath) => {
|
|
243
246
|
if (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) {
|
|
244
247
|
throw new Error(`${keypath} must be an array of strings`);
|
|
@@ -77,11 +77,6 @@ export async function prerender() {
|
|
|
77
77
|
/** @type {import('types').ValidatedKitConfig} */
|
|
78
78
|
const config = (await load_config()).kit;
|
|
79
79
|
|
|
80
|
-
if (!config.prerender.enabled) {
|
|
81
|
-
output_and_exit({ prerendered, prerender_map });
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
80
|
/** @type {import('types').Logger} */
|
|
86
81
|
const log = logger({
|
|
87
82
|
verbose: verbose === 'true'
|
|
@@ -111,8 +106,8 @@ export async function prerender() {
|
|
|
111
106
|
const manifest = (await import(pathToFileURL(manifest_path).href)).manifest;
|
|
112
107
|
|
|
113
108
|
override({
|
|
109
|
+
building: true,
|
|
114
110
|
paths: config.paths,
|
|
115
|
-
prerendering: true,
|
|
116
111
|
read: (file) => readFileSync(join(config.files.assets, file))
|
|
117
112
|
});
|
|
118
113
|
|
|
@@ -27,7 +27,7 @@ const server_template = ({ config, hooks, has_service_worker, runtime, template,
|
|
|
27
27
|
import root from '__GENERATED__/root.svelte';
|
|
28
28
|
import { respond } from '${runtime}/server/index.js';
|
|
29
29
|
import { set_paths, assets, base } from '${runtime}/paths.js';
|
|
30
|
-
import {
|
|
30
|
+
import { set_building, set_version } from '${runtime}/env.js';
|
|
31
31
|
import { set_private_env } from '${runtime}/env-private.js';
|
|
32
32
|
import { set_public_env } from '${runtime}/env-public.js';
|
|
33
33
|
|
|
@@ -53,7 +53,7 @@ let default_protocol = 'https';
|
|
|
53
53
|
export function override(settings) {
|
|
54
54
|
default_protocol = settings.protocol || default_protocol;
|
|
55
55
|
set_paths(settings.paths);
|
|
56
|
-
|
|
56
|
+
set_building(settings.building);
|
|
57
57
|
read = settings.read;
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -22,7 +22,7 @@ export function is_illegal(id, dirs) {
|
|
|
22
22
|
/**
|
|
23
23
|
* Creates a guard that checks that no id imports a module that is not allowed to be imported into client-side code.
|
|
24
24
|
* @param {import('rollup').PluginContext} context
|
|
25
|
-
* @param {{ cwd: string
|
|
25
|
+
* @param {{ cwd: string; lib: string }} paths
|
|
26
26
|
*/
|
|
27
27
|
export function module_guard(context, { cwd, lib }) {
|
|
28
28
|
/** @type {Set<string>} */
|
|
@@ -37,7 +37,7 @@ export function module_guard(context, { cwd, lib }) {
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* @param {string} id
|
|
40
|
-
* @param {Array<{ id: string
|
|
40
|
+
* @param {Array<{ id: string; dynamic: boolean }>} chain
|
|
41
41
|
*/
|
|
42
42
|
function follow(id, chain) {
|
|
43
43
|
if (seen.has(id)) return;
|
|
@@ -51,8 +51,8 @@ export function module_guard(context, { cwd, lib }) {
|
|
|
51
51
|
chain.map(({ id, dynamic }, i) => {
|
|
52
52
|
id = normalize_id(id, lib, cwd);
|
|
53
53
|
|
|
54
|
-
return `${
|
|
55
|
-
}) + `${
|
|
54
|
+
return `${' '.repeat(i * 2)}- ${id} ${dynamic ? 'dynamically imports' : 'imports'}\n`;
|
|
55
|
+
}) + `${' '.repeat(chain.length)}- ${id}`;
|
|
56
56
|
|
|
57
57
|
const message = `Cannot import ${id} into client-side code:\n${pyramid}`;
|
|
58
58
|
|
|
@@ -97,11 +97,3 @@ export function normalize_id(id, lib, cwd) {
|
|
|
97
97
|
|
|
98
98
|
return posixify(id);
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @param {string} str
|
|
103
|
-
* @param {number} times
|
|
104
|
-
*/
|
|
105
|
-
function repeat(str, times) {
|
|
106
|
-
return new Array(times + 1).join(str);
|
|
107
|
-
}
|
package/src/runtime/env.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export let
|
|
1
|
+
export let building = false;
|
|
2
2
|
export let version = '';
|
|
3
3
|
|
|
4
4
|
/** @param {boolean} value */
|
|
5
|
-
export function
|
|
6
|
-
|
|
5
|
+
export function set_building(value) {
|
|
6
|
+
building = value;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/** @param {string} value */
|
package/types/ambient.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ declare namespace App {
|
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* ```ts
|
|
70
|
-
* import { browser, dev,
|
|
70
|
+
* import { browser, building, dev, version } from '$app/environment';
|
|
71
71
|
* ```
|
|
72
72
|
*/
|
|
73
73
|
declare module '$app/environment' {
|
|
@@ -77,17 +77,17 @@ declare module '$app/environment' {
|
|
|
77
77
|
export const browser: boolean;
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* SvelteKit analyses your app during the `build` step by running it. During this process, `building` is `true`. This also applies during prerendering.
|
|
81
81
|
*/
|
|
82
|
-
export const
|
|
82
|
+
export const building: boolean;
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
85
|
+
* Whether the dev server is running. This is not guaranteed to correspond to `NODE_ENV` or `MODE`.
|
|
86
86
|
*/
|
|
87
|
-
export const
|
|
87
|
+
export const dev: boolean;
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
* The value of `config.kit.version.name
|
|
90
|
+
* The value of `config.kit.version.name`.
|
|
91
91
|
*/
|
|
92
92
|
export const version: string;
|
|
93
93
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -213,7 +213,6 @@ export interface KitConfig {
|
|
|
213
213
|
concurrency?: number;
|
|
214
214
|
crawl?: boolean;
|
|
215
215
|
default?: boolean;
|
|
216
|
-
enabled?: boolean;
|
|
217
216
|
entries?: Array<'*' | `/${string}`>;
|
|
218
217
|
handleHttpError?: PrerenderHttpErrorHandlerValue;
|
|
219
218
|
handleMissingId?: PrerenderMissingIdHandlerValue;
|
package/types/internal.d.ts
CHANGED
|
@@ -29,11 +29,11 @@ export interface ServerModule {
|
|
|
29
29
|
Server: typeof InternalServer;
|
|
30
30
|
|
|
31
31
|
override(options: {
|
|
32
|
+
building: boolean;
|
|
32
33
|
paths: {
|
|
33
34
|
base: string;
|
|
34
35
|
assets: string;
|
|
35
36
|
};
|
|
36
|
-
prerendering: boolean;
|
|
37
37
|
protocol?: 'http' | 'https';
|
|
38
38
|
read(file: string): Buffer;
|
|
39
39
|
}): void;
|