@sveltejs/kit 1.0.0-next.435 → 1.0.0-next.436

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.435",
3
+ "version": "1.0.0-next.436",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -5,6 +5,7 @@ import { pipeline } from 'stream';
5
5
  import { promisify } from 'util';
6
6
  import { copy, rimraf, mkdirp } from '../../utils/filesystem.js';
7
7
  import { generate_manifest } from '../generate_manifest/index.js';
8
+ import { get_path } from '../../utils/routing.js';
8
9
 
9
10
  /**
10
11
  * Creates the Builder which is passed to adapters for building the application.
@@ -23,7 +24,7 @@ export function create_builder({ config, build_data, prerendered, log }) {
23
24
  /** @param {import('types').RouteData} route */
24
25
  // TODO routes should come pre-filtered
25
26
  function not_prerendered(route) {
26
- const path = route.page && !route.id.includes('[') && `/${route.id}`;
27
+ const path = route.page && get_path(route.id);
27
28
  if (path) {
28
29
  return !prerendered_paths.has(path) && !prerendered_paths.has(path + '/');
29
30
  }
@@ -9,6 +9,8 @@ import { crawl } from './crawl.js';
9
9
  import { escape_html_attr } from '../../utils/escape.js';
10
10
  import { logger } from '../utils.js';
11
11
  import { load_config } from '../config/index.js';
12
+ import { compact } from '../../utils/array.js';
13
+ import { get_path } from '../../utils/routing.js';
12
14
 
13
15
  /**
14
16
  * @typedef {import('types').PrerenderErrorHandler} PrerenderErrorHandler
@@ -341,11 +343,10 @@ export async function prerender() {
341
343
  if (config.prerender.enabled) {
342
344
  for (const entry of config.prerender.entries) {
343
345
  if (entry === '*') {
344
- /** @type {import('types').ManifestData} */
345
- const { routes } = (await import(pathToFileURL(manifest_path).href)).manifest._;
346
- const entries = routes
347
- .map((route) => (route.page && !route.id.includes('[') ? `/${route.id}` : ''))
348
- .filter(Boolean);
346
+ /** @type {import('types').SSRManifest} */
347
+ const manifest = (await import(pathToFileURL(manifest_path).href)).manifest;
348
+ const { routes } = manifest._;
349
+ const entries = compact(routes.map((route) => route.page && get_path(route.id)));
349
350
 
350
351
  for (const entry of entries) {
351
352
  enqueue(null, config.paths.base + entry); // TODO can we pre-normalize these?
@@ -82,6 +82,7 @@ function create_matchers(config, cwd) {
82
82
  * @param {string} fallback
83
83
  */
84
84
  function create_routes_and_nodes(cwd, config, fallback) {
85
+ /** @type {Map<string, import('types').RouteData>} */
85
86
  const route_map = new Map();
86
87
 
87
88
  /** @type {Map<string, import('./types').Part[][]>} */
@@ -96,6 +96,15 @@ export function affects_path(segment) {
96
96
  return !/^\([^)]+\)$/.test(segment);
97
97
  }
98
98
 
99
+ /**
100
+ * Turns a route ID into a path, if possible
101
+ * @param {string} id
102
+ */
103
+ export function get_path(id) {
104
+ if (id.includes('[')) return null;
105
+ return `/${id.split('/').filter(affects_path).join('/')}`;
106
+ }
107
+
99
108
  /**
100
109
  * @param {RegExpMatchArray} match
101
110
  * @param {string[]} names