mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 09:02:03 +00:00
refactor!: remove deprecated api (#9029)
This commit is contained in:
parent
ab7ec7822c
commit
5ac9d85a49
@ -72,7 +72,7 @@ useHead({
|
|||||||
|
|
||||||
## Components
|
## Components
|
||||||
|
|
||||||
Nuxt provides `<Title>`, `<Base>`, `<Script>`, `<NoScript>`, `<Style>`, `<Meta>`, `<Link>`, `<Body>`, `<Html>` and `<Head>` components so that you can interact directly with your metadata within your component's template.
|
Nuxt provides `<Title>`, `<Base>`, `<NoScript>`, `<Style>`, `<Meta>`, `<Link>`, `<Body>`, `<Html>` and `<Head>` components so that you can interact directly with your metadata within your component's template.
|
||||||
|
|
||||||
Because these component names match native HTML elements, it is very important that they are capitalized in the template.
|
Because these component names match native HTML elements, it is very important that they are capitalized in the template.
|
||||||
|
|
||||||
@ -186,30 +186,18 @@ You can use the `body: true` option on the `link` and `script` meta tags to appe
|
|||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
::code-group
|
```vue
|
||||||
|
<script setup lang="ts">
|
||||||
```vue [useHead]
|
useHead({
|
||||||
<script setup lang="ts">
|
|
||||||
useHead({
|
|
||||||
script: [
|
script: [
|
||||||
{
|
{
|
||||||
src: 'https://third-party-script.com',
|
src: 'https://third-party-script.com',
|
||||||
body: true
|
body: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
```vue [Components]
|
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<Script src="https://third-party-script.com" body="true" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
```
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ description: Nuxt Kit provides composable utilities to help interacting with Nux
|
|||||||
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/imports.ts)
|
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/imports.ts)
|
||||||
|
|
||||||
- `addImports(imports)`
|
- `addImports(imports)`
|
||||||
- `addImportsDir(autoImportDirs)`
|
- `addImportsDir(importDirs)`
|
||||||
- `addImportsSources(autoImportSources)`
|
- `addImportsSources(importSources)`
|
||||||
|
|
||||||
### Components
|
### Components
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
<Title>Luck number: {{ dynamic }}</Title>
|
<Title>Luck number: {{ dynamic }}</Title>
|
||||||
<Meta name="description" :content="`My page's ${dynamic} description`" />
|
<Meta name="description" :content="`My page's ${dynamic} description`" />
|
||||||
<Link rel="preload" href="/test.txt" as="script" />
|
<Link rel="preload" href="/test.txt" as="script" />
|
||||||
<Script>console.log("hello script");</Script>
|
|
||||||
</Head>
|
</Head>
|
||||||
</Html>
|
</Html>
|
||||||
|
|
||||||
|
@ -30,13 +30,6 @@ export interface ExtendConfigOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
|
export interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
|
||||||
/**
|
|
||||||
* Install plugin on modern build
|
|
||||||
*
|
|
||||||
* @default true
|
|
||||||
* @deprecated Nuxt 2 only
|
|
||||||
*/
|
|
||||||
modern?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExtendViteConfigOptions extends ExtendConfigOptions {}
|
export interface ExtendViteConfigOptions extends ExtendConfigOptions {}
|
||||||
@ -73,13 +66,6 @@ export function extendWebpackConfig (
|
|||||||
fn(config)
|
fn(config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Nuxt 2 backwards compatibility
|
|
||||||
if (options.modern !== false) {
|
|
||||||
const config = configs.find(i => i.name === 'modern')
|
|
||||||
if (config) {
|
|
||||||
fn(config)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { pascalCase, kebabCase } from 'scule'
|
import { pascalCase, kebabCase } from 'scule'
|
||||||
import type { ComponentsDir, Component } from '@nuxt/schema'
|
import type { ComponentsDir, Component } from '@nuxt/schema'
|
||||||
import { genDynamicImport } from 'knitwork'
|
|
||||||
import { useNuxt } from './context'
|
import { useNuxt } from './context'
|
||||||
import { assertNuxtCompatibility } from './compatibility'
|
import { assertNuxtCompatibility } from './compatibility'
|
||||||
|
|
||||||
@ -40,14 +39,7 @@ export async function addComponent (opts: AddComponentOptions) {
|
|||||||
prefetch: false,
|
prefetch: false,
|
||||||
preload: false,
|
preload: false,
|
||||||
mode: 'all',
|
mode: 'all',
|
||||||
|
|
||||||
// Nuxt 2 support
|
|
||||||
shortPath: opts.filePath,
|
shortPath: opts.filePath,
|
||||||
async: false,
|
|
||||||
level: 0,
|
|
||||||
asyncImport: `${genDynamicImport(opts.filePath)}.then(r => r['${opts.export || 'default'}'])`,
|
|
||||||
import: `require(${JSON.stringify(opts.filePath)})['${opts.export || 'default'}']`,
|
|
||||||
|
|
||||||
...opts
|
...opts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,40 +6,26 @@ import { assertNuxtCompatibility } from './compatibility'
|
|||||||
export function addImports (imports: Import | Import[]) {
|
export function addImports (imports: Import | Import[]) {
|
||||||
assertNuxtCompatibility({ bridge: true })
|
assertNuxtCompatibility({ bridge: true })
|
||||||
|
|
||||||
// TODO: Use imports:* when widely adopted
|
useNuxt().hook('imports:extend', (_imports) => {
|
||||||
useNuxt().hook('autoImports:extend', (_imports) => {
|
|
||||||
_imports.push(...(Array.isArray(imports) ? imports : [imports]))
|
_imports.push(...(Array.isArray(imports) ? imports : [imports]))
|
||||||
}, { allowDeprecated: true })
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use `addImports` instead with nuxt>=3.0.0-rc.9
|
|
||||||
*/
|
|
||||||
export const addAutoImport = addImports
|
|
||||||
|
|
||||||
export function addImportsDir (dirs: string | string[]) {
|
export function addImportsDir (dirs: string | string[]) {
|
||||||
assertNuxtCompatibility({ bridge: true })
|
assertNuxtCompatibility({ bridge: true })
|
||||||
|
|
||||||
// TODO: Use imports:* when widely adopted
|
useNuxt().hook('imports:dirs', (_dirs: string[]) => {
|
||||||
useNuxt().hook('autoImports:dirs', (_dirs: string[]) => {
|
|
||||||
for (const dir of (Array.isArray(dirs) ? dirs : [dirs])) {
|
for (const dir of (Array.isArray(dirs) ? dirs : [dirs])) {
|
||||||
_dirs.push(dir)
|
_dirs.push(dir)
|
||||||
}
|
}
|
||||||
}, { allowDeprecated: true })
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use `addImportsDir` instead with nuxt>=3.0.0-rc.9
|
|
||||||
*/
|
|
||||||
export const addAutoImportDir = addImportsDir
|
|
||||||
|
|
||||||
export function addImportsSources (presets: ImportPresetWithDeprecation | ImportPresetWithDeprecation[]) {
|
export function addImportsSources (presets: ImportPresetWithDeprecation | ImportPresetWithDeprecation[]) {
|
||||||
assertNuxtCompatibility({ bridge: true })
|
assertNuxtCompatibility({ bridge: true })
|
||||||
|
|
||||||
// TODO: Use imports:* when widely adopted
|
useNuxt().hook('imports:sources', (_presets: ImportPresetWithDeprecation[]) => {
|
||||||
useNuxt().hook('autoImports:sources', (_presets: ImportPresetWithDeprecation[]) => {
|
|
||||||
for (const preset of (Array.isArray(presets) ? presets : [presets])) {
|
for (const preset of (Array.isArray(presets) ? presets : [presets])) {
|
||||||
_presets.push(preset)
|
_presets.push(preset)
|
||||||
}
|
}
|
||||||
}, { allowDeprecated: true })
|
})
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,12 @@ import jiti from 'jiti'
|
|||||||
// TODO: use create-require for jest environment
|
// TODO: use create-require for jest environment
|
||||||
const _require = jiti(process.cwd(), { interopDefault: true, esmResolve: true })
|
const _require = jiti(process.cwd(), { interopDefault: true, esmResolve: true })
|
||||||
|
|
||||||
|
/** @deprecated Do not use CJS utils */
|
||||||
export interface ResolveModuleOptions {
|
export interface ResolveModuleOptions {
|
||||||
paths?: string | string[]
|
paths?: string | string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated Do not use CJS utils */
|
||||||
export interface RequireModuleOptions extends ResolveModuleOptions {
|
export interface RequireModuleOptions extends ResolveModuleOptions {
|
||||||
// TODO: use create-require for jest environment
|
// TODO: use create-require for jest environment
|
||||||
// native?: boolean
|
// native?: boolean
|
||||||
@ -20,11 +22,13 @@ export interface RequireModuleOptions extends ResolveModuleOptions {
|
|||||||
interopDefault?: boolean
|
interopDefault?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated Do not use CJS utils */
|
||||||
export function isNodeModules (id: string) {
|
export function isNodeModules (id: string) {
|
||||||
// TODO: Follow symlinks
|
// TODO: Follow symlinks
|
||||||
return /[/\\]node_modules[/\\]/.test(id)
|
return /[/\\]node_modules[/\\]/.test(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated Do not use CJS utils */
|
||||||
export function clearRequireCache (id: string) {
|
export function clearRequireCache (id: string) {
|
||||||
if (isNodeModules(id)) {
|
if (isNodeModules(id)) {
|
||||||
return
|
return
|
||||||
@ -48,6 +52,7 @@ export function clearRequireCache (id: string) {
|
|||||||
delete _require.cache[id]
|
delete _require.cache[id]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated Do not use CJS utils */
|
||||||
export function scanRequireTree (id: string, files = new Set<string>()) {
|
export function scanRequireTree (id: string, files = new Set<string>()) {
|
||||||
if (isNodeModules(id) || files.has(id)) {
|
if (isNodeModules(id) || files.has(id)) {
|
||||||
return files
|
return files
|
||||||
@ -69,7 +74,7 @@ export function scanRequireTree (id: string, files = new Set<string>()) {
|
|||||||
return files
|
return files
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Access the require cache by module id. */
|
/** @deprecated Do not use CJS utils */
|
||||||
export function getRequireCacheItem (id: string) {
|
export function getRequireCacheItem (id: string) {
|
||||||
try {
|
try {
|
||||||
return _require.cache[id]
|
return _require.cache[id]
|
||||||
@ -82,7 +87,7 @@ export function requireModulePkg (id: string, opts: RequireModuleOptions = {}) {
|
|||||||
return requireModule(join(id, 'package.json'), opts)
|
return requireModule(join(id, 'package.json'), opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resolve the path of a module. */
|
/** @deprecated Do not use CJS utils */
|
||||||
export function resolveModule (id: string, opts: ResolveModuleOptions = {}) {
|
export function resolveModule (id: string, opts: ResolveModuleOptions = {}) {
|
||||||
return normalize(_require.resolve(id, {
|
return normalize(_require.resolve(id, {
|
||||||
paths: ([] as string[]).concat(
|
paths: ([] as string[]).concat(
|
||||||
@ -96,7 +101,7 @@ export function resolveModule (id: string, opts: ResolveModuleOptions = {}) {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Try to resolve the path of a module, but don't emit an error if it can't be found. */
|
/** @deprecated Do not use CJS utils */
|
||||||
export function tryResolveModule (path: string, opts: ResolveModuleOptions = {}): string | null {
|
export function tryResolveModule (path: string, opts: ResolveModuleOptions = {}): string | null {
|
||||||
try {
|
try {
|
||||||
return resolveModule(path, opts)
|
return resolveModule(path, opts)
|
||||||
@ -108,7 +113,7 @@ export function tryResolveModule (path: string, opts: ResolveModuleOptions = {})
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Require a module and return it. */
|
/** @deprecated Do not use CJS utils */
|
||||||
export function requireModule (id: string, opts: RequireModuleOptions = {}) {
|
export function requireModule (id: string, opts: RequireModuleOptions = {}) {
|
||||||
// Resolve id
|
// Resolve id
|
||||||
const resolvedPath = resolveModule(id, opts)
|
const resolvedPath = resolveModule(id, opts)
|
||||||
@ -124,6 +129,7 @@ export function requireModule (id: string, opts: RequireModuleOptions = {}) {
|
|||||||
return requiredModule
|
return requiredModule
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated Do not use CJS utils */
|
||||||
export function importModule (id: string, opts: RequireModuleOptions = {}) {
|
export function importModule (id: string, opts: RequireModuleOptions = {}) {
|
||||||
const resolvedPath = resolveModule(id, opts)
|
const resolvedPath = resolveModule(id, opts)
|
||||||
if (opts.interopDefault !== false) {
|
if (opts.interopDefault !== false) {
|
||||||
@ -132,13 +138,14 @@ export function importModule (id: string, opts: RequireModuleOptions = {}) {
|
|||||||
return import(pathToFileURL(resolvedPath).href)
|
return import(pathToFileURL(resolvedPath).href)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated Do not use CJS utils */
|
||||||
export function tryImportModule (id: string, opts: RequireModuleOptions = {}) {
|
export function tryImportModule (id: string, opts: RequireModuleOptions = {}) {
|
||||||
try {
|
try {
|
||||||
return importModule(id, opts).catch(() => undefined)
|
return importModule(id, opts).catch(() => undefined)
|
||||||
} catch { }
|
} catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Try to require a module, but don't emit an error if the module can't be required. */
|
/** @deprecated Do not use CJS utils */
|
||||||
export function tryRequireModule (id: string, opts: RequireModuleOptions = {}) {
|
export function tryRequireModule (id: string, opts: RequireModuleOptions = {}) {
|
||||||
try {
|
try {
|
||||||
return requireModule(id, opts)
|
return requireModule(id, opts)
|
||||||
|
@ -4,6 +4,7 @@ import { genSafeVariableName, genDynamicImport, genImport } from 'knitwork'
|
|||||||
|
|
||||||
import type { NuxtTemplate } from '@nuxt/schema'
|
import type { NuxtTemplate } from '@nuxt/schema'
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export async function compileTemplate (template: NuxtTemplate, ctx: any) {
|
export async function compileTemplate (template: NuxtTemplate, ctx: any) {
|
||||||
const data = { ...ctx, options: template.options }
|
const data = { ...ctx, options: template.options }
|
||||||
if (template.src) {
|
if (template.src) {
|
||||||
|
@ -13,20 +13,10 @@ import { templateUtils, compileTemplate } from '../internal/template'
|
|||||||
* any hooks that are provided, and calling an optional setup function for full control.
|
* any hooks that are provided, and calling an optional setup function for full control.
|
||||||
*/
|
*/
|
||||||
export function defineNuxtModule<OptionsT extends ModuleOptions> (definition: ModuleDefinition<OptionsT>): NuxtModule<OptionsT> {
|
export function defineNuxtModule<OptionsT extends ModuleOptions> (definition: ModuleDefinition<OptionsT>): NuxtModule<OptionsT> {
|
||||||
// Legacy format. TODO: Remove in RC
|
|
||||||
if (typeof definition === 'function') {
|
|
||||||
// @ts-ignore
|
|
||||||
definition = definition(useNuxt())
|
|
||||||
logger.warn('Module definition as function is deprecated and will be removed in the future versions', definition)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normalize definition and meta
|
// Normalize definition and meta
|
||||||
if (!definition.meta) { definition.meta = {} }
|
if (!definition.meta) { definition.meta = {} }
|
||||||
if (!definition.meta.configKey) {
|
if (definition.meta.configKey === undefined) {
|
||||||
// @ts-ignore TODO: Remove non-meta fallbacks in RC
|
definition.meta.configKey = definition.meta.name
|
||||||
definition.meta.name = definition.meta.name || definition.name
|
|
||||||
// @ts-ignore
|
|
||||||
definition.meta.configKey = definition.configKey || definition.meta.name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolves module options from inline options, [configKey] in nuxt.config, defaults and schema
|
// Resolves module options from inline options, [configKey] in nuxt.config, defaults and schema
|
||||||
|
@ -27,14 +27,6 @@ export async function installModule (moduleToInstall: string | NuxtModule, _inli
|
|||||||
async function normalizeModule (nuxtModule: string | NuxtModule, inlineOptions?: any) {
|
async function normalizeModule (nuxtModule: string | NuxtModule, inlineOptions?: any) {
|
||||||
const nuxt = useNuxt()
|
const nuxt = useNuxt()
|
||||||
|
|
||||||
// Detect if `installModule` used with older signuture (nuxt, nuxtModule)
|
|
||||||
// TODO: Remove in RC
|
|
||||||
// @ts-ignore
|
|
||||||
if (nuxtModule?._version || nuxtModule?.version || nuxtModule?.constructor?.version || '') {
|
|
||||||
[nuxtModule, inlineOptions] = [inlineOptions, {}]
|
|
||||||
console.warn(new Error('`installModule` is being called with old signature!'))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Import if input is string
|
// Import if input is string
|
||||||
if (typeof nuxtModule === 'string') {
|
if (typeof nuxtModule === 'string') {
|
||||||
const _src = resolveModule(resolveAlias(nuxtModule), { paths: nuxt.options.modulesDir })
|
const _src = resolveModule(resolveAlias(nuxtModule), { paths: nuxt.options.modulesDir })
|
||||||
|
@ -45,7 +45,7 @@ export function normalizeTemplate (template: NuxtTemplate<any> | string): Resolv
|
|||||||
}
|
}
|
||||||
if (!template.filename) {
|
if (!template.filename) {
|
||||||
const srcPath = parse(template.src)
|
const srcPath = parse(template.src)
|
||||||
template.filename = template.fileName ||
|
template.filename = (template as any).fileName ||
|
||||||
`${basename(srcPath.dir)}.${srcPath.name}.${hash(template.src)}${srcPath.ext}`
|
`${basename(srcPath.dir)}.${srcPath.name}.${hash(template.src)}${srcPath.ext}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ export default defineNuxtCommand({
|
|||||||
Builder: builder,
|
Builder: builder,
|
||||||
UserConfig: Object.keys(nuxtConfig).map(key => '`' + key + '`').join(', '),
|
UserConfig: Object.keys(nuxtConfig).map(key => '`' + key + '`').join(', '),
|
||||||
RuntimeModules: listModules(nuxtConfig.modules),
|
RuntimeModules: listModules(nuxtConfig.modules),
|
||||||
BuildModules: listModules(nuxtConfig.buildModules)
|
BuildModules: listModules(nuxtConfig.buildModules || [])
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('RootDir:', rootDir)
|
console.log('RootDir:', rootDir)
|
||||||
|
@ -63,7 +63,6 @@ export const writeTypes = async (nuxt: Nuxt) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const references: TSReference[] = [
|
const references: TSReference[] = [
|
||||||
...nuxt.options.buildModules,
|
|
||||||
...nuxt.options.modules,
|
...nuxt.options.modules,
|
||||||
...nuxt.options._modules
|
...nuxt.options._modules
|
||||||
]
|
]
|
||||||
|
@ -96,11 +96,7 @@ export function useAsyncData<
|
|||||||
options.server = options.server ?? true
|
options.server = options.server ?? true
|
||||||
options.default = options.default ?? getDefault
|
options.default = options.default ?? getDefault
|
||||||
|
|
||||||
// TODO: remove support for `defer` in Nuxt 3 RC
|
options.lazy = options.lazy ?? false
|
||||||
if ((options as any).defer) {
|
|
||||||
console.warn('[useAsyncData] `defer` has been renamed to `lazy`. Support for `defer` will be removed in RC.')
|
|
||||||
}
|
|
||||||
options.lazy = options.lazy ?? (options as any).defer ?? false
|
|
||||||
options.immediate = options.immediate ?? true
|
options.immediate = options.immediate ?? true
|
||||||
|
|
||||||
// Setup nuxt instance payload
|
// Setup nuxt instance payload
|
||||||
|
@ -21,9 +21,6 @@ export const showError = (_err: string | Error | Partial<NuxtError>) => {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @deprecated Use `throw createError()` or `showError` */
|
|
||||||
export const throwError = showError
|
|
||||||
|
|
||||||
export const clearError = async (options: { redirect?: string } = {}) => {
|
export const clearError = async (options: { redirect?: string } = {}) => {
|
||||||
const nuxtApp = useNuxtApp()
|
const nuxtApp = useNuxtApp()
|
||||||
const error = useError()
|
const error = useError()
|
||||||
|
@ -3,14 +3,14 @@ export { useAsyncData, useLazyAsyncData, refreshNuxtData, clearNuxtData } from '
|
|||||||
export type { AsyncDataOptions, AsyncData } from './asyncData'
|
export type { AsyncDataOptions, AsyncData } from './asyncData'
|
||||||
export { useHydration } from './hydrate'
|
export { useHydration } from './hydrate'
|
||||||
export { useState } from './state'
|
export { useState } from './state'
|
||||||
export { clearError, createError, isNuxtError, throwError, showError, useError } from './error'
|
export { clearError, createError, isNuxtError, showError, useError } from './error'
|
||||||
export type { NuxtError } from './error'
|
export type { NuxtError } from './error'
|
||||||
export { useFetch, useLazyFetch } from './fetch'
|
export { useFetch, useLazyFetch } from './fetch'
|
||||||
export type { FetchResult, UseFetchOptions } from './fetch'
|
export type { FetchResult, UseFetchOptions } from './fetch'
|
||||||
export { useCookie } from './cookie'
|
export { useCookie } from './cookie'
|
||||||
export type { CookieOptions, CookieRef } from './cookie'
|
export type { CookieOptions, CookieRef } from './cookie'
|
||||||
export { useRequestHeaders, useRequestEvent, setResponseStatus } from './ssr'
|
export { useRequestHeaders, useRequestEvent, setResponseStatus } from './ssr'
|
||||||
export { abortNavigation, addRouteMiddleware, defineNuxtRouteMiddleware, onBeforeRouteLeave, onBeforeRouteUpdate, setPageLayout, navigateTo, useRoute, useActiveRoute, useRouter } from './router'
|
export { abortNavigation, addRouteMiddleware, defineNuxtRouteMiddleware, onBeforeRouteLeave, onBeforeRouteUpdate, setPageLayout, navigateTo, useRoute, useRouter } from './router'
|
||||||
export type { AddRouteMiddlewareOptions, RouteMiddleware } from './router'
|
export type { AddRouteMiddlewareOptions, RouteMiddleware } from './router'
|
||||||
export { preloadComponents, prefetchComponents, preloadRouteComponents } from './preload'
|
export { preloadComponents, prefetchComponents, preloadRouteComponents } from './preload'
|
||||||
export { isPrerendered, loadPayload, preloadPayload } from './payload'
|
export { isPrerendered, loadPayload, preloadPayload } from './payload'
|
||||||
|
@ -30,11 +30,6 @@ export const onBeforeRouteUpdate = (guard: NavigationGuard) => {
|
|||||||
onUnmounted(unsubscribe)
|
onUnmounted(unsubscribe)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @deprecated Use `useRoute` instead. */
|
|
||||||
export const useActiveRoute = (): RouteLocationNormalizedLoaded => {
|
|
||||||
return useNuxtApp()._route
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RouteMiddleware {
|
export interface RouteMiddleware {
|
||||||
(to: RouteLocationNormalized, from: RouteLocationNormalized): ReturnType<NavigationGuard>
|
(to: RouteLocationNormalized, from: RouteLocationNormalized): ReturnType<NavigationGuard>
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,6 @@ export default defineNuxtModule<ComponentsOptions>({
|
|||||||
const transpile = typeof dirOptions.transpile === 'boolean' ? dirOptions.transpile : 'auto'
|
const transpile = typeof dirOptions.transpile === 'boolean' ? dirOptions.transpile : 'auto'
|
||||||
const extensions = (dirOptions.extensions || nuxt.options.extensions).map(e => e.replace(/^\./g, ''))
|
const extensions = (dirOptions.extensions || nuxt.options.extensions).map(e => e.replace(/^\./g, ''))
|
||||||
|
|
||||||
dirOptions.level = Number(dirOptions.level || 0)
|
|
||||||
|
|
||||||
const present = isDirectory(dirPath)
|
const present = isDirectory(dirPath)
|
||||||
if (!present && !DEFAULT_COMPONENTS_DIRS_RE.test(dirOptions.path)) {
|
if (!present && !DEFAULT_COMPONENTS_DIRS_RE.test(dirOptions.path)) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
@ -9,7 +9,6 @@ export const addModuleTranspiles = (opts: AddModuleTranspilesOptions = {}) => {
|
|||||||
|
|
||||||
const modules = [
|
const modules = [
|
||||||
...opts.additionalModules || [],
|
...opts.additionalModules || [],
|
||||||
...nuxt.options.buildModules,
|
|
||||||
...nuxt.options.modules,
|
...nuxt.options.modules,
|
||||||
...nuxt.options._modules
|
...nuxt.options._modules
|
||||||
]
|
]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
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, NuxtConfig, NuxtHooks } from '@nuxt/schema'
|
import type { Nuxt, NuxtOptions, NuxtHooks } from '@nuxt/schema'
|
||||||
import { loadNuxtConfig, LoadNuxtOptions, nuxtCtx, installModule, addComponent, addVitePlugin, addWebpackPlugin, tryResolveModule, addPlugin } from '@nuxt/kit'
|
import { loadNuxtConfig, LoadNuxtOptions, nuxtCtx, installModule, addComponent, addVitePlugin, addWebpackPlugin, tryResolveModule, addPlugin } from '@nuxt/kit'
|
||||||
// Temporary until finding better placement
|
// Temporary until finding better placement
|
||||||
/* eslint-disable import/no-restricted-paths */
|
/* eslint-disable import/no-restricted-paths */
|
||||||
@ -116,7 +116,6 @@ async function initNuxt (nuxt: Nuxt) {
|
|||||||
// Init user modules
|
// Init user modules
|
||||||
await nuxt.callHook('modules:before')
|
await nuxt.callHook('modules:before')
|
||||||
const modulesToInstall = [
|
const modulesToInstall = [
|
||||||
...nuxt.options.buildModules,
|
|
||||||
...nuxt.options.modules,
|
...nuxt.options.modules,
|
||||||
...nuxt.options._modules
|
...nuxt.options._modules
|
||||||
]
|
]
|
||||||
@ -168,22 +167,6 @@ async function initNuxt (nuxt: Nuxt) {
|
|||||||
filePath: resolve(nuxt.options.appDir, 'components/nuxt-loading-indicator')
|
filePath: resolve(nuxt.options.appDir, 'components/nuxt-loading-indicator')
|
||||||
})
|
})
|
||||||
|
|
||||||
// Deprecate hooks
|
|
||||||
nuxt.hooks.deprecateHooks({
|
|
||||||
'autoImports:sources': {
|
|
||||||
to: 'imports:sources',
|
|
||||||
message: '`autoImports:sources` hook is deprecated. Use `addImportsSources()` from `@nuxt/kit` or `imports:dirs` with `nuxt>=3.0.0-rc.10`.'
|
|
||||||
},
|
|
||||||
'autoImports:dirs': {
|
|
||||||
to: 'imports:dirs',
|
|
||||||
message: '`autoImports:dirs` hook is deprecated. Use `addImportsDir()` from `@nuxt/kit` or `imports:dirs` with `nuxt>=3.0.0-rc.9`.'
|
|
||||||
},
|
|
||||||
'autoImports:extend': {
|
|
||||||
to: 'imports:extend',
|
|
||||||
message: '`autoImports:extend` hook is deprecated. Use `addImports()` from `@nuxt/kit` or `imports:extend` with `nuxt>=3.0.0-rc.9`.'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Add prerender payload support
|
// Add prerender payload support
|
||||||
if (!nuxt.options.dev && nuxt.options.experimental.payloadExtraction) {
|
if (!nuxt.options.dev && nuxt.options.experimental.payloadExtraction) {
|
||||||
addPlugin(resolve(nuxt.options.appDir, 'plugins/payload.client'))
|
addPlugin(resolve(nuxt.options.appDir, 'plugins/payload.client'))
|
||||||
@ -260,12 +243,3 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
|
|||||||
|
|
||||||
return 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
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @deprecated Use `import type { NuxtConfig } from 'nuxt/config'`. */
|
|
||||||
type _NuxtConfig = NuxtConfig
|
|
||||||
export type { _NuxtConfig as NuxtConfig }
|
|
||||||
|
@ -2,7 +2,7 @@ import { resolve } from 'pathe'
|
|||||||
import { addComponent, addPlugin, defineNuxtModule } from '@nuxt/kit'
|
import { addComponent, addPlugin, defineNuxtModule } from '@nuxt/kit'
|
||||||
import { distDir } from '../dirs'
|
import { distDir } from '../dirs'
|
||||||
|
|
||||||
const components = ['Script', 'NoScript', 'Link', 'Base', 'Title', 'Meta', 'Style', 'Head', 'Html', 'Body']
|
const components = ['NoScript', 'Link', 'Base', 'Title', 'Meta', 'Style', 'Head', 'Html', 'Body']
|
||||||
|
|
||||||
export default defineNuxtModule({
|
export default defineNuxtModule({
|
||||||
meta: {
|
meta: {
|
||||||
|
@ -65,57 +65,6 @@ const globalProps = {
|
|||||||
translate: String
|
translate: String
|
||||||
}
|
}
|
||||||
|
|
||||||
// <script>
|
|
||||||
|
|
||||||
let scriptDeprecated = false
|
|
||||||
|
|
||||||
/** @deprecated */
|
|
||||||
export const Script = defineComponent({
|
|
||||||
// eslint-disable-next-line vue/no-reserved-component-names
|
|
||||||
name: 'Script',
|
|
||||||
inheritAttrs: false,
|
|
||||||
props: {
|
|
||||||
...globalProps,
|
|
||||||
async: Boolean,
|
|
||||||
crossorigin: {
|
|
||||||
type: [Boolean, String as () => CrossOrigin],
|
|
||||||
default: undefined
|
|
||||||
},
|
|
||||||
defer: Boolean,
|
|
||||||
fetchpriority: String as PropType<FetchPriority>,
|
|
||||||
integrity: String,
|
|
||||||
nomodule: Boolean,
|
|
||||||
nonce: String,
|
|
||||||
referrerpolicy: String as PropType<ReferrerPolicy>,
|
|
||||||
src: String,
|
|
||||||
type: String,
|
|
||||||
/** @deprecated **/
|
|
||||||
charset: String,
|
|
||||||
/** @deprecated **/
|
|
||||||
language: String,
|
|
||||||
body: Boolean,
|
|
||||||
renderPriority: [String, Number]
|
|
||||||
},
|
|
||||||
setup: setupForUseMeta((props, { slots }) => {
|
|
||||||
if (process.dev && !scriptDeprecated) {
|
|
||||||
console.log('[nuxt] `<Script>` is deprecated and may be removed in a future release. We advise using `useHead()` directly.')
|
|
||||||
scriptDeprecated = true
|
|
||||||
}
|
|
||||||
|
|
||||||
const script = { ...props }
|
|
||||||
const textContent = (slots.default?.() || [])
|
|
||||||
.filter(({ children }) => children)
|
|
||||||
.map(({ children }) => children)
|
|
||||||
.join('')
|
|
||||||
if (textContent) {
|
|
||||||
script.children = textContent
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
script: [script]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// <noscript>
|
// <noscript>
|
||||||
export const NoScript = defineComponent({
|
export const NoScript = defineComponent({
|
||||||
name: 'NoScript',
|
name: 'NoScript',
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { addVitePlugin, addWebpackPlugin, defineNuxtModule, addTemplate, resolveAlias, useNuxt, addPluginTemplate, logger, updateTemplates } from '@nuxt/kit'
|
import { addVitePlugin, addWebpackPlugin, defineNuxtModule, addTemplate, resolveAlias, useNuxt, addPluginTemplate, updateTemplates } from '@nuxt/kit'
|
||||||
import { isAbsolute, join, relative, resolve, normalize } from 'pathe'
|
import { isAbsolute, join, relative, resolve, normalize } from 'pathe'
|
||||||
import { createUnimport, Import, scanDirExports, toImports, Unimport } from 'unimport'
|
import { createUnimport, Import, scanDirExports, toImports, Unimport } from 'unimport'
|
||||||
import { ImportsOptions, ImportPresetWithDeprecation } from '@nuxt/schema'
|
import { ImportsOptions, ImportPresetWithDeprecation } from '@nuxt/schema'
|
||||||
import defu from 'defu'
|
|
||||||
import { TransformPlugin } from './transform'
|
import { TransformPlugin } from './transform'
|
||||||
import { defaultPresets } from './presets'
|
import { defaultPresets } from './presets'
|
||||||
|
|
||||||
@ -23,28 +22,12 @@ export default defineNuxtModule<Partial<ImportsOptions>>({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async setup (options, nuxt) {
|
async setup (options, nuxt) {
|
||||||
// TODO: remove deprecation warning
|
|
||||||
// @ts-ignore
|
|
||||||
if (nuxt.options.autoImports) {
|
|
||||||
logger.warn('`autoImports` config is deprecated, use `imports` instead.')
|
|
||||||
// @ts-ignore
|
|
||||||
options = defu(nuxt.options.autoImports, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: fix sharing of defaults between invocations of modules
|
// TODO: fix sharing of defaults between invocations of modules
|
||||||
const presets = JSON.parse(JSON.stringify(options.presets)) as ImportPresetWithDeprecation[]
|
const presets = JSON.parse(JSON.stringify(options.presets)) as ImportPresetWithDeprecation[]
|
||||||
|
|
||||||
// Allow modules extending sources
|
// Allow modules extending sources
|
||||||
await nuxt.callHook('imports:sources', presets)
|
await nuxt.callHook('imports:sources', presets)
|
||||||
|
|
||||||
for (const _i of presets) {
|
|
||||||
const i = _i as ImportPresetWithDeprecation | string
|
|
||||||
if (typeof i !== 'string' && i.names && !i.imports) {
|
|
||||||
i.imports = i.names
|
|
||||||
logger.warn('imports: presets.names is deprecated, use presets.imports instead')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter disabled sources
|
// Filter disabled sources
|
||||||
// options.sources = options.sources.filter(source => source.disabled !== true)
|
// options.sources = options.sources.filter(source => source.disabled !== true)
|
||||||
|
|
||||||
|
@ -21,10 +21,6 @@ import { globalMiddleware, namedMiddleware } from '#build/middleware'
|
|||||||
declare module '@vue/runtime-core' {
|
declare module '@vue/runtime-core' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
NuxtPage: typeof NuxtPage
|
NuxtPage: typeof NuxtPage
|
||||||
/** @deprecated */
|
|
||||||
NuxtNestedPage: typeof NuxtPage
|
|
||||||
/** @deprecated */
|
|
||||||
NuxtChild: typeof NuxtPage
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +23,6 @@ export default defineUntypedSchema({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/** @deprecated Please use `imports` config. */
|
|
||||||
autoImports: null,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure how Nuxt auto-imports composables into your application.
|
* Configure how Nuxt auto-imports composables into your application.
|
||||||
*
|
*
|
||||||
|
@ -199,9 +199,6 @@ export default defineUntypedSchema({
|
|||||||
*/
|
*/
|
||||||
modules: [],
|
modules: [],
|
||||||
|
|
||||||
/** @deprecated Use `modules` instead */
|
|
||||||
buildModules: [],
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Customize default directory structure used by Nuxt.
|
* Customize default directory structure used by Nuxt.
|
||||||
*
|
*
|
||||||
@ -427,8 +424,6 @@ export default defineUntypedSchema({
|
|||||||
*/
|
*/
|
||||||
runtimeConfig: {
|
runtimeConfig: {
|
||||||
$resolve: async (val: RuntimeConfig, get) => defu(val, {
|
$resolve: async (val: RuntimeConfig, get) => defu(val, {
|
||||||
...await get('publicRuntimeConfig'),
|
|
||||||
...await get('privateRuntimeConfig'),
|
|
||||||
public: await get('publicRuntimeConfig'),
|
public: await get('publicRuntimeConfig'),
|
||||||
app: {
|
app: {
|
||||||
baseURL: (await get('app')).baseURL,
|
baseURL: (await get('app')).baseURL,
|
||||||
@ -438,18 +433,6 @@ export default defineUntypedSchema({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {typeof import('../src/types/config').PrivateRuntimeConfig}
|
|
||||||
* @deprecated Use `runtimeConfig` option.
|
|
||||||
*/
|
|
||||||
privateRuntimeConfig: {},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {typeof import('../src/types/config').PublicRuntimeConfig}
|
|
||||||
* @deprecated Use `runtimeConfig` option with `public` key (`runtimeConfig.public.*`).
|
|
||||||
*/
|
|
||||||
publicRuntimeConfig: {},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional app configuration
|
* Additional app configuration
|
||||||
*
|
*
|
||||||
|
@ -2,7 +2,7 @@ import { defineUntypedSchema } from 'untyped'
|
|||||||
|
|
||||||
export default defineUntypedSchema({
|
export default defineUntypedSchema({
|
||||||
/** @private */
|
/** @private */
|
||||||
_majorVersion: 2,
|
_majorVersion: 3,
|
||||||
/** @private */
|
/** @private */
|
||||||
_legacyGenerate: false,
|
_legacyGenerate: false,
|
||||||
/** @private */
|
/** @private */
|
||||||
|
@ -9,15 +9,6 @@ export interface Component {
|
|||||||
preload: boolean
|
preload: boolean
|
||||||
global?: boolean
|
global?: boolean
|
||||||
mode?: 'client' | 'server' | 'all'
|
mode?: 'client' | 'server' | 'all'
|
||||||
|
|
||||||
/** @deprecated */
|
|
||||||
level?: number
|
|
||||||
/** @deprecated */
|
|
||||||
import?: string
|
|
||||||
/** @deprecated */
|
|
||||||
asyncImport?: string
|
|
||||||
/** @deprecated */
|
|
||||||
async?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ScanDir {
|
export interface ScanDir {
|
||||||
@ -46,11 +37,6 @@ export interface ScanDir {
|
|||||||
* Ignore scanning this directory if set to `true`
|
* Ignore scanning this directory if set to `true`
|
||||||
*/
|
*/
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
/**
|
|
||||||
* Level is used to define a hint when overwriting the components which have the same name in two different directories.
|
|
||||||
* @deprecated Not used by Nuxt 3 anymore
|
|
||||||
*/
|
|
||||||
level?: number
|
|
||||||
/**
|
/**
|
||||||
* These properties (prefetch/preload) are used in production to configure how components with Lazy prefix are handled by Webpack via its magic comments.
|
* These properties (prefetch/preload) are used in production to configure how components with Lazy prefix are handled by Webpack via its magic comments.
|
||||||
* Learn more on Webpack documentation: https://webpack.js.org/api/module-methods/#magic-comments
|
* Learn more on Webpack documentation: https://webpack.js.org/api/module-methods/#magic-comments
|
||||||
|
@ -62,11 +62,7 @@ type RuntimeConfigNamespace = Record<string, any>
|
|||||||
|
|
||||||
export interface PublicRuntimeConfig extends RuntimeConfigNamespace { }
|
export interface PublicRuntimeConfig extends RuntimeConfigNamespace { }
|
||||||
|
|
||||||
// TODO: remove before release of 3.0.0
|
export interface RuntimeConfig extends RuntimeConfigNamespace {
|
||||||
/** @deprecated use RuntimeConfig interface */
|
|
||||||
export interface PrivateRuntimeConfig extends RuntimeConfigNamespace { }
|
|
||||||
|
|
||||||
export interface RuntimeConfig extends PrivateRuntimeConfig, RuntimeConfigNamespace {
|
|
||||||
public: PublicRuntimeConfig
|
public: PublicRuntimeConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +74,8 @@ export interface AppConfigInput extends Record<string, any> {
|
|||||||
nuxt?: never
|
nuxt?: never
|
||||||
/** @deprecated reserved */
|
/** @deprecated reserved */
|
||||||
nitro?: never
|
nitro?: never
|
||||||
|
/** @deprecated reserved */
|
||||||
|
server?: never
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NuxtAppConfig {
|
export interface NuxtAppConfig {
|
||||||
|
@ -40,10 +40,6 @@ export type NuxtLayout = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ImportPresetWithDeprecation extends InlinePreset {
|
export interface ImportPresetWithDeprecation extends InlinePreset {
|
||||||
/**
|
|
||||||
* @deprecated renamed to `imports`
|
|
||||||
*/
|
|
||||||
names?: string[]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GenerateAppOptions {
|
export interface GenerateAppOptions {
|
||||||
@ -76,14 +72,6 @@ export interface NuxtHooks {
|
|||||||
|
|
||||||
'server:devHandler': (handler: EventHandler) => HookResult
|
'server:devHandler': (handler: EventHandler) => HookResult
|
||||||
|
|
||||||
// Auto imports
|
|
||||||
/** @deprecated Please use `imports:sources` hook */
|
|
||||||
'autoImports:sources': (presets: ImportPresetWithDeprecation[]) => HookResult
|
|
||||||
/** @deprecated Please use `imports:extend` hook */
|
|
||||||
'autoImports:extend': (imports: Import[]) => HookResult
|
|
||||||
/** @deprecated Please use `imports:dirs` hook */
|
|
||||||
'autoImports:dirs': (dirs: string[]) => HookResult
|
|
||||||
|
|
||||||
'imports:sources': (presets: ImportPresetWithDeprecation[]) => HookResult
|
'imports:sources': (presets: ImportPresetWithDeprecation[]) => HookResult
|
||||||
'imports:extend': (imports: Import[]) => HookResult
|
'imports:extend': (imports: Import[]) => HookResult
|
||||||
'imports:dirs': (dirs: string[]) => HookResult
|
'imports:dirs': (dirs: string[]) => HookResult
|
||||||
|
@ -25,10 +25,6 @@ export interface Nuxt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface NuxtTemplate<Options = Record<string, any>> {
|
export interface NuxtTemplate<Options = Record<string, any>> {
|
||||||
/** @deprecated filename */
|
|
||||||
fileName?: string
|
|
||||||
/** @deprecated whether template is custom or a nuxt core template */
|
|
||||||
custom?: boolean
|
|
||||||
/** resolved output file path (generated) */
|
/** resolved output file path (generated) */
|
||||||
dst?: string
|
dst?: string
|
||||||
/** The target filename once the template is copied into the Nuxt buildDir */
|
/** The target filename once the template is copied into the Nuxt buildDir */
|
||||||
|
@ -13,7 +13,3 @@ export type RouterConfig = RouterOptions
|
|||||||
* Only JSON serializable router options are configurable from nuxt config
|
* Only JSON serializable router options are configurable from nuxt config
|
||||||
*/
|
*/
|
||||||
export type RouterConfigSerializable = Pick<RouterConfig, 'linkActiveClass' | 'linkExactActiveClass' | 'end' | 'sensitive' | 'strict' | 'hashMode'>
|
export type RouterConfigSerializable = Pick<RouterConfig, 'linkActiveClass' | 'linkExactActiveClass' | 'end' | 'sensitive' | 'strict' | 'hashMode'>
|
||||||
|
|
||||||
|
|
||||||
/** @deprecated Use RouterConfigSerializable instead */
|
|
||||||
export type RouterConfigOptions = RouterConfigSerializable
|
|
||||||
|
2
test/fixtures/basic/extends/node_modules/foo/nuxt.config.ts
generated
vendored
2
test/fixtures/basic/extends/node_modules/foo/nuxt.config.ts
generated
vendored
@ -1,3 +1,3 @@
|
|||||||
import { defineNuxtConfig } from 'nuxt'
|
import { defineNuxtConfig } from 'nuxt/config'
|
||||||
|
|
||||||
export default defineNuxtConfig({})
|
export default defineNuxtConfig({})
|
||||||
|
8
test/fixtures/basic/nuxt.config.ts
vendored
8
test/fixtures/basic/nuxt.config.ts
vendored
@ -40,11 +40,11 @@ export default defineNuxtConfig({
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
publicRuntimeConfig: {
|
runtimeConfig: {
|
||||||
|
privateConfig: 'secret_key',
|
||||||
|
public: {
|
||||||
testConfig: 123
|
testConfig: 123
|
||||||
},
|
}
|
||||||
privateRuntimeConfig: {
|
|
||||||
privateConfig: 'secret_key'
|
|
||||||
},
|
},
|
||||||
modules: [
|
modules: [
|
||||||
'~/modules/example',
|
'~/modules/example',
|
||||||
|
2
test/fixtures/basic/types.ts
vendored
2
test/fixtures/basic/types.ts
vendored
@ -115,7 +115,7 @@ describe('modules', () => {
|
|||||||
describe('runtimeConfig', () => {
|
describe('runtimeConfig', () => {
|
||||||
it('generated runtimeConfig types', () => {
|
it('generated runtimeConfig types', () => {
|
||||||
const runtimeConfig = useRuntimeConfig()
|
const runtimeConfig = useRuntimeConfig()
|
||||||
expectTypeOf(runtimeConfig.testConfig).toEqualTypeOf<number>()
|
expectTypeOf(runtimeConfig.public.testConfig).toEqualTypeOf<number>()
|
||||||
expectTypeOf(runtimeConfig.privateConfig).toEqualTypeOf<string>()
|
expectTypeOf(runtimeConfig.privateConfig).toEqualTypeOf<string>()
|
||||||
expectTypeOf(runtimeConfig.unknown).toEqualTypeOf<any>()
|
expectTypeOf(runtimeConfig.unknown).toEqualTypeOf<any>()
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user