@sveltejs/kit 1.0.0-next.302 → 1.0.0-next.305

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.
@@ -563,7 +563,11 @@ function create_client({ target, session, base, trailing_slash }) {
563
563
  const current_token = (token = {});
564
564
  let navigation_result = intent && (await load_route(intent, no_cache));
565
565
 
566
- if (!navigation_result && url.pathname === location.pathname) {
566
+ if (
567
+ !navigation_result &&
568
+ url.origin === location.origin &&
569
+ url.pathname === location.pathname
570
+ ) {
567
571
  // this could happen in SPA fallback mode if the user navigated to
568
572
  // `/non-existent-page`. if we fall back to reloading the page, it
569
573
  // will create an infinite loop. so whereas we normally handle
@@ -73,7 +73,7 @@ async function create_plugin(config, cwd) {
73
73
  const url = id.startsWith('..') ? `/@fs${path__default.posix.resolve(id)}` : `/${id}`;
74
74
 
75
75
  const module = /** @type {import('types').SSRComponent} */ (
76
- await vite.ssrLoadModule(url)
76
+ await vite.ssrLoadModule(url, { fixStacktrace: false })
77
77
  );
78
78
  const node = await vite.moduleGraph.getModuleByUrl(url);
79
79
 
@@ -95,7 +95,7 @@ async function create_plugin(config, cwd) {
95
95
  (query.has('svelte') && query.get('type') === 'style')
96
96
  ) {
97
97
  try {
98
- const mod = await vite.ssrLoadModule(dep.url);
98
+ const mod = await vite.ssrLoadModule(dep.url, { fixStacktrace: false });
99
99
  styles[dep.url] = mod.default;
100
100
  } catch {
101
101
  // this can happen with dynamically imported modules, I think
@@ -128,7 +128,7 @@ async function create_plugin(config, cwd) {
128
128
  shadow: route.shadow
129
129
  ? async () => {
130
130
  const url = path__default.resolve(cwd, /** @type {string} */ (route.shadow));
131
- return await vite.ssrLoadModule(url);
131
+ return await vite.ssrLoadModule(url, { fixStacktrace: false });
132
132
  }
133
133
  : null,
134
134
  a: route.a.map((id) => manifest_data.components.indexOf(id)),
@@ -144,7 +144,7 @@ async function create_plugin(config, cwd) {
144
144
  types,
145
145
  load: async () => {
146
146
  const url = path__default.resolve(cwd, route.file);
147
- return await vite.ssrLoadModule(url);
147
+ return await vite.ssrLoadModule(url, { fixStacktrace: false });
148
148
  }
149
149
  };
150
150
  }),
@@ -155,7 +155,7 @@ async function create_plugin(config, cwd) {
155
155
  for (const key in manifest_data.matchers) {
156
156
  const file = manifest_data.matchers[key];
157
157
  const url = path__default.resolve(cwd, file);
158
- const module = await vite.ssrLoadModule(url);
158
+ const module = await vite.ssrLoadModule(url, { fixStacktrace: false });
159
159
 
160
160
  if (module.match) {
161
161
  matchers[key] = module.match;
@@ -172,20 +172,7 @@ async function create_plugin(config, cwd) {
172
172
 
173
173
  /** @param {Error} error */
174
174
  function fix_stack_trace(error) {
175
- // TODO https://github.com/vitejs/vite/issues/7045
176
-
177
- // ideally vite would expose ssrRewriteStacktrace, but
178
- // in lieu of that, we can implement it ourselves. we
179
- // don't want to mutate the error object, because
180
- // the stack trace could be 'fixed' multiple times,
181
- // and Vite will fix stack traces before we even
182
- // see them if they occur during ssrLoadModule
183
- const original = error.stack;
184
- vite.ssrFixStacktrace(error);
185
- const fixed = error.stack;
186
- error.stack = original;
187
-
188
- return fixed;
175
+ return error.stack ? vite.ssrRewriteStacktrace(error.stack) : error.stack;
189
176
  }
190
177
 
191
178
  update_manifest();
@@ -231,7 +218,7 @@ async function create_plugin(config, cwd) {
231
218
 
232
219
  /** @type {Partial<import('types').Hooks>} */
233
220
  const user_hooks = resolve_entry(config.kit.files.hooks)
234
- ? await vite.ssrLoadModule(`/${config.kit.files.hooks}`)
221
+ ? await vite.ssrLoadModule(`/${config.kit.files.hooks}`, { fixStacktrace: false })
235
222
  : {};
236
223
 
237
224
  const handle = user_hooks.handle || (({ event, resolve }) => resolve(event));
@@ -271,13 +258,15 @@ async function create_plugin(config, cwd) {
271
258
  // can get loaded twice via different URLs, which causes failures. Might
272
259
  // require changes to Vite to fix
273
260
  const { default: root } = await vite.ssrLoadModule(
274
- `/${posixify(path__default.relative(cwd, `${config.kit.outDir}/generated/root.svelte`))}`
261
+ `/${posixify(path__default.relative(cwd, `${config.kit.outDir}/generated/root.svelte`))}`,
262
+ { fixStacktrace: false }
275
263
  );
276
264
 
277
265
  const paths = await vite.ssrLoadModule(
278
266
  true
279
267
  ? `/${posixify(path__default.relative(cwd, `${config.kit.outDir}/runtime/paths.js`))}`
280
- : `/@fs${runtime}/paths.js`
268
+ : `/@fs${runtime}/paths.js`,
269
+ { fixStacktrace: false }
281
270
  );
282
271
 
283
272
  paths.set_paths({
@@ -1003,10 +1003,6 @@ async function prerender({ config, entries, files, log }) {
1003
1003
  paths: []
1004
1004
  };
1005
1005
 
1006
- if (!config.kit.prerender.enabled) {
1007
- return prerendered;
1008
- }
1009
-
1010
1006
  installFetch();
1011
1007
 
1012
1008
  const server_root = join(config.kit.outDir, 'output');
@@ -1023,6 +1019,23 @@ async function prerender({ config, entries, files, log }) {
1023
1019
 
1024
1020
  const server = new Server(manifest);
1025
1021
 
1022
+ const rendered = await server.respond(new Request('http://sveltekit-prerender/[fallback]'), {
1023
+ getClientAddress,
1024
+ prerender: {
1025
+ fallback: true,
1026
+ default: false,
1027
+ dependencies: new Map()
1028
+ }
1029
+ });
1030
+
1031
+ const file = `${config.kit.outDir}/output/prerendered/fallback.html`;
1032
+ mkdirp(dirname(file));
1033
+ writeFileSync(file, await rendered.text());
1034
+
1035
+ if (!config.kit.prerender.enabled) {
1036
+ return prerendered;
1037
+ }
1038
+
1026
1039
  const error = normalise_error_handler(log, config.kit.prerender.onError);
1027
1040
 
1028
1041
  const q = queue(config.kit.prerender.concurrency);
@@ -1214,19 +1227,6 @@ async function prerender({ config, entries, files, log }) {
1214
1227
  await q.done();
1215
1228
  }
1216
1229
 
1217
- const rendered = await server.respond(new Request('http://sveltekit-prerender/[fallback]'), {
1218
- getClientAddress,
1219
- prerender: {
1220
- fallback: true,
1221
- default: false,
1222
- dependencies: new Map()
1223
- }
1224
- });
1225
-
1226
- const file = `${config.kit.outDir}/output/prerendered/fallback.html`;
1227
- mkdirp(dirname(file));
1228
- writeFileSync(file, await rendered.text());
1229
-
1230
1230
  return prerendered;
1231
1231
  }
1232
1232
 
@@ -132,7 +132,7 @@ var mime = new Mime(standard, other);
132
132
  * }} Item
133
133
  */
134
134
 
135
- const specials = new Set(['__layout', '__layout.reset', '__error']);
135
+ const specials = new Set(['__layout', '__layout.reset', '__error', '__tests__', '__test__']);
136
136
 
137
137
  /**
138
138
  * @param {{
@@ -833,21 +833,6 @@ function write_types(config, manifest_data) {
833
833
  /** @type {Map<string, { params: string[], type: 'page' | 'endpoint' | 'both' }>} */
834
834
  const shadow_types = new Map();
835
835
 
836
- /** @param {string} key */
837
- function extract_params(key) {
838
- /** @type {string[]} */
839
- const params = [];
840
-
841
- const pattern = /\[(?:\.{3})?([^\]]+)\]/g;
842
- let match;
843
-
844
- while ((match = pattern.exec(key))) {
845
- params.push(match[1]);
846
- }
847
-
848
- return params;
849
- }
850
-
851
836
  manifest_data.routes.forEach((route) => {
852
837
  const file = route.type === 'endpoint' ? route.file : route.shadow;
853
838
 
@@ -857,7 +842,7 @@ function write_types(config, manifest_data) {
857
842
  );
858
843
  const key = file.slice(0, -ext.length);
859
844
  shadow_types.set(key, {
860
- params: extract_params(key),
845
+ params: parse_route_id(key).names,
861
846
  type: route.type === 'endpoint' ? 'endpoint' : 'both'
862
847
  });
863
848
  }
@@ -870,7 +855,7 @@ function write_types(config, manifest_data) {
870
855
  const key = component.slice(0, -ext.length);
871
856
 
872
857
  if (!shadow_types.has(key)) {
873
- shadow_types.set(key, { params: extract_params(key), type: 'page' });
858
+ shadow_types.set(key, { params: parse_route_id(key).names, type: 'page' });
874
859
  }
875
860
  });
876
861
 
package/dist/cli.js CHANGED
@@ -869,7 +869,7 @@ async function launch(port, https) {
869
869
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
870
870
  }
871
871
 
872
- const prog = sade('svelte-kit').version('1.0.0-next.302');
872
+ const prog = sade('svelte-kit').version('1.0.0-next.305');
873
873
 
874
874
  prog
875
875
  .command('dev')
@@ -1047,7 +1047,7 @@ async function check_port(port) {
1047
1047
  function welcome({ port, host, https, open, loose, allow, cwd }) {
1048
1048
  if (open) launch(port, https);
1049
1049
 
1050
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.302'}\n`));
1050
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.305'}\n`));
1051
1051
 
1052
1052
  const protocol = https ? 'https:' : 'http:';
1053
1053
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.302",
3
+ "version": "1.0.0-next.305",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -12,7 +12,7 @@
12
12
  "dependencies": {
13
13
  "@sveltejs/vite-plugin-svelte": "^1.0.0-next.32",
14
14
  "sade": "^1.7.4",
15
- "vite": "^2.8.0"
15
+ "vite": "^2.9.0"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@playwright/test": "^1.19.1",
package/types/index.d.ts CHANGED
@@ -184,7 +184,7 @@ export interface HandleError {
184
184
  }
185
185
 
186
186
  /**
187
- * The type of a `load` function exported from `<script context="module">` in a page or layout.
187
+ * The `(input: LoadInput) => LoadOutput` `load` function exported from `<script context="module">` in a page or layout.
188
188
  *
189
189
  * Note that you can use [generated types](/docs/types#generated-types) instead of manually specifying the Params generic argument.
190
190
  */
@@ -215,13 +215,9 @@ export interface ParamMatcher {
215
215
  }
216
216
 
217
217
  /**
218
- * A function exported from an endpoint that corresponds to an
219
- * HTTP verb (`get`, `put`, `patch`, etc) and handles requests with
220
- * that method. Note that since 'delete' is a reserved word in
221
- * JavaScript, delete handles are called `del` instead.
218
+ * A `(event: RequestEvent) => RequestHandlerOutput` function exported from an endpoint that corresponds to an HTTP verb (`get`, `put`, `patch`, etc) and handles requests with that method. Note that since 'delete' is a reserved word in JavaScript, delete handles are called `del` instead.
222
219
  *
223
- * Note that you can use [generated types](/docs/types#generated-types)
224
- * instead of manually specifying the `Params` generic argument.
220
+ * Note that you can use [generated types](/docs/types#generated-types) instead of manually specifying the `Params` generic argument.
225
221
  */
226
222
  export interface RequestHandler<
227
223
  Params extends Record<string, string> = Record<string, string>,
@@ -18,7 +18,6 @@ import {
18
18
  RequestOptions,
19
19
  ResolveOptions,
20
20
  ResponseHeaders,
21
- RouteSegment,
22
21
  TrailingSlash
23
22
  } from './private';
24
23
 
@@ -2,8 +2,6 @@
2
2
  // but which cannot be imported from `@sveltejs/kit`. Care should
3
3
  // be taken to avoid breaking changes when editing this file
4
4
 
5
- import { ValidatedConfig } from './internal';
6
-
7
5
  export interface AdapterEntry {
8
6
  /**
9
7
  * A string that uniquely identifies an HTTP service (e.g. serverless function) and is used for deduplication.
@@ -191,8 +189,6 @@ export interface Logger {
191
189
 
192
190
  export type MaybePromise<T> = T | Promise<T>;
193
191
 
194
- export type Only<T, U> = { [P in keyof T]: T[P] } & { [P in Exclude<keyof U, keyof T>]?: never };
195
-
196
192
  export interface Prerendered {
197
193
  pages: Map<
198
194
  string,