@sveltejs/kit 1.0.0-next.406 → 1.0.0-next.409
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/sync/create_manifest_data/index.js +1 -1
- package/src/core/sync/write_types.js +17 -27
- package/src/index/private.js +2 -0
- package/src/packaging/utils.js +5 -0
- package/src/runtime/server/page/index.js +7 -12
- package/src/vite/build/build_server.js +3 -1
- package/src/vite/build/utils.js +2 -1
- package/src/vite/index.js +5 -1
package/package.json
CHANGED
|
@@ -362,7 +362,7 @@ function trace(tree, id, layout_id = DEFAULT, project_relative) {
|
|
|
362
362
|
layouts.unshift(layout);
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
-
const parent_layout_id = layout?.component?.split('@')[1]?.split('.')[0];
|
|
365
|
+
const parent_layout_id = layout?.component?.split('/').at(-1)?.split('@')[1]?.split('.')[0];
|
|
366
366
|
|
|
367
367
|
if (parent_layout_id) {
|
|
368
368
|
layout_id = parent_layout_id;
|
|
@@ -390,18 +390,13 @@ function process_node(ts, node, outdir, params, groups) {
|
|
|
390
390
|
const types = [];
|
|
391
391
|
for (const method of ['POST', 'PUT', 'PATCH']) {
|
|
392
392
|
if (proxy.exports.includes(method)) {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
outdir,
|
|
401
|
-
node.server
|
|
402
|
-
)}").${method}>`
|
|
403
|
-
);
|
|
404
|
-
}
|
|
393
|
+
// If the file wasn't tweaked, we can use the return type of the original file.
|
|
394
|
+
// The advantage is that type updates are reflected without saving.
|
|
395
|
+
const from = proxy.modified
|
|
396
|
+
? `./proxy${replace_ext_with_js(basename)}`
|
|
397
|
+
: path_to_original(outdir, node.server);
|
|
398
|
+
|
|
399
|
+
types.push(`Kit.AwaitedErrors<typeof import('${from}').${method}>`);
|
|
405
400
|
}
|
|
406
401
|
}
|
|
407
402
|
errors = types.length ? types.join(' | ') : 'null';
|
|
@@ -494,18 +489,17 @@ function process_node(ts, node, outdir, params, groups) {
|
|
|
494
489
|
* @param {string} file_path
|
|
495
490
|
*/
|
|
496
491
|
function path_to_original(outdir, file_path) {
|
|
492
|
+
return posixify(path.relative(outdir, path.join(cwd, replace_ext_with_js(file_path))));
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* @param {string} file_path
|
|
497
|
+
*/
|
|
498
|
+
function replace_ext_with_js(file_path) {
|
|
499
|
+
// Another extension than `.js` (or nothing, but that fails with node16 moduleResolution)
|
|
500
|
+
// will result in TS failing to lookup the file
|
|
497
501
|
const ext = path.extname(file_path);
|
|
498
|
-
return
|
|
499
|
-
path.relative(
|
|
500
|
-
outdir,
|
|
501
|
-
path.join(
|
|
502
|
-
cwd,
|
|
503
|
-
// Another extension than `.js` (or nothing, but that fails with node16 moduleResolution)
|
|
504
|
-
// will result in TS failing to lookup the file
|
|
505
|
-
file_path.slice(0, -ext.length) + '.js'
|
|
506
|
-
)
|
|
507
|
-
)
|
|
508
|
-
);
|
|
502
|
+
return file_path.slice(0, -ext.length) + '.js';
|
|
509
503
|
}
|
|
510
504
|
|
|
511
505
|
/**
|
|
@@ -722,10 +716,6 @@ export function find_nearest_layout(routes_dir, nodes, start_idx) {
|
|
|
722
716
|
}
|
|
723
717
|
|
|
724
718
|
// matching parent layout found
|
|
725
|
-
// let import_path = posixify(path.relative(path.dirname(start_file), common_path + '/$types.js'));
|
|
726
|
-
// if (!import_path.startsWith('.')) {
|
|
727
|
-
// import_path = './' + import_path;
|
|
728
|
-
// }
|
|
729
719
|
let folder_depth_diff =
|
|
730
720
|
posixify(path.relative(path.dirname(start_file), common_path + '/$types.js')).split('/')
|
|
731
721
|
.length - 1;
|
package/src/index/private.js
CHANGED
package/src/packaging/utils.js
CHANGED
|
@@ -103,7 +103,12 @@ export function analyze(config, file) {
|
|
|
103
103
|
export function generate_pkg(cwd, files) {
|
|
104
104
|
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'));
|
|
105
105
|
|
|
106
|
+
// Remove fields that are specific to the original package.json
|
|
107
|
+
// See: https://pnpm.io/package_json#publishconfigdirectory
|
|
108
|
+
delete pkg.publishConfig?.directory;
|
|
109
|
+
delete pkg.linkDirectory?.directory;
|
|
106
110
|
delete pkg.scripts;
|
|
111
|
+
|
|
107
112
|
pkg.type = 'module';
|
|
108
113
|
|
|
109
114
|
pkg.exports = {
|
|
@@ -364,21 +364,16 @@ export async function handle_json_request(event, options, mod) {
|
|
|
364
364
|
return json(result);
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
if (
|
|
367
|
+
if (result?.errors) {
|
|
368
368
|
// @ts-ignore
|
|
369
|
-
|
|
370
|
-
// @ts-ignore
|
|
371
|
-
return json({ errors: result.errors }, { status: result.status || 400 });
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
return new Response(undefined, {
|
|
375
|
-
status: 201,
|
|
376
|
-
// @ts-ignore
|
|
377
|
-
headers: result.location ? { location: result.location } : undefined
|
|
378
|
-
});
|
|
369
|
+
return json({ errors: result.errors }, { status: result.status || 400 });
|
|
379
370
|
}
|
|
380
371
|
|
|
381
|
-
return new Response(undefined, {
|
|
372
|
+
return new Response(undefined, {
|
|
373
|
+
status: 204,
|
|
374
|
+
// @ts-ignore
|
|
375
|
+
headers: result?.location ? { location: result.location } : undefined
|
|
376
|
+
});
|
|
382
377
|
} catch (e) {
|
|
383
378
|
const error = normalize_error(e);
|
|
384
379
|
|
|
@@ -214,7 +214,9 @@ export async function build_server(options, client) {
|
|
|
214
214
|
const { chunks } = await create_build(merged_config);
|
|
215
215
|
|
|
216
216
|
/** @type {import('vite').Manifest} */
|
|
217
|
-
const vite_manifest = JSON.parse(
|
|
217
|
+
const vite_manifest = JSON.parse(
|
|
218
|
+
fs.readFileSync(`${output_dir}/server/${vite_config.build.manifest}`, 'utf-8')
|
|
219
|
+
);
|
|
218
220
|
|
|
219
221
|
mkdirp(`${output_dir}/server/nodes`);
|
|
220
222
|
mkdirp(`${output_dir}/server/stylesheets`);
|
package/src/vite/build/utils.js
CHANGED
|
@@ -93,7 +93,8 @@ export const get_default_config = function ({ config, input, ssr, outDir }) {
|
|
|
93
93
|
base: assets_base(config.kit),
|
|
94
94
|
build: {
|
|
95
95
|
cssCodeSplit: true,
|
|
96
|
-
manifest
|
|
96
|
+
// don't use the default name to avoid collisions with 'static/manifest.json'
|
|
97
|
+
manifest: 'vite-manifest.json',
|
|
97
98
|
outDir,
|
|
98
99
|
polyfillModulePreload: false,
|
|
99
100
|
rollupOptions: {
|
package/src/vite/index.js
CHANGED
|
@@ -167,7 +167,7 @@ function kit() {
|
|
|
167
167
|
function client_build_info(assets, chunks) {
|
|
168
168
|
/** @type {import('vite').Manifest} */
|
|
169
169
|
const vite_manifest = JSON.parse(
|
|
170
|
-
fs.readFileSync(`${paths.client_out_dir}
|
|
170
|
+
fs.readFileSync(`${paths.client_out_dir}/${vite_config.build.manifest}`, 'utf-8')
|
|
171
171
|
);
|
|
172
172
|
|
|
173
173
|
const entry_id = posixify(path.relative(cwd, `${runtime_directory}/client/start.js`));
|
|
@@ -437,6 +437,10 @@ function kit() {
|
|
|
437
437
|
`See ${colors.bold().cyan('https://kit.svelte.dev/docs/adapters')} to learn how to configure your app to run on the platform of your choosing`
|
|
438
438
|
);
|
|
439
439
|
}
|
|
440
|
+
|
|
441
|
+
// avoid making the manifest available to users
|
|
442
|
+
fs.unlinkSync(`${paths.output_dir}/client/${vite_config.build.manifest}`);
|
|
443
|
+
fs.unlinkSync(`${paths.output_dir}/server/${vite_config.build.manifest}`);
|
|
440
444
|
},
|
|
441
445
|
|
|
442
446
|
/**
|