astro 2.7.0 → 2.7.1
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/README.md +3 -6
- package/dist/@types/astro.d.ts +0 -14
- package/dist/assets/utils/emitAsset.js +1 -2
- package/dist/content/vite-plugin-content-imports.js +0 -1
- package/dist/content/vite-plugin-content-virtual-mod.js +7 -1
- package/dist/core/build/generate.js +1 -3
- package/dist/core/build/index.js +1 -8
- package/dist/core/build/plugins/plugin-ssr.js +1 -1
- package/dist/core/build/static-build.js +7 -7
- package/dist/core/build/types.d.ts +1 -2
- package/dist/core/compile/compile.js +0 -5
- package/dist/core/compile/style.js +0 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/dev/vite.js +1 -9
- package/dist/core/errors/errors-data.d.ts +0 -71
- package/dist/core/errors/errors-data.js +10 -75
- package/dist/core/errors/errors.d.ts +1 -10
- package/dist/core/errors/errors.js +8 -9
- package/dist/core/errors/index.d.ts +1 -1
- package/dist/core/errors/utils.d.ts +2 -5
- package/dist/core/errors/utils.js +3 -3
- package/dist/core/messages.js +2 -2
- package/dist/core/module-loader/loader.d.ts +4 -0
- package/dist/core/render/dev/vite.js +25 -19
- package/dist/core/render/ssr-element.js +3 -4
- package/dist/core/routing/manifest/create.js +1 -2
- package/dist/core/util.d.ts +1 -0
- package/dist/core/util.js +5 -4
- package/dist/events/error.d.ts +0 -1
- package/dist/events/error.js +1 -5
- package/dist/integrations/index.d.ts +3 -5
- package/dist/integrations/index.js +2 -4
- package/dist/vite-plugin-astro/compile.js +2 -0
- package/dist/vite-plugin-jsx/index.js +2 -0
- package/dist/vite-plugin-load-fallback/index.js +2 -2
- package/dist/vite-plugin-markdown/index.js +0 -2
- package/package.json +3 -5
|
@@ -17,7 +17,6 @@ const AstroErrorData = {
|
|
|
17
17
|
*/
|
|
18
18
|
UnknownCompilerError: {
|
|
19
19
|
title: "Unknown compiler error.",
|
|
20
|
-
code: 1e3,
|
|
21
20
|
hint: "This is almost always a problem with the Astro compiler, not your code. Please open an issue at https://astro.build/issues/compiler."
|
|
22
21
|
},
|
|
23
22
|
// 1xxx and 2xxx codes are reserved for compiler errors and warnings respectively
|
|
@@ -34,7 +33,6 @@ const AstroErrorData = {
|
|
|
34
33
|
*/
|
|
35
34
|
StaticRedirectNotAvailable: {
|
|
36
35
|
title: "`Astro.redirect` is not available in static mode.",
|
|
37
|
-
code: 3001,
|
|
38
36
|
message: "Redirects are only available when using `output: 'server'` or `output: 'hybrid'`. Update your Astro config if you need SSR features.",
|
|
39
37
|
hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
|
|
40
38
|
},
|
|
@@ -48,7 +46,6 @@ const AstroErrorData = {
|
|
|
48
46
|
*/
|
|
49
47
|
ClientAddressNotAvailable: {
|
|
50
48
|
title: "`Astro.clientAddress` is not available in current adapter.",
|
|
51
|
-
code: 3002,
|
|
52
49
|
message: (adapterName) => `\`Astro.clientAddress\` is not available in the \`${adapterName}\` adapter. File an issue with the adapter to add support.`
|
|
53
50
|
},
|
|
54
51
|
/**
|
|
@@ -63,7 +60,6 @@ const AstroErrorData = {
|
|
|
63
60
|
*/
|
|
64
61
|
StaticClientAddressNotAvailable: {
|
|
65
62
|
title: "`Astro.clientAddress` is not available in static mode.",
|
|
66
|
-
code: 3003,
|
|
67
63
|
message: "`Astro.clientAddress` is only available when using `output: 'server'` or `output: 'hybrid'`. Update your Astro config if you need SSR features.",
|
|
68
64
|
hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
|
|
69
65
|
},
|
|
@@ -76,7 +72,6 @@ const AstroErrorData = {
|
|
|
76
72
|
*/
|
|
77
73
|
NoMatchingStaticPathFound: {
|
|
78
74
|
title: "No static path found for requested path.",
|
|
79
|
-
code: 3004,
|
|
80
75
|
message: (pathName) => `A \`getStaticPaths()\` route pattern was matched, but no matching static path was found for requested path \`${pathName}\`.`,
|
|
81
76
|
hint: (possibleRoutes) => `Possible dynamic routes being matched: ${possibleRoutes.join(", ")}.`
|
|
82
77
|
},
|
|
@@ -102,7 +97,6 @@ const AstroErrorData = {
|
|
|
102
97
|
*/
|
|
103
98
|
OnlyResponseCanBeReturned: {
|
|
104
99
|
title: "Invalid type returned by Astro page.",
|
|
105
|
-
code: 3005,
|
|
106
100
|
message: (route, returnedValue) => `Route \`${route ? route : ""}\` returned a \`${returnedValue}\`. Only a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned from Astro files.`,
|
|
107
101
|
hint: "See https://docs.astro.build/en/guides/server-side-rendering/#response for more information."
|
|
108
102
|
},
|
|
@@ -119,7 +113,6 @@ const AstroErrorData = {
|
|
|
119
113
|
*/
|
|
120
114
|
MissingMediaQueryDirective: {
|
|
121
115
|
title: "Missing value for `client:media` directive.",
|
|
122
|
-
code: 3006,
|
|
123
116
|
message: 'Media query not provided for `client:media` directive. A media query similar to `client:media="(max-width: 600px)"` must be provided'
|
|
124
117
|
},
|
|
125
118
|
/**
|
|
@@ -135,7 +128,6 @@ const AstroErrorData = {
|
|
|
135
128
|
*/
|
|
136
129
|
NoMatchingRenderer: {
|
|
137
130
|
title: "No matching renderer found.",
|
|
138
|
-
code: 3007,
|
|
139
131
|
message: (componentName, componentExtension, plural, validRenderersCount) => `Unable to render \`${componentName}\`.
|
|
140
132
|
|
|
141
133
|
${validRenderersCount > 0 ? `There ${plural ? "are" : "is"} ${validRenderersCount} renderer${plural ? "s" : ""} configured in your \`astro.config.mjs\` file,
|
|
@@ -155,7 +147,6 @@ See https://docs.astro.build/en/core-concepts/framework-components/ for more inf
|
|
|
155
147
|
*/
|
|
156
148
|
NoClientEntrypoint: {
|
|
157
149
|
title: "No client entrypoint specified in renderer.",
|
|
158
|
-
code: 3008,
|
|
159
150
|
message: (componentName, clientDirective, rendererName) => `\`${componentName}\` component has a \`client:${clientDirective}\` directive, but no client entrypoint was provided by \`${rendererName}\`.`,
|
|
160
151
|
hint: "See https://docs.astro.build/en/reference/integrations-reference/#addrenderer-option for more information on how to configure your renderer."
|
|
161
152
|
},
|
|
@@ -173,7 +164,6 @@ See https://docs.astro.build/en/core-concepts/framework-components/ for more inf
|
|
|
173
164
|
*/
|
|
174
165
|
NoClientOnlyHint: {
|
|
175
166
|
title: "Missing hint on client:only directive.",
|
|
176
|
-
code: 3009,
|
|
177
167
|
message: (componentName) => `Unable to render \`${componentName}\`. When using the \`client:only\` hydration strategy, Astro needs a hint to use the correct renderer.`,
|
|
178
168
|
hint: (probableRenderers) => `Did you mean to pass \`client:only="${probableRenderers}"\`? See https://docs.astro.build/en/reference/directives-reference/#clientonly for more information on client:only`
|
|
179
169
|
},
|
|
@@ -198,7 +188,6 @@ See https://docs.astro.build/en/core-concepts/framework-components/ for more inf
|
|
|
198
188
|
*/
|
|
199
189
|
InvalidGetStaticPathParam: {
|
|
200
190
|
title: "Invalid value returned by a `getStaticPaths` path.",
|
|
201
|
-
code: 3010,
|
|
202
191
|
message: (paramType) => `Invalid params given to \`getStaticPaths\` path. Expected an \`object\`, got \`${paramType}\``,
|
|
203
192
|
hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
|
|
204
193
|
},
|
|
@@ -221,7 +210,6 @@ See https://docs.astro.build/en/core-concepts/framework-components/ for more inf
|
|
|
221
210
|
*/
|
|
222
211
|
InvalidGetStaticPathsReturn: {
|
|
223
212
|
title: "Invalid value returned by getStaticPaths.",
|
|
224
|
-
code: 3011,
|
|
225
213
|
message: (returnType) => `Invalid type returned by \`getStaticPaths\`. Expected an \`array\`, got \`${returnType}\``,
|
|
226
214
|
hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
|
|
227
215
|
},
|
|
@@ -234,7 +222,6 @@ See https://docs.astro.build/en/core-concepts/framework-components/ for more inf
|
|
|
234
222
|
*/
|
|
235
223
|
GetStaticPathsRemovedRSSHelper: {
|
|
236
224
|
title: "getStaticPaths RSS helper is not available anymore.",
|
|
237
|
-
code: 3012,
|
|
238
225
|
message: "The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead.",
|
|
239
226
|
hint: "See https://docs.astro.build/en/guides/rss/ for more information."
|
|
240
227
|
},
|
|
@@ -260,7 +247,6 @@ See https://docs.astro.build/en/core-concepts/framework-components/ for more inf
|
|
|
260
247
|
*/
|
|
261
248
|
GetStaticPathsExpectedParams: {
|
|
262
249
|
title: "Missing params property on `getStaticPaths` route.",
|
|
263
|
-
code: 3013,
|
|
264
250
|
message: "Missing or empty required `params` property on `getStaticPaths` route.",
|
|
265
251
|
hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
|
|
266
252
|
},
|
|
@@ -300,7 +286,6 @@ See https://docs.astro.build/en/core-concepts/framework-components/ for more inf
|
|
|
300
286
|
*/
|
|
301
287
|
GetStaticPathsInvalidRouteParam: {
|
|
302
288
|
title: "Invalid value for `getStaticPaths` route parameter.",
|
|
303
|
-
code: 3014,
|
|
304
289
|
message: (key, value, valueType) => `Invalid getStaticPaths route parameter for \`${key}\`. Expected undefined, a string or a number, received \`${valueType}\` (\`${value}\`)`,
|
|
305
290
|
hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
|
|
306
291
|
},
|
|
@@ -315,7 +300,6 @@ See https://docs.astro.build/en/core-concepts/framework-components/ for more inf
|
|
|
315
300
|
*/
|
|
316
301
|
GetStaticPathsRequired: {
|
|
317
302
|
title: "`getStaticPaths()` function required for dynamic routes.",
|
|
318
|
-
code: 3015,
|
|
319
303
|
message: "`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.",
|
|
320
304
|
hint: `See https://docs.astro.build/en/core-concepts/routing/#dynamic-routes for more information on dynamic routes.
|
|
321
305
|
|
|
@@ -331,7 +315,6 @@ See https://docs.astro.build/en/guides/server-side-rendering/ for more informati
|
|
|
331
315
|
*/
|
|
332
316
|
ReservedSlotName: {
|
|
333
317
|
title: "Invalid slot name.",
|
|
334
|
-
code: 3016,
|
|
335
318
|
message: (slotName) => `Unable to create a slot named \`${slotName}\`. \`${slotName}\` is a reserved slot name. Please update the name of this slot.`
|
|
336
319
|
},
|
|
337
320
|
/**
|
|
@@ -344,7 +327,6 @@ See https://docs.astro.build/en/guides/server-side-rendering/ for more informati
|
|
|
344
327
|
*/
|
|
345
328
|
NoAdapterInstalled: {
|
|
346
329
|
title: "Cannot use Server-side Rendering without an adapter.",
|
|
347
|
-
code: 3017,
|
|
348
330
|
message: `Cannot use \`output: 'server'\` or \`output: 'hybrid'\` without an adapter. Please install and configure the appropriate server adapter for your final deployment.`,
|
|
349
331
|
hint: "See https://docs.astro.build/en/guides/server-side-rendering/ for more information."
|
|
350
332
|
},
|
|
@@ -355,7 +337,6 @@ See https://docs.astro.build/en/guides/server-side-rendering/ for more informati
|
|
|
355
337
|
*/
|
|
356
338
|
NoMatchingImport: {
|
|
357
339
|
title: "No import found for component.",
|
|
358
|
-
code: 3018,
|
|
359
340
|
message: (componentName) => `Could not render \`${componentName}\`. No matching import has been found for \`${componentName}\`.`,
|
|
360
341
|
hint: "Please make sure the component is properly imported."
|
|
361
342
|
},
|
|
@@ -369,7 +350,6 @@ See https://docs.astro.build/en/guides/server-side-rendering/ for more informati
|
|
|
369
350
|
*/
|
|
370
351
|
InvalidPrerenderExport: {
|
|
371
352
|
title: "Invalid prerender export.",
|
|
372
|
-
code: 3019,
|
|
373
353
|
message: (prefix, suffix, isHydridOuput) => {
|
|
374
354
|
const defaultExpectedValue = isHydridOuput ? "false" : "true";
|
|
375
355
|
let msg = `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`;
|
|
@@ -393,7 +373,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
393
373
|
*/
|
|
394
374
|
InvalidComponentArgs: {
|
|
395
375
|
title: "Invalid component arguments.",
|
|
396
|
-
code: 3020,
|
|
397
376
|
message: (name) => `Invalid arguments passed to${name ? ` <${name}>` : ""} component.`,
|
|
398
377
|
hint: "Astro components cannot be rendered directly via function call, such as `Component()` or `{items.map(Component)}`."
|
|
399
378
|
},
|
|
@@ -406,7 +385,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
406
385
|
*/
|
|
407
386
|
PageNumberParamNotFound: {
|
|
408
387
|
title: "Page number param not found.",
|
|
409
|
-
code: 3021,
|
|
410
388
|
message: (paramName) => `[paginate()] page number param \`${paramName}\` not found in your filepath.`,
|
|
411
389
|
hint: "Rename your file to `[page].astro` or `[...page].astro`."
|
|
412
390
|
},
|
|
@@ -423,7 +401,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
423
401
|
*/
|
|
424
402
|
ImageMissingAlt: {
|
|
425
403
|
title: "Missing alt property.",
|
|
426
|
-
code: 3022,
|
|
427
404
|
message: "The alt property is required.",
|
|
428
405
|
hint: "The `alt` property is important for the purpose of accessibility, without it users using screen readers or other assistive technologies won't be able to understand what your image is supposed to represent. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-alt for more information."
|
|
429
406
|
},
|
|
@@ -438,7 +415,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
438
415
|
*/
|
|
439
416
|
InvalidImageService: {
|
|
440
417
|
title: "Error while loading image service.",
|
|
441
|
-
code: 3023,
|
|
442
418
|
message: "There was an error loading the configured image service. Please see the stack trace for more information."
|
|
443
419
|
},
|
|
444
420
|
/**
|
|
@@ -455,7 +431,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
455
431
|
*/
|
|
456
432
|
MissingImageDimension: {
|
|
457
433
|
title: "Missing image dimensions",
|
|
458
|
-
code: 3024,
|
|
459
434
|
message: (missingDimension, imageURL) => `Missing ${missingDimension === "both" ? "width and height attributes" : `${missingDimension} attribute`} for ${imageURL}. When using remote images, both dimensions are always required in order to avoid CLS.`,
|
|
460
435
|
hint: "If your image is inside your `src` folder, you probably meant to import it instead. See [the Imports guide for more information](https://docs.astro.build/en/guides/imports/#other-assets)."
|
|
461
436
|
},
|
|
@@ -475,7 +450,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
475
450
|
*/
|
|
476
451
|
UnsupportedImageFormat: {
|
|
477
452
|
title: "Unsupported image format",
|
|
478
|
-
code: 3025,
|
|
479
453
|
message: (format, imagePath, supportedFormats) => `Received unsupported format \`${format}\` from \`${imagePath}\`. Currently only ${supportedFormats.join(
|
|
480
454
|
", "
|
|
481
455
|
)} are supported for optimization.`,
|
|
@@ -493,7 +467,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
493
467
|
*/
|
|
494
468
|
PrerenderDynamicEndpointPathCollide: {
|
|
495
469
|
title: "Prerendered dynamic endpoint has path collision.",
|
|
496
|
-
code: 3026,
|
|
497
470
|
message: (pathname) => `Could not render \`${pathname}\` with an \`undefined\` param as the generated path will collide during prerendering. Prevent passing \`undefined\` as \`params\` for the endpoint's \`getStaticPaths()\` function, or add an additional extension to the endpoint's filename.`,
|
|
498
471
|
hint: (filename) => `Rename \`${filename}\` to \`${filename.replace(/\.(js|ts)/, (m) => `.json` + m)}\``
|
|
499
472
|
},
|
|
@@ -518,7 +491,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
518
491
|
*/
|
|
519
492
|
ExpectedImage: {
|
|
520
493
|
title: "Expected src to be an image.",
|
|
521
|
-
code: 3027,
|
|
522
494
|
message: (options) => `Expected \`src\` property to be either an ESM imported image or a string with the path of a remote image. Received \`${options}\`.`,
|
|
523
495
|
hint: "This error can often happen because of a wrong path. Make sure the path to your image is correct."
|
|
524
496
|
},
|
|
@@ -540,7 +512,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
540
512
|
*/
|
|
541
513
|
ExpectedImageOptions: {
|
|
542
514
|
title: "Expected image options.",
|
|
543
|
-
code: 3028,
|
|
544
515
|
message: (options) => `Expected getImage() parameter to be an object. Received \`${options}\`.`
|
|
545
516
|
},
|
|
546
517
|
/**
|
|
@@ -556,7 +527,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
556
527
|
*/
|
|
557
528
|
MarkdownImageNotFound: {
|
|
558
529
|
title: "Image not found.",
|
|
559
|
-
code: 3029,
|
|
560
530
|
message: (imagePath, fullImagePath) => `Could not find requested image \`${imagePath}\`${fullImagePath ? ` at \`${fullImagePath}\`.` : "."}`,
|
|
561
531
|
hint: "This is often caused by a typo in the image path. Please make sure the file exists, and is spelled correctly."
|
|
562
532
|
},
|
|
@@ -567,7 +537,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
567
537
|
*/
|
|
568
538
|
ResponseSentError: {
|
|
569
539
|
title: "Unable to set response.",
|
|
570
|
-
code: 3030,
|
|
571
540
|
message: "The response has already been sent to the browser and cannot be altered."
|
|
572
541
|
},
|
|
573
542
|
/**
|
|
@@ -586,7 +555,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
586
555
|
*/
|
|
587
556
|
MiddlewareNoDataOrNextCalled: {
|
|
588
557
|
title: "The middleware didn't return a response or call `next`.",
|
|
589
|
-
code: 3031,
|
|
590
558
|
message: "The middleware needs to either return a `Response` object or call the `next` function."
|
|
591
559
|
},
|
|
592
560
|
/**
|
|
@@ -604,7 +572,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
604
572
|
*/
|
|
605
573
|
MiddlewareNotAResponse: {
|
|
606
574
|
title: "The middleware returned something that is not a `Response` object.",
|
|
607
|
-
code: 3032,
|
|
608
575
|
message: "Any data returned from middleware must be a valid `Response` object."
|
|
609
576
|
},
|
|
610
577
|
/**
|
|
@@ -624,7 +591,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
624
591
|
*/
|
|
625
592
|
LocalsNotAnObject: {
|
|
626
593
|
title: "Value assigned to `locals` is not accepted.",
|
|
627
|
-
code: 3033,
|
|
628
594
|
message: "`locals` can only be assigned to an object. Other values like numbers, strings, etc. are not accepted.",
|
|
629
595
|
hint: "If you tried to remove some information from the `locals` object, try to use `delete` or set the property to `undefined`."
|
|
630
596
|
},
|
|
@@ -650,7 +616,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
650
616
|
*/
|
|
651
617
|
LocalImageUsedWrongly: {
|
|
652
618
|
title: "ESM imported images must be passed as-is.",
|
|
653
|
-
code: 3034,
|
|
654
619
|
message: (imageFilePath) => `\`Image\`'s and \`getImage\`'s \`src\` parameter must be an imported image or an URL, it cannot be a filepath. Received \`${imageFilePath}\`.`
|
|
655
620
|
},
|
|
656
621
|
/**
|
|
@@ -662,7 +627,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
662
627
|
*/
|
|
663
628
|
AstroGlobUsedOutside: {
|
|
664
629
|
title: "Astro.glob() used outside of an Astro file.",
|
|
665
|
-
code: 3035,
|
|
666
630
|
message: (globStr) => `\`Astro.glob(${globStr})\` can only be used in \`.astro\` files. \`import.meta.glob(${globStr})\` can be used instead to achieve a similar result.`,
|
|
667
631
|
hint: "See Vite's documentation on `import.meta.glob` for more information: https://vitejs.dev/guide/features.html#glob-import"
|
|
668
632
|
},
|
|
@@ -675,7 +639,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
675
639
|
*/
|
|
676
640
|
AstroGlobNoMatch: {
|
|
677
641
|
title: "Astro.glob() did not match any files.",
|
|
678
|
-
code: 3036,
|
|
679
642
|
message: (globStr) => `\`Astro.glob(${globStr})\` did not return any matching files. Check the pattern for typos.`
|
|
680
643
|
},
|
|
681
644
|
/**
|
|
@@ -686,8 +649,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
686
649
|
* A redirect must be given a location with the `Location` header.
|
|
687
650
|
*/
|
|
688
651
|
RedirectWithNoLocation: {
|
|
689
|
-
title: "A redirect must be given a location with the `Location` header."
|
|
690
|
-
code: 3037
|
|
652
|
+
title: "A redirect must be given a location with the `Location` header."
|
|
691
653
|
},
|
|
692
654
|
/**
|
|
693
655
|
* @docs
|
|
@@ -698,7 +660,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
698
660
|
*/
|
|
699
661
|
InvalidDynamicRoute: {
|
|
700
662
|
title: "Invalid dynamic route.",
|
|
701
|
-
code: 3038,
|
|
702
663
|
message: (route, invalidParam, received) => `The ${invalidParam} param for route ${route} is invalid. Received **${received}**.`
|
|
703
664
|
},
|
|
704
665
|
// No headings here, that way Vite errors are merged with Astro ones in the docs, which makes more sense to users.
|
|
@@ -713,8 +674,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
713
674
|
* If you can reliably cause this error to happen, we'd appreciate if you could [open an issue](https://astro.build/issues/)
|
|
714
675
|
*/
|
|
715
676
|
UnknownViteError: {
|
|
716
|
-
title: "Unknown Vite Error."
|
|
717
|
-
code: 4e3
|
|
677
|
+
title: "Unknown Vite Error."
|
|
718
678
|
},
|
|
719
679
|
/**
|
|
720
680
|
* @docs
|
|
@@ -727,7 +687,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
727
687
|
*/
|
|
728
688
|
FailedToLoadModuleSSR: {
|
|
729
689
|
title: "Could not import file.",
|
|
730
|
-
code: 4001,
|
|
731
690
|
message: (importName) => `Could not import \`${importName}\`.`,
|
|
732
691
|
hint: "This is often caused by a typo in the import path. Please make sure the file exists."
|
|
733
692
|
},
|
|
@@ -740,7 +699,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
740
699
|
*/
|
|
741
700
|
InvalidGlob: {
|
|
742
701
|
title: "Invalid glob pattern.",
|
|
743
|
-
code: 4002,
|
|
744
702
|
message: (globPattern) => `Invalid glob pattern: \`${globPattern}\`. Glob patterns must start with './', '../' or '/'.`,
|
|
745
703
|
hint: "See https://docs.astro.build/en/guides/imports/#glob-patterns for more information on supported glob patterns."
|
|
746
704
|
},
|
|
@@ -751,7 +709,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
751
709
|
*/
|
|
752
710
|
FailedToFindPageMapSSR: {
|
|
753
711
|
title: "Astro couldn't find the correct page to render",
|
|
754
|
-
code: 4003,
|
|
755
712
|
message: "Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error. Please file an issue."
|
|
756
713
|
},
|
|
757
714
|
/**
|
|
@@ -768,8 +725,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
768
725
|
* Astro encountered an unknown error while parsing your CSS. Oftentimes, this is caused by a syntax error and the error message should contain more information.
|
|
769
726
|
*/
|
|
770
727
|
UnknownCSSError: {
|
|
771
|
-
title: "Unknown CSS Error."
|
|
772
|
-
code: 5e3
|
|
728
|
+
title: "Unknown CSS Error."
|
|
773
729
|
},
|
|
774
730
|
/**
|
|
775
731
|
* @docs
|
|
@@ -781,8 +737,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
781
737
|
* Astro encountered an error while parsing your CSS, due to a syntax error. This is often caused by a missing semicolon.
|
|
782
738
|
*/
|
|
783
739
|
CSSSyntaxError: {
|
|
784
|
-
title: "CSS Syntax Error."
|
|
785
|
-
code: 5001
|
|
740
|
+
title: "CSS Syntax Error."
|
|
786
741
|
},
|
|
787
742
|
/**
|
|
788
743
|
* @docs
|
|
@@ -796,8 +751,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
796
751
|
* Astro encountered an unknown error while parsing your Markdown. Oftentimes, this is caused by a syntax error and the error message should contain more information.
|
|
797
752
|
*/
|
|
798
753
|
UnknownMarkdownError: {
|
|
799
|
-
title: "Unknown Markdown Error."
|
|
800
|
-
code: 6e3
|
|
754
|
+
title: "Unknown Markdown Error."
|
|
801
755
|
},
|
|
802
756
|
/**
|
|
803
757
|
* @docs
|
|
@@ -811,8 +765,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
811
765
|
* This is often caused by a mistake in the syntax, such as a missing colon or a missing end quote.
|
|
812
766
|
*/
|
|
813
767
|
MarkdownFrontmatterParseError: {
|
|
814
|
-
title: "Failed to parse Markdown frontmatter."
|
|
815
|
-
code: 6001
|
|
768
|
+
title: "Failed to parse Markdown frontmatter."
|
|
816
769
|
},
|
|
817
770
|
/**
|
|
818
771
|
* @docs
|
|
@@ -823,7 +776,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
823
776
|
*/
|
|
824
777
|
InvalidFrontmatterInjectionError: {
|
|
825
778
|
title: "Invalid frontmatter injection.",
|
|
826
|
-
code: 6003,
|
|
827
779
|
message: 'A remark or rehype plugin attempted to inject invalid frontmatter. Ensure "astro.frontmatter" is set to a valid JSON object that is not `null` or `undefined`.',
|
|
828
780
|
hint: "See the frontmatter injection docs https://docs.astro.build/en/guides/markdown-content/#modifying-frontmatter-programmatically for more information."
|
|
829
781
|
},
|
|
@@ -836,7 +788,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
836
788
|
*/
|
|
837
789
|
MdxIntegrationMissingError: {
|
|
838
790
|
title: "MDX integration missing.",
|
|
839
|
-
code: 6004,
|
|
840
791
|
message: (file) => `Unable to render ${file}. Ensure that the \`@astrojs/mdx\` integration is installed.`,
|
|
841
792
|
hint: "See the MDX integration docs for installation and usage instructions: https://docs.astro.build/en/guides/integrations-guide/mdx/"
|
|
842
793
|
},
|
|
@@ -852,8 +803,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
852
803
|
* If you can reliably cause this error to happen, we'd appreciate if you could [open an issue](https://astro.build/issues/)
|
|
853
804
|
*/
|
|
854
805
|
UnknownConfigError: {
|
|
855
|
-
title: "Unknown configuration error."
|
|
856
|
-
code: 7e3
|
|
806
|
+
title: "Unknown configuration error."
|
|
857
807
|
},
|
|
858
808
|
/**
|
|
859
809
|
* @docs
|
|
@@ -864,7 +814,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
864
814
|
*/
|
|
865
815
|
ConfigNotFound: {
|
|
866
816
|
title: "Specified configuration file not found.",
|
|
867
|
-
code: 7001,
|
|
868
817
|
message: (configFile) => `Unable to resolve \`--config "${configFile}"\`. Does the file exist?`
|
|
869
818
|
},
|
|
870
819
|
/**
|
|
@@ -876,7 +825,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
876
825
|
*/
|
|
877
826
|
ConfigLegacyKey: {
|
|
878
827
|
title: "Legacy configuration detected.",
|
|
879
|
-
code: 7002,
|
|
880
828
|
message: (legacyConfigKey) => `Legacy configuration detected: \`${legacyConfigKey}\`.`,
|
|
881
829
|
hint: "Please update your configuration to the new format.\nSee https://astro.build/config for more information."
|
|
882
830
|
},
|
|
@@ -894,8 +842,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
894
842
|
* If you can reliably cause this error to happen, we'd appreciate if you could [open an issue](https://astro.build/issues/)
|
|
895
843
|
*/
|
|
896
844
|
UnknownCLIError: {
|
|
897
|
-
title: "Unknown CLI Error."
|
|
898
|
-
code: 8e3
|
|
845
|
+
title: "Unknown CLI Error."
|
|
899
846
|
},
|
|
900
847
|
/**
|
|
901
848
|
* @docs
|
|
@@ -906,7 +853,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
906
853
|
*/
|
|
907
854
|
GenerateContentTypesError: {
|
|
908
855
|
title: "Failed to generate content types.",
|
|
909
|
-
code: 8001,
|
|
910
856
|
message: (errorMessage) => `\`astro sync\` command failed to generate content collection types: ${errorMessage}`,
|
|
911
857
|
hint: "Check your `src/content/config.*` file for typos."
|
|
912
858
|
},
|
|
@@ -925,8 +871,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
925
871
|
* If you can reliably cause this error to happen, we'd appreciate if you could [open an issue](https://astro.build/issues/)
|
|
926
872
|
*/
|
|
927
873
|
UnknownContentCollectionError: {
|
|
928
|
-
title: "Unknown Content Collection Error."
|
|
929
|
-
code: 9e3
|
|
874
|
+
title: "Unknown Content Collection Error."
|
|
930
875
|
},
|
|
931
876
|
/**
|
|
932
877
|
* @docs
|
|
@@ -943,7 +888,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
943
888
|
*/
|
|
944
889
|
InvalidContentEntryFrontmatterError: {
|
|
945
890
|
title: "Content entry frontmatter does not match schema.",
|
|
946
|
-
code: 9001,
|
|
947
891
|
message: (collection, entryId, error) => {
|
|
948
892
|
return [
|
|
949
893
|
`**${String(collection)} \u2192 ${String(
|
|
@@ -964,7 +908,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
964
908
|
*/
|
|
965
909
|
InvalidContentEntrySlugError: {
|
|
966
910
|
title: "Invalid content entry slug.",
|
|
967
|
-
code: 9002,
|
|
968
911
|
message: (collection, entryId) => {
|
|
969
912
|
return `${String(collection)} \u2192 ${String(
|
|
970
913
|
entryId
|
|
@@ -981,7 +924,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
981
924
|
*/
|
|
982
925
|
ContentSchemaContainsSlugError: {
|
|
983
926
|
title: "Content Schema should not contain `slug`.",
|
|
984
|
-
code: 9003,
|
|
985
927
|
message: (collectionName) => `A content collection schema should not contain \`slug\` since it is reserved for slug generation. Remove this from your ${collectionName} collection schema.`,
|
|
986
928
|
hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."
|
|
987
929
|
},
|
|
@@ -993,7 +935,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
993
935
|
*/
|
|
994
936
|
CollectionDoesNotExistError: {
|
|
995
937
|
title: "Collection does not exist",
|
|
996
|
-
code: 9004,
|
|
997
938
|
message: (collectionName) => `The collection **${collectionName}** does not exist. Ensure a collection directory with this name exists.`,
|
|
998
939
|
hint: "See https://docs.astro.build/en/guides/content-collections/ for more on creating collections."
|
|
999
940
|
},
|
|
@@ -1007,7 +948,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
1007
948
|
*/
|
|
1008
949
|
MixedContentDataCollectionError: {
|
|
1009
950
|
title: "Content and data cannot be in same collection.",
|
|
1010
|
-
code: 9005,
|
|
1011
951
|
message: (collection) => {
|
|
1012
952
|
return `**${collection}** contains a mix of content and data entries. All entries must be of the same type.`;
|
|
1013
953
|
},
|
|
@@ -1023,7 +963,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
1023
963
|
*/
|
|
1024
964
|
ContentCollectionTypeMismatchError: {
|
|
1025
965
|
title: "Collection contains entries of a different type.",
|
|
1026
|
-
code: 9006,
|
|
1027
966
|
message: (collection, expectedType, actualType) => {
|
|
1028
967
|
return `${collection} contains ${expectedType} entries, but is configured as a ${actualType} collection.`;
|
|
1029
968
|
}
|
|
@@ -1036,7 +975,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
1036
975
|
*/
|
|
1037
976
|
DataCollectionEntryParseError: {
|
|
1038
977
|
title: "Data collection entry failed to parse.",
|
|
1039
|
-
code: 9007,
|
|
1040
978
|
message: (entryId, errorMessage) => {
|
|
1041
979
|
return `**${entryId}** failed to parse: ${errorMessage}`;
|
|
1042
980
|
},
|
|
@@ -1050,7 +988,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
1050
988
|
*/
|
|
1051
989
|
DuplicateContentEntrySlugError: {
|
|
1052
990
|
title: "Duplicate content entry slug.",
|
|
1053
|
-
code: 9008,
|
|
1054
991
|
message: (collection, slug) => {
|
|
1055
992
|
return `**${collection}** contains multiple entries with the same slug: \`${slug}\`. Slugs must be unique.`;
|
|
1056
993
|
}
|
|
@@ -1064,15 +1001,13 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
1064
1001
|
*/
|
|
1065
1002
|
UnsupportedConfigTransformError: {
|
|
1066
1003
|
title: "Unsupported transform in content config.",
|
|
1067
|
-
code: 9008,
|
|
1068
1004
|
message: (parseError) => `\`transform()\` functions in your content config must return valid JSON, or data types compatible with the devalue library (including Dates, Maps, and Sets).
|
|
1069
1005
|
Full error: ${parseError}`,
|
|
1070
1006
|
hint: "See the devalue library for all supported types: https://github.com/rich-harris/devalue"
|
|
1071
1007
|
},
|
|
1072
1008
|
// Generic catch-all - Only use this in extreme cases, like if there was a cosmic ray bit flip
|
|
1073
1009
|
UnknownError: {
|
|
1074
|
-
title: "Unknown Error."
|
|
1075
|
-
code: 99999
|
|
1010
|
+
title: "Unknown Error."
|
|
1076
1011
|
}
|
|
1077
1012
|
};
|
|
1078
1013
|
export {
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type { DiagnosticMessage } from '@astrojs/compiler';
|
|
2
|
-
import type { AstroErrorCodes } from './errors-data.js';
|
|
3
|
-
type DiagnosticCode = DiagnosticMessage['code'];
|
|
4
1
|
interface ErrorProperties {
|
|
5
|
-
code: AstroErrorCodes | DiagnosticCode;
|
|
6
2
|
title?: string;
|
|
7
3
|
name?: string;
|
|
8
4
|
message?: string;
|
|
@@ -19,14 +15,12 @@ export interface ErrorLocation {
|
|
|
19
15
|
type ErrorTypes = 'AstroError' | 'CompilerError' | 'CSSError' | 'MarkdownError' | 'InternalError' | 'AggregateError';
|
|
20
16
|
export declare function isAstroError(e: unknown): e is AstroError;
|
|
21
17
|
export declare class AstroError extends Error {
|
|
22
|
-
errorCode: AstroErrorCodes | DiagnosticCode;
|
|
23
18
|
loc: ErrorLocation | undefined;
|
|
24
19
|
title: string | undefined;
|
|
25
20
|
hint: string | undefined;
|
|
26
21
|
frame: string | undefined;
|
|
27
22
|
type: ErrorTypes;
|
|
28
23
|
constructor(props: ErrorProperties, ...params: any);
|
|
29
|
-
setErrorCode(errorCode: AstroErrorCodes): void;
|
|
30
24
|
setLocation(location: ErrorLocation): void;
|
|
31
25
|
setName(name: string): void;
|
|
32
26
|
setMessage(message: string): void;
|
|
@@ -36,9 +30,7 @@ export declare class AstroError extends Error {
|
|
|
36
30
|
}
|
|
37
31
|
export declare class CompilerError extends AstroError {
|
|
38
32
|
type: ErrorTypes;
|
|
39
|
-
constructor(props:
|
|
40
|
-
code: DiagnosticCode;
|
|
41
|
-
}, ...params: any);
|
|
33
|
+
constructor(props: ErrorProperties, ...params: any);
|
|
42
34
|
static is(err: Error | unknown): err is CompilerError;
|
|
43
35
|
}
|
|
44
36
|
export declare class CSSError extends AstroError {
|
|
@@ -72,7 +64,6 @@ export interface ErrorWithMetadata {
|
|
|
72
64
|
type?: ErrorTypes;
|
|
73
65
|
message: string;
|
|
74
66
|
stack: string;
|
|
75
|
-
errorCode?: number;
|
|
76
67
|
hint?: string;
|
|
77
68
|
id?: string;
|
|
78
69
|
frame?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { codeFrame } from "./printer.js";
|
|
2
|
-
import {
|
|
2
|
+
import { getErrorDataByTitle } from "./utils.js";
|
|
3
3
|
function isAstroError(e) {
|
|
4
4
|
return e instanceof Error && e.type === "AstroError";
|
|
5
5
|
}
|
|
@@ -8,14 +8,16 @@ class AstroError extends Error {
|
|
|
8
8
|
var _a;
|
|
9
9
|
super(...params);
|
|
10
10
|
this.type = "AstroError";
|
|
11
|
-
const {
|
|
12
|
-
this.
|
|
11
|
+
const { name, title, message, stack, location, hint, frame } = props;
|
|
12
|
+
this.title = title;
|
|
13
13
|
if (name && name !== "Error") {
|
|
14
14
|
this.name = name;
|
|
15
|
-
} else {
|
|
16
|
-
|
|
15
|
+
} else if (this.title) {
|
|
16
|
+
const errorData = (_a = getErrorDataByTitle(this.title)) == null ? void 0 : _a.name;
|
|
17
|
+
if (errorData) {
|
|
18
|
+
this.name = errorData;
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
|
-
this.title = title;
|
|
19
21
|
if (message)
|
|
20
22
|
this.message = message;
|
|
21
23
|
this.stack = stack ? stack : this.stack;
|
|
@@ -23,9 +25,6 @@ class AstroError extends Error {
|
|
|
23
25
|
this.hint = hint;
|
|
24
26
|
this.frame = frame;
|
|
25
27
|
}
|
|
26
|
-
setErrorCode(errorCode) {
|
|
27
|
-
this.errorCode = errorCode;
|
|
28
|
-
}
|
|
29
28
|
setLocation(location) {
|
|
30
29
|
this.loc = location;
|
|
31
30
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { ErrorLocation, ErrorWithMetadata } from './errors';
|
|
2
|
-
export { AstroErrorData
|
|
2
|
+
export { AstroErrorData } from './errors-data.js';
|
|
3
3
|
export { AggregateError, AstroError, CompilerError, CSSError, isAstroError, MarkdownError, } from './errors.js';
|
|
4
4
|
export { codeFrame } from './printer.js';
|
|
5
5
|
export { createSafeError, positionAt } from './utils.js';
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type { DiagnosticMessage } from '@astrojs/compiler';
|
|
2
1
|
import type { YAMLException } from 'js-yaml';
|
|
3
2
|
import type { ErrorPayload as ViteErrorPayload } from 'vite';
|
|
4
|
-
import { type
|
|
5
|
-
type DiagnosticCode = DiagnosticMessage['code'];
|
|
3
|
+
import { type ErrorData } from './errors-data.js';
|
|
6
4
|
/**
|
|
7
5
|
* Get the line and character based on the offset
|
|
8
6
|
* @param offset The index of the position
|
|
@@ -18,8 +16,7 @@ export declare function formatYAMLException(e: YAMLException): ViteErrorPayload[
|
|
|
18
16
|
/** Coalesce any throw variable to an Error instance. */
|
|
19
17
|
export declare function createSafeError(err: any): Error;
|
|
20
18
|
export declare function normalizeLF(code: string): string;
|
|
21
|
-
export declare function
|
|
19
|
+
export declare function getErrorDataByTitle(title: string): {
|
|
22
20
|
name: string;
|
|
23
21
|
data: ErrorData;
|
|
24
22
|
} | undefined;
|
|
25
|
-
export {};
|
|
@@ -70,8 +70,8 @@ function createSafeError(err) {
|
|
|
70
70
|
function normalizeLF(code) {
|
|
71
71
|
return code.replace(/\r\n|\r(?!\n)|\n/g, "\n");
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
const entry = Object.entries(AstroErrorData).find((data) => data[1].
|
|
73
|
+
function getErrorDataByTitle(title) {
|
|
74
|
+
const entry = Object.entries(AstroErrorData).find((data) => data[1].title === title);
|
|
75
75
|
if (entry) {
|
|
76
76
|
return {
|
|
77
77
|
name: entry[0],
|
|
@@ -82,7 +82,7 @@ function getErrorDataByCode(code) {
|
|
|
82
82
|
export {
|
|
83
83
|
createSafeError,
|
|
84
84
|
formatYAMLException,
|
|
85
|
-
|
|
85
|
+
getErrorDataByTitle,
|
|
86
86
|
isYAMLException,
|
|
87
87
|
normalizeLF,
|
|
88
88
|
positionAt
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
base,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "2.7.
|
|
50
|
+
const version = "2.7.1";
|
|
51
51
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
52
52
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
53
53
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -233,7 +233,7 @@ function printHelp({
|
|
|
233
233
|
message.push(
|
|
234
234
|
linebreak(),
|
|
235
235
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
236
|
-
`v${"2.7.
|
|
236
|
+
`v${"2.7.1"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|