Skip to content

Commit

Permalink
feat(nuxt): add apps to nuxt build-time instance (nuxt#20637)
Browse files Browse the repository at this point in the history
  • Loading branch information
huang-julien authored May 9, 2023
1 parent 5781cf1 commit 018bf12
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/nuxt/src/core/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { generateApp as _generateApp, createApp } from './app'

export async function build (nuxt: Nuxt) {
const app = createApp(nuxt)
nuxt.apps.default = app

const generateApp = debounce(() => _generateApp(nuxt, app), undefined, { leading: true })
await generateApp()

Expand Down
3 changes: 2 additions & 1 deletion packages/nuxt/src/core/nuxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export function createNuxt (options: NuxtOptions): Nuxt {
hook: hooks.hook,
ready: () => initNuxt(nuxt),
close: () => Promise.resolve(hooks.callHook('close', nuxt)),
vfs: {}
vfs: {},
apps: {}
}

return nuxt
Expand Down
2 changes: 2 additions & 0 deletions packages/schema/src/types/nuxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export interface Nuxt {
server?: any

vfs: Record<string, string>

apps: Record<string, NuxtApp>
}

export interface NuxtTemplate<Options = Record<string, any>> {
Expand Down

0 comments on commit 018bf12

Please sign in to comment.