@nuxt/docs-nightly 5.0.0-29758166.c429b54c → 5.0.0-29758188.0ff9da9b
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.
|
@@ -342,6 +342,27 @@ In server routes, the error class is now `HTTPError` (replacing `createError` fr
|
|
|
342
342
|
In the Vue part of your app (the `app/` directory), Nuxt's `createError` composable continues to work and is the recommended way to throw errors.
|
|
343
343
|
::
|
|
344
344
|
|
|
345
|
+
#### `createError` No Longer Returns an `HTTPError` Instance
|
|
346
|
+
|
|
347
|
+
`NuxtError` is now its own class rather than a subclass of h3's `HTTPError`, so `instanceof HTTPError` no longer matches an error created with Nuxt's `createError`. Everything else is unchanged: the error keeps the same properties, serialises the same way, and is still mapped to the right HTTP response during SSR.
|
|
348
|
+
|
|
349
|
+
If you narrow errors by class, use one of the predicates instead:
|
|
350
|
+
|
|
351
|
+
```diff
|
|
352
|
+
- if (error instanceof HTTPError) {
|
|
353
|
+
+ if (HTTPError.isError(error)) {
|
|
354
|
+
// handles both `new HTTPError()` and Nuxt's `createError()`
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
```diff
|
|
359
|
+
+ import { isNuxtError } from '#app'
|
|
360
|
+
+
|
|
361
|
+
+ if (isNuxtError(error)) {
|
|
362
|
+
+ // narrows to errors created with Nuxt's `createError`
|
|
363
|
+
+ }
|
|
364
|
+
```
|
|
365
|
+
|
|
345
366
|
#### Server Event API Changes (h3 v2)
|
|
346
367
|
|
|
347
368
|
The `H3Event` object now uses Web standard APIs:
|
|
@@ -437,6 +458,49 @@ If you previously set `experimental.externalVue` explicitly, you should now remo
|
|
|
437
458
|
If you use `vue.runtimeCompiler: true`, the real compiler packages are still included as before.
|
|
438
459
|
::
|
|
439
460
|
|
|
461
|
+
### `experimental.parseErrorData` Is No Longer Configurable
|
|
462
|
+
|
|
463
|
+
🚦 **Impact Level**: Minimal
|
|
464
|
+
|
|
465
|
+
#### What Changed
|
|
466
|
+
|
|
467
|
+
The `experimental.parseErrorData` option is deprecated, and on Nuxt 5 it is forced on. Setting it to `false` logs a warning and is otherwise ignored, so `error.data` on the error page is always the value you passed to `createError`.
|
|
468
|
+
|
|
469
|
+
On `compatibilityVersion: 4` the option still works and `false` still gives you a stringified `error.data`, so the behaviour only changes when you opt in to Nuxt 5.
|
|
470
|
+
|
|
471
|
+
#### Reasons for Change
|
|
472
|
+
|
|
473
|
+
When Nuxt renders an error page it fetches `/__nuxt_error` internally, passing the error along with the request. That used to spread the error across one query parameter per field, and because query values are always strings, `error.data` arrived as a string and had to be parsed back. `parseErrorData` existed to opt out of that parsing.
|
|
474
|
+
|
|
475
|
+
The error is now sent as a single JSON-encoded parameter, so `error.data` keeps its original shape and is never stringified. Values also keep their types, so `status` is a number and booleans are booleans rather than the strings `'true'` and `'false'`. With nothing stringifying `error.data`, the option only survives to re-stringify it for apps that still expect a string.
|
|
476
|
+
|
|
477
|
+
#### Migration Steps
|
|
478
|
+
|
|
479
|
+
Remove the option:
|
|
480
|
+
|
|
481
|
+
```diff
|
|
482
|
+
export default defineNuxtConfig({
|
|
483
|
+
experimental: {
|
|
484
|
+
- parseErrorData: false,
|
|
485
|
+
},
|
|
486
|
+
})
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
If you set it to `false` in order to keep parsing `error.data` yourself, drop that parsing too, as `error.data` now keeps whatever value you passed to `createError`:
|
|
490
|
+
|
|
491
|
+
```diff
|
|
492
|
+
<script setup lang="ts">
|
|
493
|
+
import type { NuxtError } from '#app'
|
|
494
|
+
|
|
495
|
+
const props = defineProps({
|
|
496
|
+
error: Object as () => NuxtError
|
|
497
|
+
})
|
|
498
|
+
|
|
499
|
+
- const data = JSON.parse(props.error.data)
|
|
500
|
+
+ const data = props.error.data
|
|
501
|
+
</script>
|
|
502
|
+
```
|
|
503
|
+
|
|
440
504
|
### `@vitejs/plugin-vue-jsx` Is Now Optional
|
|
441
505
|
|
|
442
506
|
🚦 **Impact Level**: Minimal
|
|
@@ -192,12 +192,19 @@ export default defineNuxtConfig({
|
|
|
192
192
|
|
|
193
193
|
## parseErrorData
|
|
194
194
|
|
|
195
|
+
::warning
|
|
196
|
+
This option is deprecated and will be removed. With `compatibilityVersion: 5` it is forced on and setting it is ignored.
|
|
197
|
+
::
|
|
198
|
+
|
|
195
199
|
Whether to parse `error.data` when rendering a server error page.
|
|
196
200
|
|
|
197
|
-
|
|
201
|
+
It existed because the error was previously passed to the error page as individual query parameters, which stringified `error.data` and meant it had to be parsed back. Setting it to `false` opted out of that parsing and left you with the string.
|
|
202
|
+
|
|
203
|
+
The error is now JSON-encoded as a whole, so `error.data` arrives with its original shape and is never stringified. On `compatibilityVersion: 4`, setting this to `false` stringifies it again so existing error pages that call `JSON.parse(error.data)` keep working:
|
|
198
204
|
|
|
199
205
|
```ts twoslash [nuxt.config.ts]
|
|
200
206
|
export default defineNuxtConfig({
|
|
207
|
+
future: { compatibilityVersion: 4 },
|
|
201
208
|
experimental: {
|
|
202
209
|
parseErrorData: false,
|
|
203
210
|
},
|