@nuxt/docs-nightly 4.4.0-29533707.0a5a5c19 → 4.4.0-29533953.9698f387
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.
|
@@ -59,6 +59,7 @@ export default defineNuxtConfig({
|
|
|
59
59
|
When you set your `future.compatibilityVersion` to `5`, defaults throughout your Nuxt configuration will change to opt in to Nuxt v5 behavior, including:
|
|
60
60
|
|
|
61
61
|
- **Vite Environment API**: Automatically enables the new [Vite Environment API](/docs/4.x/getting-started/upgrade#migration-to-vite-environment-api) for improved build configuration
|
|
62
|
+
- **Normalized Page Names**: Page component names will [match their route names](/docs/4.x/getting-started/upgrade#normalized-page-component-names) for consistent `<KeepAlive>` behavior
|
|
62
63
|
- **`clearNuxtState` resets to defaults**: `clearNuxtState` will [reset state to its initial value](/docs/4.x/getting-started/upgrade#respect-defaults-when-clearing-usestate) instead of setting it to `undefined`
|
|
63
64
|
- Other Nuxt 5 improvements and changes as they become available
|
|
64
65
|
|
|
@@ -1374,6 +1375,41 @@ export default defineNuxtConfig({
|
|
|
1374
1375
|
Read more about Nitro's prerender configuration options.
|
|
1375
1376
|
::
|
|
1376
1377
|
|
|
1378
|
+
### Normalized Page Component Names
|
|
1379
|
+
|
|
1380
|
+
🚦 **Impact Level**: Minimal
|
|
1381
|
+
|
|
1382
|
+
#### What Changed
|
|
1383
|
+
|
|
1384
|
+
When `future.compatibilityVersion` is set to `5` (or `experimental.normalizePageNames` is enabled), page component names match their route names instead of using the filename. For example, `pages/foo/index.vue` will have the component name `foo` instead of `index`.
|
|
1385
|
+
|
|
1386
|
+
#### Reasons for Change
|
|
1387
|
+
|
|
1388
|
+
Previously, Vue assigned component names based on the filename. This meant multiple pages like `pages/foo/index.vue` and `pages/bar/index.vue` would both have the component name `index`. This made `<KeepAlive>` with `include`/`exclude` filters unreliable and required manually adding `defineOptions({ name: '...' })` to each page.
|
|
1389
|
+
|
|
1390
|
+
#### Migration Steps
|
|
1391
|
+
|
|
1392
|
+
If you rely on the current component names (e.g. in `<KeepAlive>` `include`/`exclude` lists), update them to use route names instead of filenames.
|
|
1393
|
+
|
|
1394
|
+
```diff
|
|
1395
|
+
<template>
|
|
1396
|
+
<NuxtPage :keepalive="{
|
|
1397
|
+
- include: ['index']
|
|
1398
|
+
+ include: ['foo']
|
|
1399
|
+
}" />
|
|
1400
|
+
</template>
|
|
1401
|
+
```
|
|
1402
|
+
|
|
1403
|
+
To disable this behavior:
|
|
1404
|
+
|
|
1405
|
+
```ts twoslash [nuxt.config.ts]
|
|
1406
|
+
export default defineNuxtConfig({
|
|
1407
|
+
experimental: {
|
|
1408
|
+
normalizePageNames: false,
|
|
1409
|
+
},
|
|
1410
|
+
})
|
|
1411
|
+
```
|
|
1412
|
+
|
|
1377
1413
|
## Nuxt 2 vs. Nuxt 3+
|
|
1378
1414
|
|
|
1379
1415
|
In the table below, there is a quick comparison between 3 versions of Nuxt:
|
|
@@ -607,6 +607,30 @@ But in order to auto-import it, you would need to use `SomeFolderMyComponent`.
|
|
|
607
607
|
|
|
608
608
|
By setting `experimental.normalizeComponentNames`, these two values match, and Vue will generate a component name that matches the Nuxt pattern for component naming.
|
|
609
609
|
|
|
610
|
+
## normalizePageNames
|
|
611
|
+
|
|
612
|
+
Ensure that page component names match their route names. This sets the `__name` property on page components so that Vue's `<KeepAlive>` can correctly identify them by name.
|
|
613
|
+
|
|
614
|
+
By default, Vue assigns component names based on the filename. For example, `pages/foo/index.vue` and `pages/bar/index.vue` would both have the component name `index`. This makes name-based `<KeepAlive>` filtering unreliable because multiple pages share the same name.
|
|
615
|
+
|
|
616
|
+
With `normalizePageNames` enabled, page components are named after their route (e.g. `foo` and `bar`), so you can use `<KeepAlive>` with `include`/`exclude` without manually adding `defineOptions({ name: '...' })` to each page.
|
|
617
|
+
|
|
618
|
+
This flag is enabled when `future.compatibilityVersion` is set to `5` or higher, but you can disable this feature:
|
|
619
|
+
|
|
620
|
+
```ts twoslash [nuxt.config.ts]
|
|
621
|
+
export default defineNuxtConfig({
|
|
622
|
+
experimental: {
|
|
623
|
+
normalizePageNames: false,
|
|
624
|
+
},
|
|
625
|
+
})
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
```vue [app.vue]
|
|
629
|
+
<template>
|
|
630
|
+
<NuxtPage :keepalive="{ include: ['foo'] }" />
|
|
631
|
+
</template>
|
|
632
|
+
```
|
|
633
|
+
|
|
610
634
|
## spaLoadingTemplateLocation
|
|
611
635
|
|
|
612
636
|
When rendering a client-only page (with `ssr: false`), we optionally render a loading screen (from `~/spa-loading-template.html`).
|