@sveltejs/kit 1.0.0-next.288 → 1.0.0-next.290

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.
@@ -76,7 +76,7 @@ class Router {
76
76
  * base: string;
77
77
  * routes: import('types').CSRRoute[];
78
78
  * trailing_slash: import('types').TrailingSlash;
79
- * renderer: import('./renderer').Renderer
79
+ * renderer: import('./renderer').Renderer;
80
80
  * }} opts
81
81
  */
82
82
  constructor({ base, routes, trailing_slash, renderer }) {
@@ -310,8 +310,7 @@ class Router {
310
310
  id: url.pathname + url.search,
311
311
  routes: this.routes.filter(([pattern]) => pattern.test(path)),
312
312
  url,
313
- path,
314
- initial: !this.initialized
313
+ path
315
314
  };
316
315
  }
317
316
  }
@@ -876,6 +875,14 @@ class Renderer {
876
875
  const token = (this.token = {});
877
876
  let navigation_result = await this._get_navigation_result(info, no_cache);
878
877
 
878
+ if (!navigation_result && info.url.pathname === location.pathname) {
879
+ navigation_result = await this._load_error({
880
+ status: 404,
881
+ error: new Error(`Not found: ${info.url.pathname}`),
882
+ url: info.url
883
+ });
884
+ }
885
+
879
886
  if (!navigation_result) {
880
887
  location.href = info.url.href;
881
888
  return;
@@ -1083,14 +1090,6 @@ class Renderer {
1083
1090
  );
1084
1091
  if (result) return result;
1085
1092
  }
1086
-
1087
- if (info.initial) {
1088
- return await this._load_error({
1089
- status: 404,
1090
- error: new Error(`Not found: ${info.url.pathname}`),
1091
- url: info.url
1092
- });
1093
- }
1094
1093
  }
1095
1094
 
1096
1095
  /**
@@ -2543,7 +2543,6 @@ async function respond(request, options, state = {}) {
2543
2543
  request,
2544
2544
  url,
2545
2545
  params: {},
2546
- // @ts-expect-error this picks up types that belong to the tests
2547
2546
  locals: {},
2548
2547
  platform: state.platform
2549
2548
  };
@@ -1,5 +1,5 @@
1
1
  /** @type {import('amphtml-validator').Validator} */
2
- const amp = await (await import('./index8.js').then(function (n) { return n.i; })).getInstance();
2
+ const amp = await (await import('./index7.js').then(function (n) { return n.i; })).getInstance();
3
3
 
4
4
  /** @type {import('types').Handle} */
5
5
  async function handle({ event, resolve }) {
@@ -655,4 +655,9 @@ function sirv (dir, opts={}) {
655
655
  };
656
656
  }
657
657
 
658
- export { sirv as s };
658
+ // in `svelte-kit dev` and `svelte-kit preview`, we use a fake
659
+ // asset path so that we can serve local assets while still
660
+ // verifying that requests are correctly prefixed
661
+ const SVELTE_KIT_ASSETS = '/_svelte_kit_assets';
662
+
663
+ export { SVELTE_KIT_ASSETS as S, sirv as s };
@@ -1,11 +1,11 @@
1
1
  import path__default from 'path';
2
2
  import { svelte } from '@sveltejs/vite-plugin-svelte';
3
3
  import vite from 'vite';
4
- import { c as create_manifest_data, a as create_app, d as deep_merge } from './index2.js';
5
- import { r as runtime, S as SVELTE_KIT_ASSETS, a as resolve_entry, $, b as SVELTE_KIT, l as load_template, c as coalesce_to_error, g as get_mime_lookup, d as copy_assets, e as get_aliases, p as print_config_conflicts } from '../cli.js';
4
+ import { c as create_manifest_data, a as create_app, g as generate_tsconfig, d as deep_merge } from './tsconfig.js';
5
+ import { g as get_runtime_path, r as resolve_entry, $, p as posixify, l as load_template, c as coalesce_to_error, a as get_mime_lookup, b as copy_assets, d as get_aliases, e as print_config_conflicts } from '../cli.js';
6
6
  import fs__default from 'fs';
7
7
  import { URL } from 'url';
