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

Commit

Permalink
Merge branch 'main' into docs/getting-started/routing
Browse files Browse the repository at this point in the history
  • Loading branch information
Atinux committed Sep 14, 2022
2 parents 58e8aae + 9024d76 commit 1607ff4
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@actions/core": "^1.9.1",
"@nuxtjs/eslint-config-typescript": "^11.0.0",
"@types/crawler": "^1.2.2",
"@types/node": "^16.11.58",
"@types/node": "^16.11.59",
"@types/rimraf": "^3",
"@unocss/reset": "^0.45.21",
"case-police": "^0.5.10",
Expand Down
2 changes: 2 additions & 0 deletions packages/kit/src/loader/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { NuxtConfigSchema } from '@nuxt/schema'
export interface LoadNuxtConfigOptions extends LoadConfigOptions<NuxtConfig> {}

export async function loadNuxtConfig (opts: LoadNuxtConfigOptions): Promise<NuxtOptions> {
(globalThis as any).defineNuxtConfig = (c: any) => c
const result = await loadConfig<NuxtConfig>({
name: 'nuxt',
configFile: 'nuxt.config',
Expand All @@ -16,6 +17,7 @@ export async function loadNuxtConfig (opts: LoadNuxtConfigOptions): Promise<Nuxt
globalRc: true,
...opts
})
delete (globalThis as any).defineNuxtConfig
const { configFile, layers = [], cwd } = result
const nuxtConfig = result.config!

Expand Down
2 changes: 1 addition & 1 deletion packages/nuxi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"destr": "^1.1.1",
"execa": "^6.1.0",
"flat": "^5.0.2",
"giget": "^0.1.5",
"giget": "^0.1.6",
"jiti": "^1.15.0",
"listhen": "^0.2.15",
"mlly": "^0.5.14",
Expand Down
7 changes: 7 additions & 0 deletions packages/nuxt/config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function defineNuxtConfig (config) {
return config
}

module.exports = {
defineNuxtConfig
}
4 changes: 4 additions & 0 deletions packages/nuxt/config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { NuxtConfig } from '@nuxt/schema'
export { NuxtConfig } from '@nuxt/schema'

export declare function defineNuxtConfig(config: NuxtConfig): NuxtConfig
5 changes: 5 additions & 0 deletions packages/nuxt/config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function defineNuxtConfig (config) {
return config
}

export { defineNuxtConfig }
8 changes: 7 additions & 1 deletion packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
},
"exports": {
".": "./dist/index.mjs",
"./config": {
"import": "./config.mjs",
"require": "./config.cjs",
"types": "./config.d.ts"
},
"./app": "./dist/app/index.mjs",
"./package.json": "./package.json"
},
Expand All @@ -24,7 +29,8 @@
"app.d.ts",
"bin",
"types.d.ts",
"dist"
"dist",
"config.*"
],
"scripts": {
"prepack": "unbuild"
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/app/plugins/payload.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineNuxtPlugin, loadPayload, addRouteMiddleware, isPrerendered } from

