refactor(nuxi): extract nitro types to corresponding modules (#668)

Co-authored-by: Pooya Parsa <pyapar@gmail.com>
This commit is contained in:
Daniel Roe 2021-10-07 12:09:09 +02:00 committed by GitHub
parent accbe6445c
commit cc2279bd8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 9 deletions

View File

@ -1,3 +1,4 @@
import type {} from '@nuxt/nitro'
import type { NuxtConfig as _NuxtConfig } from '@nuxt/kit'
export interface BridgeConfig {

View File

@ -1,7 +1,7 @@
import { promises as fsp } from 'fs'
import { relative, resolve } from 'pathe'
import { cyan } from 'colorette'
import { isNuxt3, TSReference } from '@nuxt/kit'
import { TSReference } from '@nuxt/kit'
import { importModule, getModulePaths, getNearestPackage } from '../utils/cjs'
import { success } from '../utils/log'
import { defineNuxtCommand } from './index'
@ -19,15 +19,9 @@ export default defineNuxtCommand({
const { loadNuxt } = await importModule('@nuxt/kit', rootDir) as typeof import('@nuxt/kit')
const nuxt = await loadNuxt({ rootDir })
const adHocModules = isNuxt3()
? ['@nuxt/kit', '@nuxt/nitro']
: ['@nuxt/kit']
const modulePaths = getModulePaths(nuxt.options.modulesDir)
const references: TSReference[] = [
...isNuxt3() ? ['nuxt3'] : [],
...adHocModules,
...nuxt.options.buildModules,
...nuxt.options.modules,
...nuxt.options._modules

View File

@ -39,6 +39,11 @@ async function initNuxt (nuxt: Nuxt) {
// Init nitro
await initNitro(nuxt)
// Add nuxt3 types
nuxt.hook('prepare:types', (opts) => {
opts.references.push({ types: 'nuxt3' })
})
// Init user modules
await nuxt.callHook('modules:before', { nuxt } as ModuleContainer)
const modulesToInstall = [

View File

@ -1,2 +1,3 @@
import type { } from '@nuxt/nitro'
export * from './dist/index'
export * from './dist/app/types/index'

View File

@ -2,8 +2,6 @@
// Please do not manually modify this file.
/// <reference types="nuxt3" />
/// <reference types="@nuxt/kit" />
/// <reference types="@nuxt/nitro" />
/// <reference path=".nuxt/components.d.ts" />
/// <reference path=".nuxt/global-imports.d.ts" />
export {}