@sveltejs/kit 1.0.0-next.388 → 1.0.0-next.390

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.
@@ -690,6 +690,10 @@ function create_client({ target, session, base, trailing_slash }) {
690
690
  return false; // unnecessary, but TypeScript prefers it this way
691
691
  }
692
692
 
693
+ // if this is an internal navigation intent, use the normalized
694
+ // URL for the rest of the function
695
+ url = intent?.url || url;
696
+
693
697
  // abort if user navigated during update
694
698
  if (token !== current_token) return false;
695
699
 
@@ -1343,9 +1347,12 @@ function create_client({ target, session, base, trailing_slash }) {
1343
1347
  const params = route.exec(path);
1344
1348
 
1345
1349
  if (params) {
1346
- const id = normalize_path(url.pathname, trailing_slash) + url.search;
1350
+ const normalized = new URL(
1351
+ url.origin + normalize_path(url.pathname, trailing_slash) + url.search + url.hash
1352
+ );
1353
+ const id = normalized.pathname + normalized.search;
1347
1354
  /** @type {import('./types').NavigationIntent} */
1348
- const intent = { id, route, params: decode_params(params), url };
1355
+ const intent = { id, route, params: decode_params(params), url: normalized };
1349
1356
  return intent;
1350
1357
  }
1351
1358
  }
@@ -1382,9 +1389,6 @@ function create_client({ target, session, base, trailing_slash }) {
1382
1389
  return;
1383
1390
  }
1384
1391
 
1385
- const pathname = normalize_path(url.pathname, trailing_slash);
1386
- const normalized = new URL(url.origin + pathname + url.search + url.hash);
1387
-
1388
1392
  update_scroll_positions(current_history_index);
1389
1393
 
1390
1394
  accepted();