8
- import { s as sirv } from './build.js';
8
+ import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
9
9
  import { installFetch } from '../install-fetch.js';
10
10
  import { getRequest, setResponse } from '../node.js';
11
11
  import { sequence } from '../hooks.js';
@@ -29,6 +29,8 @@ import 'stream';
29
29
  * @returns {Promise<import('vite').Plugin>}
30
30
  */
31
31
  async function create_plugin(config, cwd) {
32
+ const runtime = get_runtime_path(config);
33
+
32
34
  /** @type {import('types').Handle} */
33
35
  let amp;
34
36
 
@@ -54,7 +56,7 @@ async function create_plugin(config, cwd) {
54
56
  function update_manifest() {
55
57
  const manifest_data = create_manifest_data({ config, cwd });
56
58
 
57
- create_app({ manifest_data, output: `${SVELTE_KIT}/generated`, cwd });
59
+ create_app({ config, manifest_data, cwd });
58
60
 
59
61
  manifest = {
60
62
  appDir: config.kit.appDir,
@@ -210,7 +212,6 @@ async function create_plugin(config, cwd) {
210
212
 
211
213
  /** @type {import('types').Hooks} */
212
214
  const hooks = {
213
- // @ts-expect-error this picks up types that belong to the tests
214
215
  getSession: user_hooks.getSession || (() => ({})),
215
216
  handle: amp ? sequence(amp, handle) : handle,
216
217
  handleError:
@@ -239,9 +240,18 @@ async function create_plugin(config, cwd) {
239
240
  throw new Error('The serverFetch hook has been renamed to externalFetch.');
240
241
  }
241
242
 
242
- const root = (await vite.ssrLoadModule(`/${SVELTE_KIT}/generated/root.svelte`)).default;
243
+ // TODO the / prefix will probably fail if outDir is outside the cwd (which
244
+ // could be the case in a monorepo setup), but without it these modules
245
+ // can get loaded twice via different URLs, which causes failures. Might
246
+ // require changes to Vite to fix
247
+ const { default: root } = await vite.ssrLoadModule(
248
+ `/${posixify(path__default.relative(cwd, `${config.kit.outDir}/generated/root.svelte`))}`
249
+ );
250
+
243
251
  const paths = await vite.ssrLoadModule(
244
- true ? `/${SVELTE_KIT}/runtime/paths.js` : `/@fs${runtime}/paths.js`
252
+ true
253
+ ? `/${posixify(path__default.relative(cwd, `${config.kit.outDir}/runtime/paths.js`))}`
254
+ : `/@fs${runtime}/paths.js`
245
255
  );
246
256
 
247
257
  paths.set_paths({
@@ -406,7 +416,9 @@ function find_deps(node, deps) {
406
416
 
407
417
  /** @param {Options} opts */
408
418
  async function dev({ cwd, port, host, https, config }) {
409
- copy_assets(`${SVELTE_KIT}/runtime`);
419
+ copy_assets(path__default.join(config.kit.outDir, 'runtime'));
420
+
421
+ generate_tsconfig(config);
410
422
 
411
423
  const [vite_config] = deep_merge(
412
424
  {
@@ -417,8 +429,8 @@ async function dev({ cwd, port, host, https, config }) {
417
429
  config.kit.files.assets,
418
430
  config.kit.files.lib,
419
431
  config.kit.files.routes,
432
+ config.kit.outDir,
420
433
  path__default.resolve(cwd, 'src'),
421
- path__default.resolve(cwd, SVELTE_KIT),
422
434
  path__default.resolve(cwd, 'node_modules'),
423
435
  path__default.resolve(vite.searchForWorkspaceRoot(cwd), 'node_modules')
424
436
  ])
@@ -441,7 +453,7 @@ async function dev({ cwd, port, host, https, config }) {
441
453
  rollupOptions: {
442
454
  // Vite dependency crawler needs an explicit JS entry point
443
455
  // eventhough server otherwise works without it
444
- input: `${runtime}/client/start.js`
456
+ input: `${get_runtime_path(config)}/client/start.js`
445
457
  }
446
458
  },
447
459
  plugins: [