Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

Commit 1607ff4

Browse files
author
Sébastien Chopin
authored
Merge branch 'main' into docs/getting-started/routing
2 parents 58e8aae + 9024d76 commit 1607ff4

14 files changed

Lines changed: 64 additions & 23 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@actions/core": "^1.9.1",
5151
"@nuxtjs/eslint-config-typescript": "^11.0.0",
5252
"@types/crawler": "^1.2.2",
53-
"@types/node": "^16.11.58",
53+
"@types/node": "^16.11.59",
5454
"@types/rimraf": "^3",
5555
"@unocss/reset": "^0.45.21",
5656
"case-police": "^0.5.10",

packages/kit/src/loader/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { NuxtConfigSchema } from '@nuxt/schema'
77
export interface LoadNuxtConfigOptions extends LoadConfigOptions<NuxtConfig> {}
88

99
export async function loadNuxtConfig (opts: LoadNuxtConfigOptions): Promise<NuxtOptions> {
10+
(globalThis as any).defineNuxtConfig = (c: any) => c
1011
const result = await loadConfig<NuxtConfig>({
1112
name: 'nuxt',
1213
configFile: 'nuxt.config',
@@ -16,6 +17,7 @@ export async function loadNuxtConfig (opts: LoadNuxtConfigOptions): Promise<Nuxt
1617
globalRc: true,
1718
...opts
1819
})
20+
delete (globalThis as any).defineNuxtConfig
1921
const { configFile, layers = [], cwd } = result
2022
const nuxtConfig = result.config!
2123

packages/nuxi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"destr": "^1.1.1",
3535
"execa": "^6.1.0",
3636
"flat": "^5.0.2",
37-
"giget": "^0.1.5",
37+
"giget": "^0.1.6",
3838
"jiti": "^1.15.0",
3939
"listhen": "^0.2.15",
4040
"mlly": "^0.5.14",

packages/nuxt/config.cjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function defineNuxtConfig (config) {
2+
return config
3+
}
4+
5+
module.exports = {
6+
defineNuxtConfig
7+
}

packages/nuxt/config.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { NuxtConfig } from '@nuxt/schema'
2+
export { NuxtConfig } from '@nuxt/schema'
3+
4+
export declare function defineNuxtConfig(config: NuxtConfig): NuxtConfig

packages/nuxt/config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function defineNuxtConfig (config) {
2+
return config
3+
}
4+
5+
export { defineNuxtConfig }

packages/nuxt/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
},
1313
"exports": {
1414
".": "./dist/index.mjs",
15+
"./config": {
16+
"import": "./config.mjs",
17+
"require": "./config.cjs",
18+
"types": "./config.d.ts"
19+
},
1520
"./app": "./dist/app/index.mjs",
1621
"./package.json": "./package.json"
1722
},
@@ -24,7 +29,8 @@
2429
"app.d.ts",
2530
"bin",
2631
"types.d.ts",
27-
"dist"
32+
"dist",
33+
"config.*"
2834
],
2935
"scripts": {
3036
"prepack": "unbuild"

packages/nuxt/src/app/plugins/payload.client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineNuxtPlugin, loadPayload, addRouteMiddleware, isPrerendered } from
22

33
export default defineNuxtPlugin((nuxtApp) => {
44
// Only enable behavior if initial page is prerendered
5-
// TOOD: Support hybrid
5+
// TOOD: Support hybrid and dev
66
if (!isPrerendered()) {
77
return
88
}

packages/nuxt/src/core/nuxt.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ async function initNuxt (nuxt: Nuxt) {
174174
})
175175

176176
// Add prerender payload support
177-
addPlugin(resolve(nuxt.options.appDir, 'plugins/payload.client'))
177+
if (!nuxt.options.dev) {
178+
addPlugin(resolve(nuxt.options.appDir, 'plugins/payload.client'))
179+
}
178180

179181
// Track components used to render for webpack
180182
if (nuxt.options.builder === '@nuxt/webpack-builder') {
@@ -234,9 +236,11 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
234236
return nuxt
235237
}
236238

239+
/** @deprecated `defineNuxtConfig` is auto imported. Remove import or alternatively use `import { defineNuxtConfig } from 'nuxt/config'`. */
237240
export function defineNuxtConfig (config: NuxtConfig): NuxtConfig {
238241
return config
239242
}
240243

241-
// For a convenience import together with `defineNuxtConfig`
242-
export type { NuxtConfig }
244+
/** @deprecated Use `import type { NuxtConfig } from 'nuxt/config'`. */
245+
type _NuxtConfig = NuxtConfig
246+
export type { _NuxtConfig as NuxtConfig }

packages/nuxt/src/pages/runtime/page.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { computed, defineComponent, h, inject, provide, reactive, onMounted, nextTick, Suspense, Transition } from 'vue'
1+
import { computed, defineComponent, h, inject, provide, reactive, onMounted, nextTick, Suspense, Transition, KeepAliveProps, TransitionProps } from 'vue'
22
import type { DefineComponent, VNode } from 'vue'
33
import { RouteLocationNormalized, RouteLocationNormalizedLoaded, RouterView } from 'vue-router'
44
import type { RouteLocation } from 'vue-router'
@@ -18,6 +18,14 @@ export default defineComponent({
1818
name: {
1919
type: String
2020
},
21+
transition: {
22+
type: [Boolean, Object] as any as () => boolean | TransitionProps,
23+
default: undefined
24+
},
25+
keepalive: {
26+
type: [Boolean, Object] as any as () => boolean | KeepAliveProps,
27+
default: undefined
28+
},
2129
route: {
2230
type: Object as () => RouteLocationNormalized
2331
},
@@ -38,10 +46,10 @@ export default defineComponent({
3846
if (!routeProps.Component) { return }
3947

4048
const key = generateRouteKey(props.pageKey, routeProps)
41-
const transitionProps = routeProps.route.meta.pageTransition ?? defaultPageTransition
49+
const transitionProps = props.transition ?? routeProps.route.meta.pageTransition ?? (defaultPageTransition as TransitionProps)
4250

4351
return _wrapIf(Transition, transitionProps,
44-
wrapInKeepAlive(routeProps.route.meta.keepalive ?? defaultKeepaliveConfig, isNested && nuxtApp.isHydrating
52+
wrapInKeepAlive(props.keepalive ?? routeProps.route.meta.keepalive ?? (defaultKeepaliveConfig as KeepAliveProps), isNested && nuxtApp.isHydrating
4553
// Include route children in parent suspense
4654
? h(Component, { key, routeProps, pageKey: key, hasTransition: !!transitionProps } as {})
4755
: h(Suspense, {

0 commit comments

Comments
 (0)