@sveltejs/kit 1.0.0-next.344 → 1.0.0-next.347
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/client/start.js +8 -2
- package/assets/server/index.js +2 -9
- package/dist/chunks/cert.js +136 -15
- package/dist/chunks/constants.js +1 -1
- package/dist/chunks/index.js +1266 -452
- package/dist/chunks/index2.js +88 -1360
- package/dist/chunks/index3.js +165 -99
- package/dist/chunks/index4.js +232 -148
- package/dist/chunks/index5.js +15690 -202
- package/dist/chunks/multipart-parser.js +2 -8
- package/dist/chunks/plugin.js +561 -0
- package/dist/chunks/sync.js +5 -4
- package/dist/cli.js +83 -57
- package/dist/node/polyfills.js +211 -71
- package/package.json +24 -9
- package/types/internal.d.ts +2 -0
- package/types/private.d.ts +2 -2
- package/dist/chunks/index6.js +0 -15749
package/dist/chunks/index3.js
CHANGED
|
@@ -1,118 +1,184 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { $ } from '../cli.js';
|
|
2
|
+
import { r as rimraf, m as mkdirp, c as copy } from './filesystem.js';
|
|
3
|
+
import { g as generate_manifest } from './index2.js';
|
|
4
|
+
import 'chokidar';
|
|
5
|
+
import 'fs';
|
|
6
|
+
import 'path';
|
|
7
|
+
import 'net';
|
|
8
|
+
import 'child_process';
|
|
9
|
+
import 'sade';
|
|
10
|
+
import 'vite';
|
|
11
|
+
import 'url';
|
|
12
|
+
import 'os';
|
|
13
|
+
import './misc.js';
|
|
3
14
|
|
|
4
15
|
/**
|
|
5
16
|
* @param {{
|
|
17
|
+
* config: import('types').ValidatedConfig;
|
|
6
18
|
* build_data: import('types').BuildData;
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* format?: 'esm' | 'cjs'
|
|
19
|
+
* prerendered: import('types').Prerendered;
|
|
20
|
+
* log: import('types').Logger;
|
|
10
21
|
* }} opts
|
|
22
|
+
* @returns {import('types').Builder}
|
|
11
23
|
*/
|
|
12
|
-
function
|
|
13
|
-
/** @
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
path
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
bundled_nodes.set(build_data.manifest_data.components[1], {
|
|
24
|
-
path: `${relative_path}/nodes/1.js`,
|
|
25
|
-
index: 1
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
routes.forEach((route) => {
|
|
29
|
-
if (route.type === 'page') {
|
|
30
|
-
[...route.a, ...route.b].forEach((component) => {
|
|
31
|
-
if (component && !bundled_nodes.has(component)) {
|
|
32
|
-
const i = build_data.manifest_data.components.indexOf(component);
|
|
33
|
-
|
|
34
|
-
bundled_nodes.set(component, {
|
|
35
|
-
path: `${relative_path}/nodes/${i}.js`,
|
|
36
|
-
index: bundled_nodes.size
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
});
|
|
24
|
+
function create_builder({ config, build_data, prerendered, log }) {
|
|
25
|
+
/** @type {Set<string>} */
|
|
26
|
+
const prerendered_paths = new Set(prerendered.paths);
|
|
27
|
+
|
|
28
|
+
/** @param {import('types').RouteData} route */
|
|
29
|
+
// TODO routes should come pre-filtered
|
|
30
|
+
function not_prerendered(route) {
|
|
31
|
+
if (route.type === 'page' && route.path) {
|
|
32
|
+
return !prerendered_paths.has(route.path);
|
|
40
33
|
}
|
|
41
|
-
});
|
|
42
34
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
format === 'esm'
|
|
46
|
-
? (path) => `import('${path}')`
|
|
47
|
-
: (path) => `Promise.resolve().then(() => require('${path}'))`;
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
48
37
|
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
return {
|
|
39
|
+
log,
|
|
40
|
+
rimraf,
|
|
41
|
+
mkdirp,
|
|
42
|
+
copy,
|
|
51
43
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
assets.push(build_data.service_worker);
|
|
55
|
-
}
|
|
44
|
+
config,
|
|
45
|
+
prerendered,
|
|
56
46
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
47
|
+
async createEntries(fn) {
|
|
48
|
+
const { routes } = build_data.manifest_data;
|
|
49
|
+
|
|
50
|
+
/** @type {import('types').RouteDefinition[]} */
|
|
51
|
+
const facades = routes.map((route) => ({
|
|
52
|
+
id: route.id,
|
|
53
|
+
type: route.type,
|
|
54
|
+
segments: route.id.split('/').map((segment) => ({
|
|
55
|
+
dynamic: segment.includes('['),
|
|
56
|
+
rest: segment.includes('[...'),
|
|
57
|
+
content: segment
|
|
58
|
+
})),
|
|
59
|
+
pattern: route.pattern,
|
|
60
|
+
methods: route.type === 'page' ? ['get'] : build_data.server.methods[route.file]
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
const seen = new Set();
|
|
64
|
+
|
|
65
|
+
for (let i = 0; i < routes.length; i += 1) {
|
|
66
|
+
const route = routes[i];
|
|
67
|
+
const { id, filter, complete } = fn(facades[i]);
|
|
68
|
+
|
|
69
|
+
if (seen.has(id)) continue;
|
|
70
|
+
seen.add(id);
|
|
79
71
|
|
|
72
|
+
const group = [route];
|
|
73
|
+
|
|
74
|
+
// figure out which lower priority routes should be considered fallbacks
|
|
75
|
+
for (let j = i + 1; j < routes.length; j += 1) {
|
|
76
|
+
if (filter(facades[j])) {
|
|
77
|
+
group.push(routes[j]);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const filtered = new Set(group.filter(not_prerendered));
|
|
82
|
+
|
|
83
|
+
// heuristic: if /foo/[bar] is included, /foo/[bar].json should
|
|
84
|
+
// also be included, since the page likely needs the endpoint
|
|
85
|
+
filtered.forEach((route) => {
|
|
80
86
|
if (route.type === 'page') {
|
|
81
|
-
|
|
82
|
-
type: 'page',
|
|
83
|
-
id: ${s(route.id)},
|
|
84
|
-
pattern: ${pattern},
|
|
85
|
-
names: ${s(names)},
|
|
86
|
-
types: ${s(types)},
|
|
87
|
-
path: ${route.path ? s(route.path) : null},
|
|
88
|
-
shadow: ${route.shadow ? loader(`${relative_path}/${build_data.server.vite_manifest[route.shadow].file}`) : null},
|
|
89
|
-
a: ${s(route.a.map(get_index))},
|
|
90
|
-
b: ${s(route.b.map(get_index))}
|
|
91
|
-
}`.replace(/^\t\t/gm, '');
|
|
92
|
-
} else {
|
|
93
|
-
if (!build_data.server.vite_manifest[route.file]) {
|
|
94
|
-
// this is necessary in cases where a .css file snuck in —
|
|
95
|
-
// perhaps it would be better to disallow these (and others?)
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
87
|
+
const endpoint = routes.find((candidate) => candidate.id === route.id + '.json');
|
|
98
88
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
pattern: ${pattern},
|
|
103
|
-
names: ${s(names)},
|
|
104
|
-
types: ${s(types)},
|
|
105
|
-
load: ${loader(`${relative_path}/${build_data.server.vite_manifest[route.file].file}`)}
|
|
106
|
-
}`.replace(/^\t\t/gm, '');
|
|
89
|
+
if (endpoint) {
|
|
90
|
+
filtered.add(endpoint);
|
|
91
|
+
}
|
|
107
92
|
}
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
if (filtered.size > 0) {
|
|
96
|
+
await complete({
|
|
97
|
+
generateManifest: ({ relativePath, format }) =>
|
|
98
|
+
generate_manifest({
|
|
99
|
+
build_data,
|
|
100
|
+
relative_path: relativePath,
|
|
101
|
+
routes: Array.from(filtered),
|
|
102
|
+
format
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
}
|
|
113
106
|
}
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
generateManifest: ({ relativePath, format }) => {
|
|
110
|
+
return generate_manifest({
|
|
111
|
+
build_data,
|
|
112
|
+
relative_path: relativePath,
|
|
113
|
+
routes: build_data.manifest_data.routes.filter(not_prerendered),
|
|
114
|
+
format
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
getBuildDirectory(name) {
|
|
119
|
+
return `${config.kit.outDir}/${name}`;
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
getClientDirectory() {
|
|
123
|
+
return `${config.kit.outDir}/output/client`;
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
getServerDirectory() {
|
|
127
|
+
return `${config.kit.outDir}/output/server`;
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
getStaticDirectory() {
|
|
131
|
+
return config.kit.files.assets;
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
writeClient(dest) {
|
|
135
|
+
return copy(`${config.kit.outDir}/output/client`, dest);
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
writePrerendered(dest, { fallback } = {}) {
|
|
139
|
+
const source = `${config.kit.outDir}/output/prerendered`;
|
|
140
|
+
const files = [...copy(`${source}/pages`, dest), ...copy(`${source}/dependencies`, dest)];
|
|
141
|
+
|
|
142
|
+
if (fallback) {
|
|
143
|
+
files.push(fallback);
|
|
144
|
+
copy(`${source}/fallback.html`, `${dest}/${fallback}`);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return files;
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
writeServer(dest) {
|
|
151
|
+
return copy(`${config.kit.outDir}/output/server`, dest);
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
writeStatic(dest) {
|
|
155
|
+
return copy(config.kit.files.assets, dest);
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
// @ts-expect-error
|
|
159
|
+
async prerender() {
|
|
160
|
+
throw new Error(
|
|
161
|
+
'builder.prerender() has been removed. Prerendering now takes place in the build phase — see builder.prerender and builder.writePrerendered'
|
|
162
|
+
);
|
|
114
163
|
}
|
|
115
|
-
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @param {import('types').ValidatedConfig} config
|
|
169
|
+
* @param {import('types').BuildData} build_data
|
|
170
|
+
* @param {import('types').Prerendered} prerendered
|
|
171
|
+
* @param {{ log: import('types').Logger }} opts
|
|
172
|
+
*/
|
|
173
|
+
async function adapt(config, build_data, prerendered, { log }) {
|
|
174
|
+
const { name, adapt } = config.kit.adapter;
|
|
175
|
+
|
|
176
|
+
console.log($.bold().cyan(`\n> Using ${name}`));
|
|
177
|
+
|
|
178
|
+
const builder = create_builder({ config, build_data, prerendered, log });
|
|
179
|
+
await adapt(builder);
|
|
180
|
+
|
|
181
|
+
log.success('done');
|
|
116
182
|
}
|
|
117
183
|
|
|
118
|
-
export {
|
|
184
|
+
export { adapt };
|