@sveltejs/kit 1.3.6 → 1.3.7
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 +4 -2
- package/src/cli.js +2 -2
- package/src/core/adapt/builder.js +3 -3
- package/src/core/config/index.js +3 -3
- package/src/core/config/options.js +1 -1
- package/src/core/postbuild/analyse.js +2 -2
- package/src/core/postbuild/fallback.js +3 -3
- package/src/core/postbuild/prerender.js +9 -0
- package/src/core/sync/create_manifest_data/index.js +2 -2
- package/src/core/sync/sync.js +1 -1
- package/src/core/sync/utils.js +2 -2
- package/src/core/sync/write_ambient.js +3 -3
- package/src/core/sync/write_tsconfig.js +2 -2
- package/src/core/sync/write_types/index.js +2 -2
- package/src/core/utils.js +2 -2
- package/src/exports/node/polyfills.js +2 -2
- package/src/exports/vite/build/build_service_worker.js +1 -1
- package/src/exports/vite/dev/index.js +3 -3
- package/src/exports/vite/graph_analysis/index.js +1 -1
- package/src/exports/vite/index.js +16 -18
- package/src/exports/vite/preview/index.js +3 -3
- package/src/exports/vite/utils.js +1 -1
- package/src/runtime/client/client.js +2 -1
- package/src/utils/filesystem.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/kit",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
"@types/node": "^16.18.6",
|
|
33
33
|
"@types/sade": "^1.7.4",
|
|
34
34
|
"@types/set-cookie-parser": "^2.4.2",
|
|
35
|
+
"eslint": "^8.33.0",
|
|
36
|
+
"eslint-plugin-unicorn": "^45.0.2",
|
|
35
37
|
"marked": "^4.2.3",
|
|
36
38
|
"rollup": "^3.7.0",
|
|
37
39
|
"svelte": "^3.55.1",
|
|
@@ -80,7 +82,7 @@
|
|
|
80
82
|
"node": "^16.14 || >=18"
|
|
81
83
|
},
|
|
82
84
|
"scripts": {
|
|
83
|
-
"lint": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
|
|
85
|
+
"lint": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore && eslint src/**",
|
|
84
86
|
"check": "tsc",
|
|
85
87
|
"check:all": "tsc && pnpm -r --filter=\"./**\" check",
|
|
86
88
|
"format": "pnpm lint --write",
|
package/src/cli.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { fork } from 'node:child_process';
|
|
1
2
|
import { existsSync, statSync, createReadStream, createWriteStream } from 'node:fs';
|
|
2
3
|
import { pipeline } from 'node:stream';
|
|
3
|
-
import { promisify } from 'node:util';
|
|
4
|
-
import { fork } from 'node:child_process';
|
|
5
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { promisify } from 'node:util';
|
|
6
|
+
import zlib from 'node:zlib';
|
|
6
7
|
import glob from 'tiny-glob';
|
|
7
|
-
import zlib from 'zlib';
|
|
8
8
|
import { copy, rimraf, mkdirp } from '../../utils/filesystem.js';
|
|
9
9
|
import { generate_manifest } from '../generate_manifest/index.js';
|
|
10
10
|
import { get_route_segments } from '../../utils/routing.js';
|
package/src/core/config/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync } from 'fs';
|
|
2
|
-
import { dirname, join } from 'path';
|
|
3
|
-
import { pathToFileURL } from 'url';
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
4
|
import { mkdirp } from '../../utils/filesystem.js';
|
|
5
5
|
import { installPolyfills } from '../../exports/node/polyfills.js';
|
|
6
6
|
import { load_config } from '../config/index.js';
|
|
@@ -361,6 +361,15 @@ async function prerender({ out, manifest_path, metadata, verbose, env }) {
|
|
|
361
361
|
saved.set(file, dest);
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
+
if (
|
|
365
|
+
config.prerender.entries.length > 1 ||
|
|
366
|
+
config.prerender.entries[0] !== '*' ||
|
|
367
|
+
prerender_map.size > 0
|
|
368
|
+
) {
|
|
369
|
+
// Only log if we're actually going to do something to not confuse users
|
|
370
|
+
log.info('Prerendering');
|
|
371
|
+
}
|
|
372
|
+
|
|
364
373
|
for (const entry of config.prerender.entries) {
|
|
365
374
|
if (entry === '*') {
|
|
366
375
|
for (const [id, prerender] of prerender_map) {
|
package/src/core/sync/sync.js
CHANGED
package/src/core/sync/utils.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
3
4
|
import { get_env } from '../../exports/vite/utils.js';
|
|
4
5
|
import { GENERATED_COMMENT } from '../../constants.js';
|
|
5
6
|
import { create_dynamic_types, create_static_types } from '../env.js';
|
|
6
7
|
import { write_if_changed } from './utils.js';
|
|
7
|
-
import { fileURLToPath } from 'url';
|
|
8
8
|
|
|
9
9
|
// TODO these types should be described in a neutral place, rather than
|
|
10
10
|
// inside either `packages/kit` or `kit.svelte.dev`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
3
|
import MagicString from 'magic-string';
|
|
4
4
|
import { posixify, rimraf, walk } from '../../../utils/filesystem.js';
|
|
5
5
|
import { compact } from '../../../utils/array.js';
|
package/src/core/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ReadableStream, TransformStream, WritableStream } from 'node:stream/web';
|
|
2
|
+
import { webcrypto as crypto } from 'node:crypto';
|
|
1
3
|
import { fetch, Response, Request, Headers, FormData } from 'undici';
|
|
2
|
-
import { ReadableStream, TransformStream, WritableStream } from 'stream/web';
|
|
3
|
-
import { webcrypto as crypto } from 'crypto';
|
|
4
4
|
|
|
5
5
|
/** @type {Record<string, any>} */
|
|
6
6
|
const globals = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { URL } from 'node:url';
|
|
2
4
|
import colors from 'kleur';
|
|
3
|
-
import path from 'path';
|
|
4
5
|
import sirv from 'sirv';
|
|
5
|
-
import { URL } from 'url';
|
|
6
6
|
import { isCSSRequest, loadEnv } from 'vite';
|
|
7
7
|
import { getRequest, setResponse } from '../../../exports/node/index.js';
|
|
8
8
|
import { installPolyfills } from '../../../exports/node/polyfills.js';
|
|
@@ -139,10 +139,7 @@ export async function sveltekit() {
|
|
|
139
139
|
return [...svelte(vite_plugin_svelte_options), ...kit({ svelte_config })];
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
* If `true`, the server build has been completed and we're creating the client build
|
|
144
|
-
*/
|
|
145
|
-
let secondary_build = false;
|
|
142
|
+
let secondary_build_started = false;
|
|
146
143
|
|
|
147
144
|
/**
|
|
148
145
|
* Returns the SvelteKit Vite plugin. Vite executes Rollup hooks as well as some of its own.
|
|
@@ -176,8 +173,8 @@ function kit({ svelte_config }) {
|
|
|
176
173
|
/** @type {{ public: Record<string, string>; private: Record<string, string> }} */
|
|
177
174
|
let env;
|
|
178
175
|
|
|
179
|
-
/** @type {(
|
|
180
|
-
let finalise
|
|
176
|
+
/** @type {() => Promise<void>} */
|
|
177
|
+
let finalise;
|
|
181
178
|
|
|
182
179
|
const service_worker_entry_file = resolve_entry(kit.files.serviceWorker);
|
|
183
180
|
|
|
@@ -251,7 +248,7 @@ function kit({ svelte_config }) {
|
|
|
251
248
|
|
|
252
249
|
if (is_build) {
|
|
253
250
|
if (!new_config.build) new_config.build = {};
|
|
254
|
-
new_config.build.ssr = !
|
|
251
|
+
new_config.build.ssr = !secondary_build_started;
|
|
255
252
|
|
|
256
253
|
new_config.define = {
|
|
257
254
|
__SVELTEKIT_ADAPTER_NAME__: JSON.stringify(kit.adapter?.name),
|
|
@@ -363,7 +360,7 @@ function kit({ svelte_config }) {
|
|
|
363
360
|
writeBundle: {
|
|
364
361
|
sequential: true,
|
|
365
362
|
async handler(_options) {
|
|
366
|
-
if (
|
|
363
|
+
if (vite_config.build.ssr) return;
|
|
367
364
|
|
|
368
365
|
const guard = module_guard(this, {
|
|
369
366
|
cwd: vite.normalizePath(process.cwd()),
|
|
@@ -535,10 +532,7 @@ function kit({ svelte_config }) {
|
|
|
535
532
|
* Clears the output directories.
|
|
536
533
|
*/
|
|
537
534
|
buildStart() {
|
|
538
|
-
if (
|
|
539
|
-
|
|
540
|
-
// reset (here, not in `config`, because `build --watch` skips `config`)
|
|
541
|
-
finalise = null;
|
|
535
|
+
if (secondary_build_started) return;
|
|
542
536
|
|
|
543
537
|
if (is_build) {
|
|
544
538
|
if (!vite_config.build.watch) {
|
|
@@ -549,7 +543,7 @@ function kit({ svelte_config }) {
|
|
|
549
543
|
},
|
|
550
544
|
|
|
551
545
|
generateBundle() {
|
|
552
|
-
if (
|
|
546
|
+
if (vite_config.build.ssr) return;
|
|
553
547
|
|
|
554
548
|
this.emitFile({
|
|
555
549
|
type: 'asset',
|
|
@@ -566,8 +560,7 @@ function kit({ svelte_config }) {
|
|
|
566
560
|
writeBundle: {
|
|
567
561
|
sequential: true,
|
|
568
562
|
async handler(_options) {
|
|
569
|
-
if (
|
|
570
|
-
secondary_build = true;
|
|
563
|
+
if (secondary_build_started) return; // only run this once
|
|
571
564
|
|
|
572
565
|
const verbose = vite_config.logLevel === 'info';
|
|
573
566
|
const log = logger({ verbose });
|
|
@@ -596,6 +589,8 @@ function kit({ svelte_config }) {
|
|
|
596
589
|
);
|
|
597
590
|
|
|
598
591
|
// first, build server nodes without the client manifest so we can analyse it
|
|
592
|
+
log.info('Analysing routes');
|
|
593
|
+
|
|
599
594
|
build_server_nodes(out, kit, manifest_data, server_manifest, null, null);
|
|
600
595
|
|
|
601
596
|
const metadata = await analyse({
|
|
@@ -603,6 +598,8 @@ function kit({ svelte_config }) {
|
|
|
603
598
|
env: { ...env.private, ...env.public }
|
|
604
599
|
});
|
|
605
600
|
|
|
601
|
+
log.info('Building app');
|
|
602
|
+
|
|
606
603
|
// create client build
|
|
607
604
|
write_client_manifest(
|
|
608
605
|
kit,
|
|
@@ -611,6 +608,8 @@ function kit({ svelte_config }) {
|
|
|
611
608
|
metadata.nodes
|
|
612
609
|
);
|
|
613
610
|
|
|
611
|
+
secondary_build_started = true;
|
|
612
|
+
|
|
614
613
|
const { output } = /** @type {import('rollup').RollupOutput} */ (
|
|
615
614
|
await vite.build({
|
|
616
615
|
configFile: vite_config.configFile,
|
|
@@ -649,8 +648,6 @@ function kit({ svelte_config }) {
|
|
|
649
648
|
build_server_nodes(out, kit, manifest_data, server_manifest, client_manifest, css);
|
|
650
649
|
|
|
651
650
|
// ...and prerender
|
|
652
|
-
log.info('Prerendering');
|
|
653
|
-
|
|
654
651
|
const { prerendered, prerender_map } = await prerender({
|
|
655
652
|
out,
|
|
656
653
|
manifest_path,
|
|
@@ -721,7 +718,8 @@ function kit({ svelte_config }) {
|
|
|
721
718
|
closeBundle: {
|
|
722
719
|
sequential: true,
|
|
723
720
|
async handler() {
|
|
724
|
-
|
|
721
|
+
if (!vite_config.build.ssr) return;
|
|
722
|
+
await finalise();
|
|
725
723
|
}
|
|
726
724
|
}
|
|
727
725
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
3
4
|
import sirv from 'sirv';
|
|
4
|
-
import { pathToFileURL } from 'url';
|
|
5
5
|
import { loadEnv, normalizePath } from 'vite';
|
|
6
6
|
import { getRequest, setResponse } from '../../../exports/node/index.js';
|
|
7
7
|
import { installPolyfills } from '../../../exports/node/polyfills.js';
|
|
@@ -343,7 +343,8 @@ export function create_client({ target, base }) {
|
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
if (autoscroll) {
|
|
346
|
-
const deep_linked =
|
|
346
|
+
const deep_linked =
|
|
347
|
+
url.hash && document.getElementById(decodeURIComponent(url.hash.slice(1)));
|
|
347
348
|
if (scroll) {
|
|
348
349
|
scrollTo(scroll.x, scroll.y);
|
|
349
350
|
} else if (deep_linked) {
|
package/src/utils/filesystem.js
CHANGED