mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-24 14:45:15 +00:00
fix(nuxt): expose nuxt/schema
subpath for augmentation (#18922)
This commit is contained in:
parent
e362061587
commit
6016aef859
@ -54,7 +54,7 @@ It is also possible to type app config manually. There are two possible things y
|
|||||||
`AppConfigInput` might be used by module authors who are declaring what valid _input_ options are when setting app config. This will not affect the type of `useAppConfig()`.
|
`AppConfigInput` might be used by module authors who are declaring what valid _input_ options are when setting app config. This will not affect the type of `useAppConfig()`.
|
||||||
|
|
||||||
```ts [index.d.ts]
|
```ts [index.d.ts]
|
||||||
declare module '@nuxt/schema' {
|
declare module 'nuxt/schema' {
|
||||||
interface AppConfigInput {
|
interface AppConfigInput {
|
||||||
/** Theme configuration */
|
/** Theme configuration */
|
||||||
theme?: {
|
theme?: {
|
||||||
@ -77,7 +77,7 @@ Be careful when typing `AppConfig` as you will overwrite the types Nuxt infers f
|
|||||||
::
|
::
|
||||||
|
|
||||||
```ts [index.d.ts]
|
```ts [index.d.ts]
|
||||||
declare module '@nuxt/schema' {
|
declare module 'nuxt/schema' {
|
||||||
interface AppConfig {
|
interface AppConfig {
|
||||||
// This will entirely replace the existing inferred `theme` property
|
// This will entirely replace the existing inferred `theme` property
|
||||||
theme: {
|
theme: {
|
||||||
|
@ -147,7 +147,7 @@ Nuxt tries to automatically generate a typescript interface from provided runtim
|
|||||||
It is also possible to type your runtime config manually:
|
It is also possible to type your runtime config manually:
|
||||||
|
|
||||||
```ts [index.d.ts]
|
```ts [index.d.ts]
|
||||||
declare module '@nuxt/schema' {
|
declare module 'nuxt/schema' {
|
||||||
interface RuntimeConfig {
|
interface RuntimeConfig {
|
||||||
apiSecret: string
|
apiSecret: string
|
||||||
public: {
|
public: {
|
||||||
|
4
packages/nuxt/config.d.ts
vendored
4
packages/nuxt/config.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
import type { NuxtConfig } from '@nuxt/schema'
|
import type { NuxtConfig } from 'nuxt/schema'
|
||||||
export { NuxtConfig } from '@nuxt/schema'
|
export { NuxtConfig } from 'nuxt/schema'
|
||||||
|
|
||||||
export declare function defineNuxtConfig(config: NuxtConfig): NuxtConfig
|
export declare function defineNuxtConfig(config: NuxtConfig): NuxtConfig
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
"import": "./config.mjs",
|
"import": "./config.mjs",
|
||||||
"require": "./config.cjs"
|
"require": "./config.cjs"
|
||||||
},
|
},
|
||||||
|
"./schema": {
|
||||||
|
"types": "./schema.d.ts",
|
||||||
|
"import": "./schema.mjs"
|
||||||
|
},
|
||||||
"./app": "./dist/app/index.mjs",
|
"./app": "./dist/app/index.mjs",
|
||||||
"./package.json": "./package.json"
|
"./package.json": "./package.json"
|
||||||
},
|
},
|
||||||
@ -30,7 +34,8 @@
|
|||||||
"bin",
|
"bin",
|
||||||
"types.d.ts",
|
"types.d.ts",
|
||||||
"dist",
|
"dist",
|
||||||
"config.*"
|
"config.*",
|
||||||
|
"schema.*"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepack": "unbuild"
|
"prepack": "unbuild"
|
||||||
|
1
packages/nuxt/schema.d.ts
vendored
Normal file
1
packages/nuxt/schema.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from '@nuxt/schema'
|
1
packages/nuxt/schema.mjs
Normal file
1
packages/nuxt/schema.mjs
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from '@nuxt/schema'
|
@ -1,10 +1,10 @@
|
|||||||
import { defineComponent, createStaticVNode, computed, ref, watch } from 'vue'
|
import { defineComponent, createStaticVNode, computed, ref, watch } from 'vue'
|
||||||
import { debounce } from 'perfect-debounce'
|
import { debounce } from 'perfect-debounce'
|
||||||
import { hash } from 'ohash'
|
import { hash } from 'ohash'
|
||||||
import type { MetaObject } from '@nuxt/schema'
|
|
||||||
import { appendHeader } from 'h3'
|
import { appendHeader } from 'h3'
|
||||||
// eslint-disable-next-line import/no-restricted-paths
|
// eslint-disable-next-line import/no-restricted-paths
|
||||||
import type { NuxtIslandResponse } from '../../core/runtime/nitro/renderer'
|
import type { NuxtIslandResponse } from '../../core/runtime/nitro/renderer'
|
||||||
|
import type { MetaObject } from 'nuxt/schema'
|
||||||
import { useNuxtApp } from '#app/nuxt'
|
import { useNuxtApp } from '#app/nuxt'
|
||||||
import { useRequestEvent } from '#app/composables/ssr'
|
import { useRequestEvent } from '#app/composables/ssr'
|
||||||
import { useHead } from '#app/composables/head'
|
import { useHead } from '#app/composables/head'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import type { AppConfig } from '@nuxt/schema'
|
|
||||||
import { reactive } from 'vue'
|
import { reactive } from 'vue'
|
||||||
import { useNuxtApp } from './nuxt'
|
import { useNuxtApp } from './nuxt'
|
||||||
|
import type { AppConfig } from 'nuxt/schema'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import __appConfig from '#build/app.config.mjs'
|
import __appConfig from '#build/app.config.mjs'
|
||||||
|
|
||||||
|
@ -3,12 +3,12 @@ import { getCurrentInstance, reactive } from 'vue'
|
|||||||
import type { App, onErrorCaptured, VNode, Ref } from 'vue'
|
import type { App, onErrorCaptured, VNode, Ref } from 'vue'
|
||||||
import type { Hookable } from 'hookable'
|
import type { Hookable } from 'hookable'
|
||||||
import { createHooks } from 'hookable'
|
import { createHooks } from 'hookable'
|
||||||
import type { RuntimeConfig, AppConfigInput } from '@nuxt/schema'
|
|
||||||
import { getContext } from 'unctx'
|
import { getContext } from 'unctx'
|
||||||
import type { SSRContext } from 'vue-bundle-renderer/runtime'
|
import type { SSRContext } from 'vue-bundle-renderer/runtime'
|
||||||
import type { H3Event } from 'h3'
|
import type { H3Event } from 'h3'
|
||||||
// eslint-disable-next-line import/no-restricted-paths
|
// eslint-disable-next-line import/no-restricted-paths
|
||||||
import type { NuxtIslandContext } from '../core/runtime/nitro/renderer'
|
import type { NuxtIslandContext } from '../core/runtime/nitro/renderer'
|
||||||
|
import type { RuntimeConfig, AppConfigInput } from 'nuxt/schema'
|
||||||
|
|
||||||
const nuxtAppCtx = getContext<NuxtApp>('nuxt-app')
|
const nuxtAppCtx = getContext<NuxtApp>('nuxt-app')
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { pathToFileURL } from 'node:url'
|
import { pathToFileURL } from 'node:url'
|
||||||
import { createUnplugin } from 'unplugin'
|
import { createUnplugin } from 'unplugin'
|
||||||
import { parseQuery, parseURL } from 'ufo'
|
import { parseQuery, parseURL } from 'ufo'
|
||||||
import type { Component, ComponentsOptions } from '@nuxt/schema'
|
|
||||||
import { genDynamicImport, genImport } from 'knitwork'
|
import { genDynamicImport, genImport } from 'knitwork'
|
||||||
import MagicString from 'magic-string'
|
import MagicString from 'magic-string'
|
||||||
import { pascalCase } from 'scule'
|
import { pascalCase } from 'scule'
|
||||||
import { resolve } from 'pathe'
|
import { resolve } from 'pathe'
|
||||||
import { distDir } from '../dirs'
|
import { distDir } from '../dirs'
|
||||||
|
import type { Component, ComponentsOptions } from 'nuxt/schema'
|
||||||
|
|
||||||
interface LoaderOptions {
|
interface LoaderOptions {
|
||||||
getComponents (): Component[]
|
getComponents (): Component[]
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { statSync } from 'node:fs'
|
import { statSync } from 'node:fs'
|
||||||
import { relative, resolve } from 'pathe'
|
import { relative, resolve } from 'pathe'
|
||||||
import { defineNuxtModule, resolveAlias, addTemplate, addPluginTemplate, updateTemplates } from '@nuxt/kit'
|
import { defineNuxtModule, resolveAlias, addTemplate, addPluginTemplate, updateTemplates } from '@nuxt/kit'
|
||||||
import type { Component, ComponentsDir, ComponentsOptions } from '@nuxt/schema'
|
|
||||||
import { distDir } from '../dirs'
|
import { distDir } from '../dirs'
|
||||||
import { componentsPluginTemplate, componentsTemplate, componentsIslandsTemplate, componentsTypeTemplate } from './templates'
|
import { componentsPluginTemplate, componentsTemplate, componentsIslandsTemplate, componentsTypeTemplate } from './templates'
|
||||||
import { scanComponents } from './scan'
|
import { scanComponents } from './scan'
|
||||||
import { loaderPlugin } from './loader'
|
import { loaderPlugin } from './loader'
|
||||||
import { TreeShakeTemplatePlugin } from './tree-shake'
|
import { TreeShakeTemplatePlugin } from './tree-shake'
|
||||||
|
import type { Component, ComponentsDir, ComponentsOptions } from 'nuxt/schema'
|
||||||
|
|
||||||
const isPureObjectOrString = (val: any) => (!Array.isArray(val) && typeof val === 'object') || typeof val === 'string'
|
const isPureObjectOrString = (val: any) => (!Array.isArray(val) && typeof val === 'object') || typeof val === 'string'
|
||||||
const isDirectory = (p: string) => { try { return statSync(p).isDirectory() } catch (_e) { return false } }
|
const isDirectory = (p: string) => { try { return statSync(p).isDirectory() } catch (_e) { return false } }
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { basename, extname, join, dirname, relative } from 'pathe'
|
import { basename, extname, join, dirname, relative } from 'pathe'
|
||||||
import { globby } from 'globby'
|
import { globby } from 'globby'
|
||||||
import { pascalCase, splitByCase } from 'scule'
|
import { pascalCase, splitByCase } from 'scule'
|
||||||
import type { Component, ComponentsDir } from '@nuxt/schema'
|
|
||||||
import { isIgnored } from '@nuxt/kit'
|
import { isIgnored } from '@nuxt/kit'
|
||||||
// eslint-disable-next-line vue/prefer-import-from-vue
|
// eslint-disable-next-line vue/prefer-import-from-vue
|
||||||
import { hyphenate } from '@vue/shared'
|
import { hyphenate } from '@vue/shared'
|
||||||
import { withTrailingSlash } from 'ufo'
|
import { withTrailingSlash } from 'ufo'
|
||||||
|
import type { Component, ComponentsDir } from 'nuxt/schema'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan the components inside different components folders
|
* Scan the components inside different components folders
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { isAbsolute, relative } from 'pathe'
|
import { isAbsolute, relative } from 'pathe'
|
||||||
import type { Component, Nuxt, NuxtPluginTemplate, NuxtTemplate } from '@nuxt/schema'
|
|
||||||
import { genDynamicImport, genExport, genImport, genObjectFromRawEntries } from 'knitwork'
|
import { genDynamicImport, genExport, genImport, genObjectFromRawEntries } from 'knitwork'
|
||||||
|
import type { Component, Nuxt, NuxtPluginTemplate, NuxtTemplate } from 'nuxt/schema'
|
||||||
|
|
||||||
export interface ComponentsTemplateContext {
|
export interface ComponentsTemplateContext {
|
||||||
nuxt: Nuxt
|
nuxt: Nuxt
|
||||||
|
@ -5,9 +5,9 @@ import { walk } from 'estree-walker'
|
|||||||
import type { CallExpression, Property, Identifier, ImportDeclaration, MemberExpression, Literal, ReturnStatement, VariableDeclaration, ObjectExpression, Node } from 'estree'
|
import type { CallExpression, Property, Identifier, ImportDeclaration, MemberExpression, Literal, ReturnStatement, VariableDeclaration, ObjectExpression, Node } from 'estree'
|
||||||
import { createUnplugin } from 'unplugin'
|
import { createUnplugin } from 'unplugin'
|
||||||
import escapeStringRegexp from 'escape-string-regexp'
|
import escapeStringRegexp from 'escape-string-regexp'
|
||||||
import type { Component } from '@nuxt/schema'
|
|
||||||
import { resolve } from 'pathe'
|
import { resolve } from 'pathe'
|
||||||
import { distDir } from '../dirs'
|
import { distDir } from '../dirs'
|
||||||
|
import type { Component } from 'nuxt/schema'
|
||||||
|
|
||||||
interface TreeShakeTemplatePluginOptions {
|
interface TreeShakeTemplatePluginOptions {
|
||||||
sourcemap?: boolean
|
sourcemap?: boolean
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { promises as fsp } from 'node:fs'
|
import { promises as fsp } from 'node:fs'
|
||||||
import { dirname, resolve, join } from 'pathe'
|
import { dirname, resolve, join } from 'pathe'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
import type { Nuxt, NuxtApp, NuxtPlugin, NuxtTemplate, ResolvedNuxtTemplate } from '@nuxt/schema'
|
|
||||||
import { findPath, resolveFiles, normalizePlugin, normalizeTemplate, compileTemplate, templateUtils, tryResolveModule, resolvePath, resolveAlias } from '@nuxt/kit'
|
import { findPath, resolveFiles, normalizePlugin, normalizeTemplate, compileTemplate, templateUtils, tryResolveModule, resolvePath, resolveAlias } from '@nuxt/kit'
|
||||||
|
|
||||||
import * as defaultTemplates from './templates'
|
import * as defaultTemplates from './templates'
|
||||||
import { getNameFromPath, hasSuffix, uniqueBy } from './utils'
|
import { getNameFromPath, hasSuffix, uniqueBy } from './utils'
|
||||||
|
import type { Nuxt, NuxtApp, NuxtPlugin, NuxtTemplate, ResolvedNuxtTemplate } from 'nuxt/schema'
|
||||||
|
|
||||||
export function createApp (nuxt: Nuxt, options: Partial<NuxtApp> = {}): NuxtApp {
|
export function createApp (nuxt: Nuxt, options: Partial<NuxtApp> = {}): NuxtApp {
|
||||||
return defu(options, {
|
return defu(options, {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import chokidar from 'chokidar'
|
import chokidar from 'chokidar'
|
||||||
import type { Nuxt } from '@nuxt/schema'
|
|
||||||
import { importModule, isIgnored } from '@nuxt/kit'
|
import { importModule, isIgnored } from '@nuxt/kit'
|
||||||
import { debounce } from 'perfect-debounce'
|
import { debounce } from 'perfect-debounce'
|
||||||
import { normalize } from 'pathe'
|
import { normalize } from 'pathe'
|
||||||
import { createApp, generateApp as _generateApp } from './app'
|
import { createApp, generateApp as _generateApp } from './app'
|
||||||
|
import type { Nuxt } from 'nuxt/schema'
|
||||||
|
|
||||||
export async function build (nuxt: Nuxt) {
|
export async function build (nuxt: Nuxt) {
|
||||||
const app = createApp(nuxt)
|
const app = createApp(nuxt)
|
||||||
|
@ -2,7 +2,6 @@ import { existsSync, promises as fsp } from 'node:fs'
|
|||||||
import { resolve, join } from 'pathe'
|
import { resolve, join } from 'pathe'
|
||||||
import { createNitro, createDevServer, build, prepare, copyPublicAssets, writeTypes, scanHandlers, prerender } from 'nitropack'
|
import { createNitro, createDevServer, build, prepare, copyPublicAssets, writeTypes, scanHandlers, prerender } from 'nitropack'
|
||||||
import type { NitroConfig, Nitro } from 'nitropack'
|
import type { NitroConfig, Nitro } from 'nitropack'
|
||||||
import type { Nuxt } from '@nuxt/schema'
|
|
||||||
import { logger, resolvePath } from '@nuxt/kit'
|
import { logger, resolvePath } from '@nuxt/kit'
|
||||||
import escapeRE from 'escape-string-regexp'
|
import escapeRE from 'escape-string-regexp'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
@ -12,6 +11,7 @@ import { createHeadCore } from 'unhead'
|
|||||||
import { renderSSRHead } from '@unhead/ssr'
|
import { renderSSRHead } from '@unhead/ssr'
|
||||||
import { distDir } from '../dirs'
|
import { distDir } from '../dirs'
|
||||||
import { ImportProtectionPlugin } from './plugins/import-protection'
|
import { ImportProtectionPlugin } from './plugins/import-protection'
|
||||||
|
import type { Nuxt } from 'nuxt/schema'
|
||||||
|
|
||||||
export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
|
export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
|
||||||
// Resolve config
|
// Resolve config
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { join, normalize, resolve } from 'pathe'
|
import { join, normalize, resolve } from 'pathe'
|
||||||
import { createHooks, createDebugger } from 'hookable'
|
import { createHooks, createDebugger } from 'hookable'
|
||||||
import type { Nuxt, NuxtOptions, NuxtHooks } from '@nuxt/schema'
|
|
||||||
import type { LoadNuxtOptions } from '@nuxt/kit'
|
import type { LoadNuxtOptions } from '@nuxt/kit'
|
||||||
import { loadNuxtConfig, nuxtCtx, installModule, addComponent, addVitePlugin, addWebpackPlugin, tryResolveModule, addPlugin } from '@nuxt/kit'
|
import { loadNuxtConfig, nuxtCtx, installModule, addComponent, addVitePlugin, addWebpackPlugin, tryResolveModule, addPlugin } from '@nuxt/kit'
|
||||||
|
|
||||||
@ -22,6 +21,7 @@ import { DevOnlyPlugin } from './plugins/dev-only'
|
|||||||
import { addModuleTranspiles } from './modules'
|
import { addModuleTranspiles } from './modules'
|
||||||
import { initNitro } from './nitro'
|
import { initNitro } from './nitro'
|
||||||
import schemaModule from './schema'
|
import schemaModule from './schema'
|
||||||
|
import type { Nuxt, NuxtOptions, NuxtHooks } from 'nuxt/schema'
|
||||||
|
|
||||||
export function createNuxt (options: NuxtOptions): Nuxt {
|
export function createNuxt (options: NuxtOptions): Nuxt {
|
||||||
const hooks = createHooks<NuxtHooks>()
|
const hooks = createHooks<NuxtHooks>()
|
||||||
|
@ -2,8 +2,8 @@ import { createRequire } from 'node:module'
|
|||||||
import { createUnplugin } from 'unplugin'
|
import { createUnplugin } from 'unplugin'
|
||||||
import { logger } from '@nuxt/kit'
|
import { logger } from '@nuxt/kit'
|
||||||
import { isAbsolute, join, relative } from 'pathe'
|
import { isAbsolute, join, relative } from 'pathe'
|
||||||
import type { Nuxt } from '@nuxt/schema'
|
|
||||||
import escapeRE from 'escape-string-regexp'
|
import escapeRE from 'escape-string-regexp'
|
||||||
|
import type { Nuxt } from 'nuxt/schema'
|
||||||
|
|
||||||
const _require = createRequire(import.meta.url)
|
const _require = createRequire(import.meta.url)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import type { Nuxt, NuxtApp } from '@nuxt/schema'
|
|
||||||
import { normalize } from 'pathe'
|
import { normalize } from 'pathe'
|
||||||
import { createTransformer } from 'unctx/transform'
|
import { createTransformer } from 'unctx/transform'
|
||||||
import { createUnplugin } from 'unplugin'
|
import { createUnplugin } from 'unplugin'
|
||||||
|
import type { Nuxt, NuxtApp } from 'nuxt/schema'
|
||||||
|
|
||||||
const TRANSFORM_MARKER = '/* _processed_nuxt_unctx_transform */\n'
|
const TRANSFORM_MARKER = '/* _processed_nuxt_unctx_transform */\n'
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ export default defineNuxtModule({
|
|||||||
`
|
`
|
||||||
export type CustomAppConfig = Exclude<NuxtCustomSchema['appConfig'], undefined>
|
export type CustomAppConfig = Exclude<NuxtCustomSchema['appConfig'], undefined>
|
||||||
|
|
||||||
declare module '@nuxt/schema' {
|
declare module 'nuxt/schema' {
|
||||||
interface NuxtConfig extends NuxtCustomSchema {}
|
interface NuxtConfig extends NuxtCustomSchema {}
|
||||||
interface NuxtOptions extends NuxtCustomSchema {}
|
interface NuxtOptions extends NuxtCustomSchema {}
|
||||||
interface AppConfigInput extends CustomAppConfig {}
|
interface AppConfigInput extends CustomAppConfig {}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import type { Nuxt, NuxtApp, NuxtTemplate } from '@nuxt/schema'
|
|
||||||
import { genArrayFromRaw, genDynamicImport, genExport, genImport, genObjectFromRawEntries, genString, genSafeVariableName } from 'knitwork'
|
import { genArrayFromRaw, genDynamicImport, genExport, genImport, genObjectFromRawEntries, genString, genSafeVariableName } from 'knitwork'
|
||||||
import { isAbsolute, join, relative, resolve } from 'pathe'
|
import { isAbsolute, join, relative, resolve } from 'pathe'
|
||||||
import { resolveSchema, generateTypes } from 'untyped'
|
import { resolveSchema, generateTypes } from 'untyped'
|
||||||
@ -7,6 +6,7 @@ import { hash } from 'ohash'
|
|||||||
import { camelCase } from 'scule'
|
import { camelCase } from 'scule'
|
||||||
import { resolvePath } from 'mlly'
|
import { resolvePath } from 'mlly'
|
||||||
import { filename } from 'pathe/utils'
|
import { filename } from 'pathe/utils'
|
||||||
|
import type { Nuxt, NuxtApp, NuxtTemplate } from 'nuxt/schema'
|
||||||
|
|
||||||
export interface TemplateContext {
|
export interface TemplateContext {
|
||||||
nuxt: Nuxt
|
nuxt: Nuxt
|
||||||
@ -126,8 +126,8 @@ export const schemaTemplate: NuxtTemplate<TemplateContext> = {
|
|||||||
const modules = moduleInfo.map(meta => [genString(meta.configKey), getImportName(meta.importName)])
|
const modules = moduleInfo.map(meta => [genString(meta.configKey), getImportName(meta.importName)])
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"import { NuxtModule } from '@nuxt/schema'",
|
"import { NuxtModule } from 'nuxt/schema'",
|
||||||
"declare module '@nuxt/schema' {",
|
"declare module 'nuxt/schema' {",
|
||||||
' interface NuxtConfig {',
|
' interface NuxtConfig {',
|
||||||
...modules.map(([configKey, importName]) =>
|
...modules.map(([configKey, importName]) =>
|
||||||
` [${configKey}]?: typeof ${genDynamicImport(importName, { wrapper: false })}.default extends NuxtModule<infer O> ? Partial<O> : Record<string, any>`
|
` [${configKey}]?: typeof ${genDynamicImport(importName, { wrapper: false })}.default extends NuxtModule<infer O> ? Partial<O> : Record<string, any>`
|
||||||
@ -200,7 +200,7 @@ ${app.configs.map((id: string, index: number) => `import ${`cfg${index}`} from $
|
|||||||
declare const inlineConfig = ${JSON.stringify(nuxt.options.appConfig, null, 2)}
|
declare const inlineConfig = ${JSON.stringify(nuxt.options.appConfig, null, 2)}
|
||||||
type ResolvedAppConfig = Defu<typeof inlineConfig, [${app.configs.map((_id: string, index: number) => `typeof cfg${index}`).join(', ')}]>
|
type ResolvedAppConfig = Defu<typeof inlineConfig, [${app.configs.map((_id: string, index: number) => `typeof cfg${index}`).join(', ')}]>
|
||||||
|
|
||||||
declare module '@nuxt/schema' {
|
declare module 'nuxt/schema' {
|
||||||
interface AppConfig extends ResolvedAppConfig { }
|
interface AppConfig extends ResolvedAppConfig { }
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import type { HeadEntryOptions, UseHeadInput, ActiveHeadEntry } from '@vueuse/head'
|
import type { HeadEntryOptions, UseHeadInput, ActiveHeadEntry } from '@vueuse/head'
|
||||||
import type { HeadAugmentations } from '@nuxt/schema'
|
|
||||||
import { useSeoMeta as _useSeoMeta } from '@vueuse/head'
|
import { useSeoMeta as _useSeoMeta } from '@vueuse/head'
|
||||||
|
import type { HeadAugmentations } from 'nuxt/schema'
|
||||||
import { useNuxtApp } from '#app/nuxt'
|
import { useNuxtApp } from '#app/nuxt'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { UseHeadInput } from '@vueuse/head'
|
import type { UseHeadInput } from '@vueuse/head'
|
||||||
import type { HeadAugmentations } from '@nuxt/schema'
|
import type { HeadAugmentations } from 'nuxt/schema'
|
||||||
|
|
||||||
export * from './composables'
|
export * from './composables'
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@ import { addVitePlugin, addWebpackPlugin, defineNuxtModule, addTemplate, resolve
|
|||||||
import { isAbsolute, join, relative, resolve, normalize } from 'pathe'
|
import { isAbsolute, join, relative, resolve, normalize } from 'pathe'
|
||||||
import type { Import, Unimport } from 'unimport'
|
import type { Import, Unimport } from 'unimport'
|
||||||
import { createUnimport, scanDirExports } from 'unimport'
|
import { createUnimport, scanDirExports } from 'unimport'
|
||||||
import type { ImportsOptions, ImportPresetWithDeprecation } from '@nuxt/schema'
|
|
||||||
import { TransformPlugin } from './transform'
|
import { TransformPlugin } from './transform'
|
||||||
import { defaultPresets } from './presets'
|
import { defaultPresets } from './presets'
|
||||||
|
import type { ImportsOptions, ImportPresetWithDeprecation } from 'nuxt/schema'
|
||||||
|
|
||||||
export default defineNuxtModule<Partial<ImportsOptions>>({
|
export default defineNuxtModule<Partial<ImportsOptions>>({
|
||||||
meta: {
|
meta: {
|
||||||
|
@ -2,8 +2,8 @@ import { pathToFileURL } from 'node:url'
|
|||||||
import { createUnplugin } from 'unplugin'
|
import { createUnplugin } from 'unplugin'
|
||||||
import { parseQuery, parseURL } from 'ufo'
|
import { parseQuery, parseURL } from 'ufo'
|
||||||
import type { Unimport } from 'unimport'
|
import type { Unimport } from 'unimport'
|
||||||
import type { ImportsOptions } from '@nuxt/schema'
|
|
||||||
import { normalize } from 'pathe'
|
import { normalize } from 'pathe'
|
||||||
|
import type { ImportsOptions } from 'nuxt/schema'
|
||||||
|
|
||||||
export const TransformPlugin = createUnplugin(({ ctx, options, sourcemap }: { ctx: Unimport, options: Partial<ImportsOptions>, sourcemap?: boolean }) => {
|
export const TransformPlugin = createUnplugin(({ ctx, options, sourcemap }: { ctx: Unimport, options: Partial<ImportsOptions>, sourcemap?: boolean }) => {
|
||||||
return {
|
return {
|
||||||
|
@ -3,12 +3,12 @@ import { defineNuxtModule, addTemplate, addPlugin, addVitePlugin, addWebpackPlug
|
|||||||
import { relative, resolve } from 'pathe'
|
import { relative, resolve } from 'pathe'
|
||||||
import { genString, genImport, genObjectFromRawEntries } from 'knitwork'
|
import { genString, genImport, genObjectFromRawEntries } from 'knitwork'
|
||||||
import escapeRE from 'escape-string-regexp'
|
import escapeRE from 'escape-string-regexp'
|
||||||
import type { NuxtApp, NuxtPage } from '@nuxt/schema'
|
|
||||||
import { joinURL } from 'ufo'
|
import { joinURL } from 'ufo'
|
||||||
import { distDir } from '../dirs'
|
import { distDir } from '../dirs'
|
||||||
import { resolvePagesRoutes, normalizeRoutes } from './utils'
|
import { resolvePagesRoutes, normalizeRoutes } from './utils'
|
||||||
import type { PageMetaPluginOptions } from './page-meta'
|
import type { PageMetaPluginOptions } from './page-meta'
|
||||||
import { PageMetaPlugin } from './page-meta'
|
import { PageMetaPlugin } from './page-meta'
|
||||||
|
import type { NuxtApp, NuxtPage } from 'nuxt/schema'
|
||||||
|
|
||||||
export default defineNuxtModule({
|
export default defineNuxtModule({
|
||||||
meta: {
|
meta: {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import type { RouterConfig } from '@nuxt/schema'
|
|
||||||
import type { RouterScrollBehavior, RouteLocationNormalized } from 'vue-router'
|
import type { RouterScrollBehavior, RouteLocationNormalized } from 'vue-router'
|
||||||
import { nextTick } from 'vue'
|
import { nextTick } from 'vue'
|
||||||
|
import type { RouterConfig } from 'nuxt/schema'
|
||||||
import { useNuxtApp } from '#app/nuxt'
|
import { useNuxtApp } from '#app/nuxt'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { appPageTransition as defaultPageTransition } from '#build/nuxt.config.mjs'
|
import { appPageTransition as defaultPageTransition } from '#build/nuxt.config.mjs'
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { extname, normalize, relative, resolve } from 'pathe'
|
import { extname, normalize, relative, resolve } from 'pathe'
|
||||||
import { encodePath } from 'ufo'
|
import { encodePath } from 'ufo'
|
||||||
import type { NuxtPage } from '@nuxt/schema'
|
|
||||||
import { resolveFiles, useNuxt } from '@nuxt/kit'
|
import { resolveFiles, useNuxt } from '@nuxt/kit'
|
||||||
import { genImport, genDynamicImport, genArrayFromRaw, genSafeVariableName } from 'knitwork'
|
import { genImport, genDynamicImport, genArrayFromRaw, genSafeVariableName } from 'knitwork'
|
||||||
import escapeRE from 'escape-string-regexp'
|
import escapeRE from 'escape-string-regexp'
|
||||||
import { filename } from 'pathe/utils'
|
import { filename } from 'pathe/utils'
|
||||||
import { hash } from 'ohash'
|
import { hash } from 'ohash'
|
||||||
import { uniqueBy } from '../core/utils'
|
import { uniqueBy } from '../core/utils'
|
||||||
|
import type { NuxtPage } from 'nuxt/schema'
|
||||||
|
|
||||||
enum SegmentParserState {
|
enum SegmentParserState {
|
||||||
initial,
|
initial,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { resolve } from 'node:path'
|
import { resolve } from 'node:path'
|
||||||
import type { ComponentsDir } from '@nuxt/schema'
|
|
||||||
import { expect, it, vi } from 'vitest'
|
import { expect, it, vi } from 'vitest'
|
||||||
import { scanComponents } from '../src/components/scan'
|
import { scanComponents } from '../src/components/scan'
|
||||||
|
import type { ComponentsDir } from 'nuxt/schema'
|
||||||
|
|
||||||
const fixtureDir = resolve(__dirname, 'fixture')
|
const fixtureDir = resolve(__dirname, 'fixture')
|
||||||
const rFixture = (...p: string[]) => resolve(fixtureDir, ...p)
|
const rFixture = (...p: string[]) => resolve(fixtureDir, ...p)
|
||||||
|
2
packages/nuxt/types.d.ts
vendored
2
packages/nuxt/types.d.ts
vendored
@ -1,7 +1,7 @@
|
|||||||
/// <reference types="nitropack" />
|
/// <reference types="nitropack" />
|
||||||
export * from './dist/index'
|
export * from './dist/index'
|
||||||
|
|
||||||
import type { SchemaDefinition } from '@nuxt/schema'
|
import type { SchemaDefinition } from 'nuxt/schema'
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
const defineNuxtConfig: typeof import('nuxt/config')['defineNuxtConfig']
|
const defineNuxtConfig: typeof import('nuxt/config')['defineNuxtConfig']
|
||||||
|
Loading…
Reference in New Issue
Block a user