export default defineNuxtPlugin((nuxtApp) => {
// Only enable behavior if initial page is prerendered
// TOOD: Support hybrid
// TOOD: Support hybrid and dev
if (!isPrerendered()) {
return
}
Expand Down
10 changes: 7 additions & 3 deletions packages/nuxt/src/core/nuxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ async function initNuxt (nuxt: Nuxt) {
})

// Add prerender payload support
addPlugin(resolve(nuxt.options.appDir, 'plugins/payload.client'))
if (!nuxt.options.dev) {
addPlugin(resolve(nuxt.options.appDir, 'plugins/payload.client'))
}

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

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

// For a convenience import together with `defineNuxtConfig`
export type { NuxtConfig }
/** @deprecated Use `import type { NuxtConfig } from 'nuxt/config'`. */
type _NuxtConfig = NuxtConfig
export type { _NuxtConfig as NuxtConfig }
14 changes: 11 additions & 3 deletions packages/nuxt/src/pages/runtime/page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { computed, defineComponent, h, inject, provide, reactive, onMounted, nextTick, Suspense, Transition } from 'vue'
import { computed, defineComponent, h, inject, provide, reactive, onMounted, nextTick, Suspense, Transition, KeepAliveProps, TransitionProps } from 'vue'
import type { DefineComponent, VNode } from 'vue'
import { RouteLocationNormalized, RouteLocationNormalizedLoaded, RouterView } from 'vue-router'
import type { RouteLocation } from 'vue-router'
Expand All @@ -18,6 +18,14 @@ export default defineComponent({
name: {
type: String
},
transition: {
type: [Boolean, Object] as any as () => boolean | TransitionProps,
default: undefined
},
keepalive: {
type: [Boolean, Object] as any as () => boolean | KeepAliveProps,
default: undefined
},
route: {
type: Object as () => RouteLocationNormalized
},
Expand All @@ -38,10 +46,10 @@ export default defineComponent({
if (!routeProps.Component) { return }

const key = generateRouteKey(props.pageKey, routeProps)
const transitionProps = routeProps.route.meta.pageTransition ?? defaultPageTransition
const transitionProps = props.transition ?? routeProps.route.meta.pageTransition ?? (defaultPageTransition as TransitionProps)

return _wrapIf(Transition, transitionProps,
wrapInKeepAlive(routeProps.route.meta.keepalive ?? defaultKeepaliveConfig, isNested && nuxtApp.isHydrating
wrapInKeepAlive(props.keepalive ?? routeProps.route.meta.keepalive ?? (defaultKeepaliveConfig as KeepAliveProps), isNested && nuxtApp.isHydrating
// Include route children in parent suspense
? h(Component, { key, routeProps, pageKey: key, hasTransition: !!transitionProps } as {})
: h(Suspense, {
Expand Down
4 changes: 4 additions & 0 deletions packages/nuxt/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
/// <reference types="nitropack" />
export * from './dist/index'

declare global {
const defineNuxtConfig: typeof import('nuxt/config')['defineNuxtConfig']
}
2 changes: 1 addition & 1 deletion packages/schema/src/config/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default defineUntypedSchema({
* Tree shakes contents of client-only components from server bundle.
* @see https://github.com/nuxt/framework/pull/5750
*/
treeshakeClientOnly: false,
treeshakeClientOnly: true,

/**
* Use vite-node for on-demand server chunk loading
Expand Down
4 changes: 2 additions & 2 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { defineNuxtConfig } from 'nuxt'
export default defineNuxtConfig({

export default defineNuxtConfig({})
})
21 changes: 11 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2595,10 +2595,10 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:^16.11.58":
version: 16.11.58
resolution: "@types/node@npm:16.11.58"
checksum: efdf14c62e6c1a8e758416aaa3ae4b81015ffd4e1f31c05680d1242817ba23f0b4b1345886fe5aeb3c05d818bcaed1a7af4d637e7cca5723a5e4ac8b759d3ace
"@types/node@npm:^16.11.59":
version: 16.11.59
resolution: "@types/node@npm:16.11.59"
checksum: b3a2986ef8f8216bb7fd1187dcf2e69aca3e6b6b5fdfd6abf4cf11c44e3cdd587fae875a28dc4ef257e2b369e2c5290642aff6a0a9d702f3385a78f561293259
languageName: node
linkType: hard

Expand Down Expand Up @@ -7776,18 +7776,19 @@ __metadata:
languageName: node
linkType: hard

"giget@npm:^0.1.5":
version: 0.1.5
resolution: "giget@npm:0.1.5"
"giget@npm:^0.1.6":
version: 0.1.6
resolution: "giget@npm:0.1.6"
dependencies:
colorette: ^2.0.19
defu: ^6.1.0
mri: ^1.2.0
node-fetch-native: ^0.1.4
pathe: ^0.3.7
tar: ^6.1.11
bin:
giget: dist/cli.mjs
checksum: 3f9e50f3bd4f9109c7cb511427449daa66c54f466a7e3169bd2475984b60b83e5e840dc35b71373ee137be22458ad1a31564fa2f99e9fc50ec760849d4d30e62
checksum: d41a8cb2eb794a1910672663d4319a20a799135149d48e15dc35d3ab18e87910df5344c140fcc1018a4672f14c8312d8068c30577b17cbde7a48fe554c64e96a
languageName: node
linkType: hard

Expand Down Expand Up @@ -10646,7 +10647,7 @@ __metadata:
execa: ^6.1.0
flat: ^5.0.2
fsevents: ~2.3.2
giget: ^0.1.5
giget: ^0.1.6
jiti: ^1.15.0
listhen: ^0.2.15
mlly: ^0.5.14
Expand All @@ -10672,7 +10673,7 @@ __metadata:
"@actions/core": ^1.9.1
"@nuxtjs/eslint-config-typescript": ^11.0.0
"@types/crawler": ^1.2.2
"@types/node": ^16.11.58
"@types/node": ^16.11.59
"@types/rimraf": ^3
"@unocss/reset": ^0.45.21
case-police: ^0.5.10
Expand Down

0 comments on commit 1607ff4

Please sign in to comment.