@sveltejs/kit 1.0.0-next.401 → 1.0.0-next.405
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/assets/server/index.js +31 -21
- package/dist/chunks/index3.js +46 -4
- package/dist/chunks/sync.js +0 -2
- package/dist/cli.js +1 -1
- package/dist/node/polyfills.js +224 -74
- package/dist/vite.js +21 -28
- package/package.json +4 -3
- package/types/index.d.ts +5 -0
package/assets/server/index.js
CHANGED
|
@@ -1360,6 +1360,9 @@ async function render_response({
|
|
|
1360
1360
|
const stylesheets = new Set(entry.stylesheets);
|
|
1361
1361
|
const modulepreloads = new Set(entry.imports);
|
|
1362
1362
|
|
|
1363
|
+
/** @type {Set<string>} */
|
|
1364
|
+
const link_header_preloads = new Set();
|
|
1365
|
+
|
|
1363
1366
|
/** @type {Map<string, string>} */
|
|
1364
1367
|
// TODO if we add a client entry point one day, we will need to include inline_styles with the entry, otherwise stylesheets will be linked even if they are below inlineStyleThreshold
|
|
1365
1368
|
const inline_styles = new Map();
|
|
@@ -1519,32 +1522,35 @@ async function render_response({
|
|
|
1519
1522
|
head += `\n\t<style${attributes.join('')}>${content}</style>`;
|
|
1520
1523
|
}
|
|
1521
1524
|
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
const attributes = [
|
|
1526
|
-
'rel="stylesheet"',
|
|
1527
|
-
`href="${options.prefix + dep}"`
|
|
1528
|
-
];
|
|
1525
|
+
for (const dep of stylesheets) {
|
|
1526
|
+
const path = options.prefix + dep;
|
|
1527
|
+
const attributes = [];
|
|
1529
1528
|
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1529
|
+
if (csp.style_needs_nonce) {
|
|
1530
|
+
attributes.push(`nonce="${csp.nonce}"`);
|
|
1531
|
+
}
|
|
1533
1532
|
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1533
|
+
if (inline_styles.has(dep)) {
|
|
1534
|
+
// don't load stylesheets that are already inlined
|
|
1535
|
+
// include them in disabled state so that Vite can detect them and doesn't try to add them
|
|
1536
|
+
attributes.push('disabled', 'media="(max-width: 0)"');
|
|
1537
|
+
} else {
|
|
1538
|
+
const preload_atts = ['rel="preload"', 'as="style"'].concat(attributes);
|
|
1539
|
+
link_header_preloads.add(`<${encodeURI(path)}>; ${preload_atts.join(';')}; nopush`);
|
|
1540
|
+
}
|
|
1539
1541
|
|
|
1540
|
-
|
|
1541
|
-
})
|
|
1542
|
-
|
|
1542
|
+
attributes.unshift('rel="stylesheet"');
|
|
1543
|
+
head += `\n\t<link href="${path}" ${attributes.join(' ')}>`;
|
|
1544
|
+
}
|
|
1543
1545
|
|
|
1544
1546
|
if (page_config.router || page_config.hydrate) {
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
.
|
|
1547
|
+
for (const dep of modulepreloads) {
|
|
1548
|
+
const path = options.prefix + dep;
|
|
1549
|
+
link_header_preloads.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`);
|
|
1550
|
+
if (state.prerendering) {
|
|
1551
|
+
head += `\n\t<link rel="modulepreload" href="${path}">`;
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1548
1554
|
|
|
1549
1555
|
const attributes = ['type="module"', `data-sveltekit-hydrate="${target}"`];
|
|
1550
1556
|
|
|
@@ -1611,6 +1617,10 @@ async function render_response({
|
|
|
1611
1617
|
etag: `"${hash(html)}"`
|
|
1612
1618
|
});
|
|
1613
1619
|
|
|
1620
|
+
if (link_header_preloads.size) {
|
|
1621
|
+
headers.set('link', Array.from(link_header_preloads).join(', '));
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1614
1624
|
if (cache) {
|
|
1615
1625
|
headers.set('cache-control', `${is_private ? 'private' : 'public'}, max-age=${cache.maxage}`);
|
|
1616
1626
|
}
|
package/dist/chunks/index3.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { $ } from './index.js';
|
|
2
|
+
import glob from 'tiny-glob';
|
|
3
|
+
import zlib from 'zlib';
|
|
4
|
+
import { existsSync, statSync, createReadStream, createWriteStream } from 'fs';
|
|
5
|
+
import { pipeline } from 'stream';
|
|
6
|
+
import { promisify } from 'util';
|
|
2
7
|
import { r as rimraf, m as mkdirp, c as copy } from './filesystem.js';
|
|
3
8
|
import { g as generate_manifest } from '../vite.js';
|
|
4
|
-
import 'fs';
|
|
5
9
|
import 'path';
|
|
6
10
|
import 'url';
|
|
7
11
|
import 'node:child_process';
|
|
@@ -18,9 +22,7 @@ import '../node/polyfills.js';
|
|
|
18
22
|
import 'assert';
|
|
19
23
|
import 'net';
|
|
20
24
|
import 'http';
|
|
21
|
-
import 'stream';
|
|
22
25
|
import 'buffer';
|
|
23
|
-
import 'util';
|
|
24
26
|
import 'stream/web';
|
|
25
27
|
import 'perf_hooks';
|
|
26
28
|
import 'util/types';
|
|
@@ -28,7 +30,6 @@ import 'events';
|
|
|
28
30
|
import 'tls';
|
|
29
31
|
import 'async_hooks';
|
|
30
32
|
import 'console';
|
|
31
|
-
import 'zlib';
|
|
32
33
|
import 'node:http';
|
|
33
34
|
import 'node:https';
|
|
34
35
|
import 'node:zlib';
|
|
@@ -64,6 +65,30 @@ function create_builder({ config, build_data, prerendered, log }) {
|
|
|
64
65
|
return true;
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
const pipe = promisify(pipeline);
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @param {string} file
|
|
72
|
+
* @param {'gz' | 'br'} format
|
|
73
|
+
*/
|
|
74
|
+
async function compress_file(file, format = 'gz') {
|
|
75
|
+
const compress =
|
|
76
|
+
format == 'br'
|
|
77
|
+
? zlib.createBrotliCompress({
|
|
78
|
+
params: {
|
|
79
|
+
[zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT,
|
|
80
|
+
[zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY,
|
|
81
|
+
[zlib.constants.BROTLI_PARAM_SIZE_HINT]: statSync(file).size
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
: zlib.createGzip({ level: zlib.constants.Z_BEST_COMPRESSION });
|
|
85
|
+
|
|
86
|
+
const source = createReadStream(file);
|
|
87
|
+
const destination = createWriteStream(`${file}.${format}`);
|
|
88
|
+
|
|
89
|
+
await pipe(source, compress, destination);
|
|
90
|
+
}
|
|
91
|
+
|
|
67
92
|
return {
|
|
68
93
|
log,
|
|
69
94
|
rimraf,
|
|
@@ -190,6 +215,23 @@ function create_builder({ config, build_data, prerendered, log }) {
|
|
|
190
215
|
);
|
|
191
216
|
},
|
|
192
217
|
|
|
218
|
+
async compress(directory) {
|
|
219
|
+
if (!existsSync(directory)) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const files = await glob('**/*.{html,js,json,css,svg,xml,wasm}', {
|
|
224
|
+
cwd: directory,
|
|
225
|
+
dot: true,
|
|
226
|
+
absolute: true,
|
|
227
|
+
filesOnly: true
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
await Promise.all(
|
|
231
|
+
files.map((file) => Promise.all([compress_file(file, 'gz'), compress_file(file, 'br')]))
|
|
232
|
+
);
|
|
233
|
+
},
|
|
234
|
+
|
|
193
235
|
async prerender() {
|
|
194
236
|
throw new Error(
|
|
195
237
|
'builder.prerender() has been removed. Prerendering now takes place in the build phase — see builder.prerender and builder.writePrerendered'
|
package/dist/chunks/sync.js
CHANGED
|
@@ -1169,7 +1169,6 @@ const find_illegal_rollup_imports = (
|
|
|
1169
1169
|
if (chain) return [{ name, dynamic }, ...chain];
|
|
1170
1170
|
}
|
|
1171
1171
|
|
|
1172
|
-
seen.delete(name);
|
|
1173
1172
|
return null;
|
|
1174
1173
|
};
|
|
1175
1174
|
|
|
@@ -1231,7 +1230,6 @@ function find_illegal_vite_imports(node, illegal_imports, module_types, seen = n
|
|
|
1231
1230
|
if (chain) return [{ name, dynamic: false }, ...chain];
|
|
1232
1231
|
}
|
|
1233
1232
|
|
|
1234
|
-
seen.delete(name);
|
|
1235
1233
|
return null;
|
|
1236
1234
|
}
|
|
1237
1235
|
|