@sveltejs/kit 1.0.0-next.433 → 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.433",
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[][]>} */
@@ -321,7 +322,7 @@ function analyze(project_relative, file, component_extensions, module_extensions
321
322
  const component_extension = component_extensions.find((ext) => file.endsWith(ext));
322
323
  if (component_extension) {
323
324
  const name = file.slice(0, -component_extension.length);
324
- const pattern = /^\+(?:(page(?:@([a-zA-Z0-9_-]*))?)|(layout(?:@([a-zA-Z0-9_-]*))?)|(error))$/;
325
+ const pattern = /^\+(?:(page(?:@(.*))?)|(layout(?:@(.*))?)|(error))$/;
325
326
  const match = pattern.exec(name);
326
327
  if (!match) {
327
328
  // TODO remove for 1.0
@@ -112,7 +112,7 @@ function update_types(config, manifest_data, route) {
112
112
  input_files.push(route.endpoint.file);
113
113
  }
114
114
 
115
- if (input_files.length === 0) return; // nothing to do
115
+ if (!route.leaf && !route.layout && !route.endpoint) return; // nothing to do
116
116
 
117
117
  try {
118
118
  fs.mkdirSync(outdir, { recursive: true });
@@ -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