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

feat(nuxt)!: add NuxtPage to #components #8145

Merged
merged 5 commits into from Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/nuxt/src/pages/module.ts
@@ -1,5 +1,5 @@
import { existsSync } from 'node:fs'
import { defineNuxtModule, addTemplate, addPlugin, addVitePlugin, addWebpackPlugin, findPath } from '@nuxt/kit'
import { defineNuxtModule, addTemplate, addPlugin, addVitePlugin, addWebpackPlugin, findPath, addComponent } from '@nuxt/kit'
import { relative, resolve } from 'pathe'
import { genString, genImport, genObjectFromRawEntries } from 'knitwork'
import escapeRE from 'escape-string-regexp'
Expand Down Expand Up @@ -185,6 +185,12 @@ export default defineNuxtModule({
}
})

// Add <NuxtPage>
addComponent({
name: 'NuxtPage',
filePath: resolve(distDir, 'pages/runtime/page')
})

// Add declarations for middleware keys
nuxt.hook('prepare:types', ({ references }) => {
references.push({ path: resolve(nuxt.options.buildDir, 'types/middleware.d.ts') })
Expand Down
4 changes: 4 additions & 0 deletions packages/nuxt/src/pages/runtime/app.vue
Expand Up @@ -3,3 +3,7 @@
<NuxtPage />
</NuxtLayout>
</template>

<script setup>
import NuxtPage from './page'
</script>
huang-julien marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 0 additions & 5 deletions packages/nuxt/src/pages/runtime/router.ts
Expand Up @@ -50,11 +50,6 @@ function createCurrentLocation (
}

export default defineNuxtPlugin(async (nuxtApp) => {
nuxtApp.vueApp.component('NuxtPage', NuxtPage)
// TODO: remove before release - present for backwards compatibility & intentionally undocumented
nuxtApp.vueApp.component('NuxtNestedPage', NuxtPage)
nuxtApp.vueApp.component('NuxtChild', NuxtPage)

let routerBase = useRuntimeConfig().app.baseURL
if (routerOptions.hashMode && !routerBase.includes('#')) {
// allow the user to provide a `#` in the middle: `/base/#/app`
Expand Down