@sveltejs/kit 1.3.8 → 1.3.9

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.3.8",
3
+ "version": "1.3.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -3,7 +3,7 @@ import path from 'node:path';
3
3
  import { URL } from 'node:url';
4
4
  import colors from 'kleur';
5
5
  import sirv from 'sirv';
6
- import { isCSSRequest, loadEnv } from 'vite';
6
+ import { isCSSRequest, loadEnv, buildErrorMessage } from 'vite';
7
7
  import { getRequest, setResponse } from '../../../exports/node/index.js';
8
8
  import { installPolyfills } from '../../../exports/node/polyfills.js';
9
9
  import { coalesce_to_error } from '../../../utils/error.js';
@@ -50,11 +50,25 @@ export async function dev(vite, vite_config, svelte_config) {
50
50
  /** @type {Error | null} */
51
51
  let manifest_error = null;
52
52
 
53
+ /** @param {string} url */
54
+ async function loud_ssr_load_module(url) {
55
+ try {
56
+ return await vite.ssrLoadModule(url);
57
+ } catch (/** @type {any} */ err) {
58
+ const msg = buildErrorMessage(err, [colors.red(`Internal server error: ${err.message}`)]);
59
+
60
+ vite.config.logger.error(msg, { error: err });
61
+ vite.ws.send({ type: 'error', err: err });
62
+
63
+ throw err;
64
+ }
65
+ }
66
+
53
67
  /** @param {string} id */
54
68
  async function resolve(id) {
55
69
  const url = id.startsWith('..') ? `/@fs${path.posix.resolve(id)}` : `/${id}`;
56
70
 
57
- const module = await vite.ssrLoadModule(url);
71
+ const module = await loud_ssr_load_module(url);
58
72
 
59
73
  const module_node = await vite.moduleGraph.getModuleByUrl(url);
60
74
  if (!module_node) throw new Error(`Could not find node for ${url}`);
@@ -161,7 +175,7 @@ export async function dev(vite, vite_config, svelte_config) {
161
175
  (query.has('svelte') && query.get('type') === 'style')
162
176
  ) {
163
177
  try {
164
- const mod = await vite.ssrLoadModule(dep.url);
178
+ const mod = await loud_ssr_load_module(dep.url);
165
179
  styles[dep.url] = mod.default;
166
180
  } catch {
167
181
  // this can happen with dynamically imported modules, I think
@@ -191,7 +205,7 @@ export async function dev(vite, vite_config, svelte_config) {
191
205
  endpoint: endpoint
192
206
  ? async () => {
193
207
  const url = path.resolve(cwd, endpoint.file);
194
- return await vite.ssrLoadModule(url);
208
+ return await loud_ssr_load_module(url);
195
209
  }
196
210
  : null,
197
211
  endpoint_id: endpoint?.file