@@ -1392,12 +1396,12 @@ function create_client({ target, session, base, trailing_slash }) {
1392
1396
  if (started) {
1393
1397
  stores.navigating.set({
1394
1398
  from: current.url,
1395
- to: normalized
1399
+ to: url
1396
1400
  });
1397
1401
  }
1398
1402
 
1399
1403
  await update(
1400
- normalized,
1404
+ url,
1401
1405
  redirect_chain,
1402
1406
  false,
1403
1407
  {
@@ -1406,7 +1410,7 @@ function create_client({ target, session, base, trailing_slash }) {
1406
1410
  details
1407
1411
  },
1408
1412
  () => {
1409
- const navigation = { from, to: normalized };
1413
+ const navigation = { from, to: url };
1410
1414
  callbacks.after_navigate.forEach((fn) => fn(navigation));
1411
1415
 
1412
1416
  stores.navigating.set(null);
@@ -3,7 +3,7 @@ import * as path from 'path';
3
3
  import { join, relative, dirname } from 'path';
4
4
  import { $ } from './error.js';
5
5
  import chokidar from 'chokidar';
6
- import { d as walk$1, m as mkdirp, p as posixify, r as rimraf, b as write_tsconfig, c as copy } from './write_tsconfig.js';
6
+ import { w as walk$1, m as mkdirp, p as posixify, r as rimraf, d as write_tsconfig, c as copy } from './write_tsconfig.js';
7
7
  import { createRequire } from 'module';
8
8
  import 'url';
9
9
 
@@ -2,7 +2,7 @@ import path__default from 'path';
2
2
  import fs__default from 'fs';
3
3
  import { $ } from './error.js';
4
4
  import { fileURLToPath } from 'url';
5
- import { p as posixify, c as copy, w as write_if_changed, t as trim, r as rimraf, a as write, b as write_tsconfig } from './write_tsconfig.js';
5
+ import { p as posixify, c as copy, a as write_if_changed, t as trim, r as rimraf, b as write, d as write_tsconfig } from './write_tsconfig.js';
6
6
 
7
7
  /**
8
8
  * @param typeMap [Object] Map of MIME type -> Array[extensions]
@@ -271,4 +271,4 @@ function validate(config, cwd, out, user_file) {
271
271
  }
272
272
  }
273
273
 
274
- export { write as a, write_tsconfig as b, copy as c, walk as d, mkdirp as m, posixify as p, rimraf as r, trim as t, write_if_changed as w };
274
+ export { write_if_changed as a, write as b, copy as c, write_tsconfig as d, mkdirp as m, posixify as p, rimraf as r, trim as t, walk as w };
package/dist/cli.js CHANGED
@@ -18,7 +18,7 @@ function handle_error(e) {
18
18
  process.exit(1);
19
19
  }
20
20
 
21
- const prog = sade('svelte-kit').version('1.0.0-next.388');
21
+ const prog = sade('svelte-kit').version('1.0.0-next.390');
22
22
 
23
23
  prog
24
24
  .command('package')
package/dist/vite.js CHANGED
@@ -5,7 +5,7 @@ import { a as load_template, $, c as coalesce_to_error, l as load_config } from
5
5
  import { svelte } from '@sveltejs/vite-plugin-svelte';
6
6
  import * as vite from 'vite';
7
7
  import { loadConfigFromFile } from 'vite';
8
- import { p as posixify, m as mkdirp, r as rimraf } from './chunks/write_tsconfig.js';
8
+ import { p as posixify, m as mkdirp, w as walk, r as rimraf } from './chunks/write_tsconfig.js';
9
9
  import { g as get_runtime_directory, s, i as init, a as get_runtime_prefix, u as update, b as get_mime_lookup, p as parse_route_id, c as all, l as logger } from './chunks/sync.js';
10
10
  import { URL as URL$1, pathToFileURL } from 'url';
11
11
  import { installPolyfills } from './node/polyfills.js';
@@ -1134,12 +1134,12 @@ const REDIRECT = 3;
1134
1134
  /**
1135
1135
  * @param {{
1136
1136
  * config: import('types').ValidatedKitConfig;
1137
- * entries: string[];
1138
- * files: Set<string>;
1137
+ * client_out_dir: string;
1138
+ * manifest_path: string;
1139
1139
  * log: Logger;
1140
1140
  * }} opts
1141
1141
  */
1142
- async function prerender({ config, entries, files, log }) {
1142
+ async function prerender({ config, client_out_dir, manifest_path, log }) {
1143
1143
  /** @type {import('types').Prerendered} */
1144
1144
  const prerendered = {
1145
1145
  pages: new Map(),
@@ -1240,6 +1240,7 @@ async function prerender({ config, entries, files, log }) {
1240
1240
  return file;
1241
1241
  }
1242
1242
 
1243
+ const files = new Set(walk(client_out_dir).map(posixify));
1243
1244
  const seen = new Set();
1244
1245
  const written = new Set();
1245
1246
 
@@ -1397,6 +1398,12 @@ async function prerender({ config, entries, files, log }) {
1397
1398
  if (config.prerender.enabled) {
1398
1399
  for (const entry of config.prerender.entries) {
1399
1400
  if (entry === '*') {
1401
+ /** @type {import('types').ManifestData} */
1402
+ const { routes } = (await import(pathToFileURL(manifest_path).href)).manifest._;
1403
+ const entries = routes
1404
+ .map((route) => (route.type === 'page' ? route.path : ''))
1405
+ .filter(Boolean);
1406
+
1400
1407
  for (const entry of entries) {
1401
1408
  enqueue(null, config.paths.base + entry); // TODO can we pre-normalize these?
1402
1409
  }
@@ -2910,6 +2917,9 @@ function kit() {
2910
2917
  /** @type {import('types').BuildData} */
2911
2918
  let build_data;
2912
2919
 
2920
+ /** @type {string | undefined} */
2921
+ let deferred_warning;
2922
+
2913
2923
  /**
2914
2924
  * @type {{
2915
2925
  * build_dir: string;
@@ -2998,7 +3008,8 @@ function kit() {
2998
3008
 
2999
3009
  const new_config = vite_client_build_config();
3000
3010
 
3001
- warn_overridden_config(config, new_config);
3011
+ const warning = warn_overridden_config(config, new_config);
3012
+ if (warning) console.error(warning + '\n');
3002
3013
 
3003
3014
  return new_config;
3004
3015
  }
@@ -3045,7 +3056,8 @@ function kit() {
3045
3056
  }
3046
3057
  }
3047
3058
  };
3048
- warn_overridden_config(config, result);
3059
+
3060
+ deferred_warning = warn_overridden_config(config, result);
3049
3061
  return result;
3050
3062
  },
3051
3063
 
@@ -3112,8 +3124,9 @@ function kit() {
3112
3124
  server
3113
3125
  };
3114
3126
 
3127
+ const manifest_path = `${paths.output_dir}/server/manifest.js`;
3115
3128
  fs__default.writeFileSync(
3116
- `${paths.output_dir}/server/manifest.js`,
3129
+ manifest_path,
3117
3130
  `export const manifest = ${generate_manifest({
3118
3131
  build_data,
3119
3132
  relative_path: '.',
@@ -3124,27 +3137,10 @@ function kit() {
3124
3137
  process.env.SVELTEKIT_SERVER_BUILD_COMPLETED = 'true';
3125
3138
  log.info('Prerendering');
3126
3139
 
3127
- const static_files = manifest_data.assets.map((asset) => posixify(asset.file));
3128
-
3129
- const files = new Set([
3130
- ...static_files,
3131
- ...chunks.map((chunk) => chunk.fileName),
3132
- ...assets.map((chunk) => chunk.fileName)
3133
- ]);
3134
-
3135
- // TODO is this right?
3136
- static_files.forEach((file) => {
3137
- if (file.endsWith('/index.html')) {
3138
- files.add(file.slice(0, -11));
3139
- }
3140
- });
3141
-
3142
3140
  prerendered = await prerender({
3143
3141
  config: svelte_config.kit,
3144
- entries: manifest_data.routes
3145
- .map((route) => (route.type === 'page' ? route.path : ''))
3146
- .filter(Boolean),
3147
- files,
3142
+ client_out_dir: vite_config.build.outDir,
3143
+ manifest_path,
3148
3144
  log
3149
3145
  });
3150
3146
 
@@ -3199,6 +3195,14 @@ function kit() {
3199
3195
  * @see https://vitejs.dev/guide/api-plugin.html#configureserver
3200
3196
  */
3201
3197
  async configureServer(vite) {
3198
+ // This method is called by Vite after clearing the screen.
3199
+ // This patch ensures we can log any important messages afterwards for the user to see.
3200
+ const print_urls = vite.printUrls;
3201
+ vite.printUrls = function () {
3202
+ print_urls.apply(this);
3203
+ if (deferred_warning) console.error('\n' + deferred_warning);
3204
+ };
3205
+
3202
3206
  return await dev(vite, vite_config, svelte_config);
3203
3207
  },
3204
3208
 
@@ -3248,11 +3252,12 @@ function collect_output(bundle) {
3248
3252
  */
3249
3253
  function warn_overridden_config(config, resolved_config) {
3250
3254
  const overridden = find_overridden_config(config, resolved_config, enforced_config, '', []);
3255
+
3251
3256
  if (overridden.length > 0) {
3252
- console.log(
3253
- $.bold().red('The following Vite config options will be overridden by SvelteKit:')
3257
+ return (
3258
+ $.bold().red('The following Vite config options will be overridden by SvelteKit:') +
3259
+ overridden.map((key) => `\n - ${key}`).join('')
3254
3260
  );
3255
- console.log(overridden.map((key) => ` - ${key}`).join('\n'));
3256
3261
  }
3257
3262
  }
3258
3263
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.388",
3
+ "version": "1.0.0-next.390",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",