@sveltejs/kit 1.0.0-next.490 → 1.0.0-next.491
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
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { s } from '../../utils/misc.js';
|
|
2
2
|
import { get_mime_lookup } from '../utils.js';
|
|
3
|
+
import { resolve_symlinks } from '../../exports/vite/build/utils.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Generates the data used to write the server-side manifest.js file. This data is used in the Vite
|
|
@@ -65,7 +66,7 @@ export function generate_manifest({ build_data, relative_path, routes, format =
|
|
|
65
66
|
names: ${s(route.names)},
|
|
66
67
|
types: ${s(route.types)},
|
|
67
68
|
page: ${route.page ? `{ layouts: ${get_nodes(route.page.layouts)}, errors: ${get_nodes(route.page.errors)}, leaf: ${route.page.leaf} }` : 'null'},
|
|
68
|
-
endpoint: ${route.endpoint ? loader(`${relative_path}/${build_data.server.vite_manifest
|
|
69
|
+
endpoint: ${route.endpoint ? loader(`${relative_path}/${resolve_symlinks(build_data.server.vite_manifest, route.endpoint.file).chunk.file}`) : 'null'}
|
|
69
70
|
}`;
|
|
70
71
|
}).filter(Boolean).join(',\n\t\t\t\t')}
|
|
71
72
|
],
|
|
@@ -164,13 +164,16 @@ function create_routes_and_nodes(cwd, config, fallback) {
|
|
|
164
164
|
|
|
165
165
|
const dir = path.join(cwd, routes_base, id);
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
// We can't use withFileTypes because of a NodeJs bug which returns wrong results
|
|
168
|
+
// with isDirectory() in case of symlinks: https://github.com/nodejs/node/issues/30646
|
|
169
|
+
const files = fs.readdirSync(dir).map((name) => ({
|
|
170
|
+
is_dir: fs.statSync(path.join(dir, name)).isDirectory(),
|
|
171
|
+
name
|
|
172
|
+
}));
|
|
170
173
|
|
|
171
174
|
// process files first
|
|
172
175
|
for (const file of files) {
|
|
173
|
-
if (file.
|
|
176
|
+
if (file.is_dir) continue;
|
|
174
177
|
if (!file.name.startsWith('+')) continue;
|
|
175
178
|
if (!valid_extensions.find((ext) => file.name.endsWith(ext))) continue;
|
|
176
179
|
|
|
@@ -213,7 +216,7 @@ function create_routes_and_nodes(cwd, config, fallback) {
|
|
|
213
216
|
|
|
214
217
|
// then handle children
|
|
215
218
|
for (const file of files) {
|
|
216
|
-
if (file.
|
|
219
|
+
if (file.is_dir) {
|
|
217
220
|
walk(depth + 1, path.posix.join(id, file.name), file.name, route);
|
|
218
221
|
}
|
|
219
222
|
}
|
|
@@ -4,7 +4,13 @@ import { mkdirp, posixify, resolve_entry } from '../../../utils/filesystem.js';
|
|
|
4
4
|
import { get_vite_config, merge_vite_configs } from '../utils.js';
|
|
5
5
|
import { load_error_page, load_template } from '../../../core/config/index.js';
|
|
6
6
|
import { runtime_directory } from '../../../core/utils.js';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
create_build,
|
|
9
|
+
find_deps,
|
|
10
|
+
get_default_build_config,
|
|
11
|
+
is_http_method,
|
|
12
|
+
resolve_symlinks
|
|
13
|
+
} from './utils.js';
|
|
8
14
|
import { s } from '../../../utils/misc.js';
|
|
9
15
|
|
|
10
16
|
/**
|
|
@@ -285,7 +291,7 @@ export async function build_server(options, client) {
|
|
|
285
291
|
|
|
286
292
|
exports.push(
|
|
287
293
|
`export const component = async () => (await import('../${
|
|
288
|
-
vite_manifest
|
|
294
|
+
resolve_symlinks(vite_manifest, node.component).chunk.file
|
|
289
295
|
}')).default;`,
|
|
290
296
|
`export const file = '${entry.file}';` // TODO what is this?
|
|
291
297
|
);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
1
3
|
import * as vite from 'vite';
|
|
2
4
|
import { get_aliases } from '../utils.js';
|
|
3
5
|
|
|
@@ -44,14 +46,14 @@ export function find_deps(manifest, entry, add_dynamic_css) {
|
|
|
44
46
|
const stylesheets = new Set();
|
|
45
47
|
|
|
46
48
|
/**
|
|
47
|
-
* @param {string}
|
|
49
|
+
* @param {string} current
|
|
48
50
|
* @param {boolean} add_js
|
|
49
51
|
*/
|
|
50
|
-
function traverse(
|
|
51
|
-
if (seen.has(
|
|
52
|
-
seen.add(
|
|
52
|
+
function traverse(current, add_js) {
|
|
53
|
+
if (seen.has(current)) return;
|
|
54
|
+
seen.add(current);
|
|
53
55
|
|
|
54
|
-
const chunk = manifest
|
|
56
|
+
const { chunk } = resolve_symlinks(manifest, current);
|
|
55
57
|
|
|
56
58
|
if (add_js) imports.add(chunk.file);
|
|
57
59
|
|
|
@@ -68,15 +70,31 @@ export function find_deps(manifest, entry, add_dynamic_css) {
|
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
const { chunk, file } = resolve_symlinks(manifest, entry);
|
|
74
|
+
|
|
75
|
+
traverse(file, true);
|
|
72
76
|
|
|
73
77
|
return {
|
|
74
|
-
file:
|
|
78
|
+
file: chunk.file,
|
|
75
79
|
imports: Array.from(imports),
|
|
76
80
|
stylesheets: Array.from(stylesheets)
|
|
77
81
|
};
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
/**
|
|
85
|
+
* @param {import('vite').Manifest} manifest
|
|
86
|
+
* @param {string} file
|
|
87
|
+
*/
|
|
88
|
+
export function resolve_symlinks(manifest, file) {
|
|
89
|
+
while (!manifest[file]) {
|
|
90
|
+
file = path.relative('.', fs.realpathSync(file));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const chunk = manifest[file];
|
|
94
|
+
|
|
95
|
+
return { chunk, file };
|
|
96
|
+
}
|
|
97
|
+
|
|
80
98
|
/**
|
|
81
99
|
* The Vite configuration that we use by default.
|
|
82
100
|
* @param {{
|