mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
refactor!: remove deprecated api (#9029)
This commit is contained in:
parent
ab7ec7822c
commit
5ac9d85a49
@ -72,7 +72,7 @@ useHead({
|
||||
|
||||
## 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.
|
||||
|
||||
@ -186,30 +186,18 @@ You can use the `body: true` option on the `link` and `script` meta tags to appe
|
||||
|
||||
For example:
|
||||
|
||||
::code-group
|
||||
|
||||
```vue [useHead]
|
||||
<script setup lang="ts">
|
||||
useHead({
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
useHead({
|
||||
script: [
|
||||
{
|
||||
src: 'https://third-party-script.com',
|
||||
body: true
|
||||
}
|
||||
]
|
||||
})
|
||||
</script>
|
||||
```
|
||||
|
||||
```vue [Components]
|
||||
<template>
|
||||
<div>
|
||||
<Script src="https://third-party-script.com" body="true" />
|
||||
</div>
|
||||
</template>
|
||||
```
|
||||
|
||||
::
|
||||
})
|
||||
</script>
|
||||
```
|
||||
|
||||
## 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)
|
||||
|
||||
- `addImports(imports)`
|
||||
- `addImportsDir(autoImportDirs)`
|
||||
- `addImportsSources(autoImportSources)`
|
||||
- `addImportsDir(importDirs)`
|
||||
- `addImportsSources(importSources)`
|
||||
|
||||
### Components
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
<Title>Luck number: {{ dynamic }}</Title>
|
||||
<Meta name="description" :content="`My page's ${dynamic} description`" />
|
||||
<Link rel="preload" href="/test.txt" as="script" />
|
||||
<Script>console.log("hello script");</Script>
|
||||
</Head>
|
||||
</Html>
|
||||
|
||||
|
@ -30,13 +30,6 @@ export interface ExtendConfigOptions {
|
||||
}
|
||||
|
||||
export interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
|
||||
/**
|
||||
* Install plugin on modern build
|
||||
*
|
||||
* @default true
|
||||
* @deprecated Nuxt 2 only
|
||||
*/
|
||||
modern?: boolean
|
||||
}
|
||||
|
||||
export interface ExtendViteConfigOptions extends ExtendConfigOptions {}
|
||||
@ -73,13 +66,6 @@ export function extendWebpackConfig (
|
||||
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 type { ComponentsDir, Component } from '@nuxt/schema'
|
||||
import { genDynamicImport } from 'knitwork'
|
||||
import { useNuxt } from './context'
|
||||
import { assertNuxtCompatibility } from './compatibility'
|
||||
|
||||
@ -40,14 +39,7 @@ export async function addComponent (opts: AddComponentOptions) {
|
||||
prefetch: false,
|
||||
preload: false,
|
||||
mode: 'all',
|
||||
|
||||
// Nuxt 2 support
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -6,40 +6,26 @@ import { assertNuxtCompatibility } from './compatibility'
|
||||
export function addImports (imports: Import | Import[]) {
|
||||
assertNuxtCompatibility({ bridge: true })
|
||||
|
||||
// TODO: Use imports:* when widely adopted
|
||||
useNuxt().hook('autoImports:extend', (_imports) => {
|
||||
useNuxt().hook('imports:extend', (_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[]) {
|
||||
assertNuxtCompatibility({ bridge: true })
|
||||
|
||||
// TODO: Use imports:* when widely adopted
|
||||
useNuxt().hook('autoImports:dirs', (_dirs: string[]) => {
|
||||
useNuxt().hook('imports:dirs', (_dirs: string[]) => {
|
||||
for (const dir of (Array.isArray(dirs) ? dirs : [dirs])) {
|
||||
_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[]) {
|
||||
assertNuxtCompatibility({ bridge: true })
|
||||
|
||||
// TODO: Use imports:* when widely adopted
|
||||
useNuxt().hook('autoImports:sources', (_presets: ImportPresetWithDeprecation[]) => {
|
||||
useNuxt().hook('imports:sources', (_presets: ImportPresetWithDeprecation[]) => {
|
||||
for (const preset of (Array.isArray(presets) ? presets : [presets])) {
|
||||
_presets.push(preset)
|
||||
}
|
||||
}, { allowDeprecated: true })
|
||||
})
|
||||
}
|
||||
|
@ -6,10 +6,12 @@ import jiti from 'jiti'
|
||||
// TODO: use create-require for jest environment
|
||||
const _require = jiti(process.cwd(), { interopDefault: true, esmResolve: true })
|
||||
|
||||
/** @deprecated Do not use CJS utils */
|
||||
export interface ResolveModuleOptions {
|
||||
paths?: string | string[]
|
||||
}
|
||||
|
||||
/** @deprecated Do not use CJS utils */
|
||||
export interface RequireModuleOptions extends ResolveModuleOptions {
|
||||
// TODO: use create-require for jest environment
|
||||
// native?: boolean
|
||||
@ -20,11 +22,13 @@ export interface RequireModuleOptions extends ResolveModuleOptions {
|
||||
interopDefault?: boolean
|
||||
}
|
||||
|
||||
/** @deprecated Do not use CJS utils */
|
||||
export function isNodeModules (id: string) {
|
||||
// TODO: Follow symlinks
|
||||
return /[/\\]node_modules[/\\]/.test(id)
|
||||
}
|
||||
|
||||
/** @deprecated Do not use CJS utils */
|
||||
export function clearRequireCache (id: string) {
|
||||
if (isNodeModules(id)) {
|
||||
return
|
||||
@ -48,6 +52,7 @@ export function clearRequireCache (id: string) {
|
||||
delete _require.cache[id]
|
||||
}
|
||||
|
||||
/** @deprecated Do not use CJS utils */
|
||||
export function scanRequireTree (id: string, files = new Set<string>()) {
|
||||
if (isNodeModules(id) || files.has(id)) {
|
||||
return files
|
||||
@ -69,7 +74,7 @@ export function scanRequireTree (id: string, files = new Set<string>()) {
|
||||
return files
|
||||
}
|
||||
|
||||
/** Access the require cache by module id. */
|
||||
/** @deprecated Do not use CJS utils */
|
||||
export function getRequireCacheItem (id: string) {
|
||||
try {
|
||||
return _require.cache[id]
|
||||
@ -82,7 +87,7 @@ export function requireModulePkg (id: string, opts: RequireModuleOptions = {}) {
|
||||
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 = {}) {
|
||||
return normalize(_require.resolve(id, {
|
||||
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 {
|
||||
try {
|
||||
return resolveModule(path, opts)
|
||||
@ -108,7 +113,7 @@ export function tryResolveModule (path: string, opts: ResolveModuleOptions = {})
|
||||
return null
|
||||
}
|
||||
|
||||
/** Require a module and return it. */
|
||||
/** @deprecated Do not use CJS utils */
|
||||
export function requireModule (id: string, opts: RequireModuleOptions = {}) {
|
||||
// Resolve id
|
||||
const resolvedPath = resolveModule(id, opts)
|
||||
@ -124,6 +129,7 @@ export function requireModule (id: string, opts: RequireModuleOptions = {}) {
|
||||
return requiredModule
|
||||
}
|
||||
|
||||
/** @deprecated Do not use CJS utils */
|
||||
export function importModule (id: string, opts: RequireModuleOptions = {}) {
|
||||
const resolvedPath = resolveModule(id, opts)
|
||||
if (opts.interopDefault !== false) {
|
||||
@ -132,13 +138,14 @@ export function importModule (id: string, opts: RequireModuleOptions = {}) {
|
||||
return import(pathToFileURL(resolvedPath).href)
|
||||
}
|
||||
|
||||
/** @deprecated Do not use CJS utils */
|
||||
export function tryImportModule (id: string, opts: RequireModuleOptions = {}) {
|
||||
try {
|
||||
return importModule(id, opts).catch(() => undefined)
|
||||
} 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 = {}) {
|
||||
try {
|
||||
return requireModule(id, opts)
|
||||
|
@ -4,6 +4,7 @@ import { genSafeVariableName, genDynamicImport, genImport } from 'knitwork'
|
||||
|
||||
import type { NuxtTemplate } from '@nuxt/schema'
|
||||
|
||||
/** @deprecated */
|
||||
export async function compileTemplate (template: NuxtTemplate, ctx: any) {
|
||||
const data = { ...ctx, options: template.options }
|
||||
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.
|
||||
*/
|
||||
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
|
||||
if (!definition.meta) { definition.meta = {} }
|
||||
if (!definition.meta.configKey) {
|
||||
// @ts-ignore TODO: Remove non-meta fallbacks in RC
|
||||
definition.meta.name = definition.meta.name || definition.name
|
||||
// @ts-ignore
|
||||
definition.meta.configKey = definition.configKey || definition.meta.name
|
||||
if (definition.meta.configKey === undefined) {
|
||||
definition.meta.configKey = definition.meta.name
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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
|
||||
if (typeof nuxtModule === 'string') {
|
||||
const _src = resolveModule(resolveAlias(nuxtModule), { paths: nuxt.options.modulesDir })
|
||||
|
@ -45,7 +45,7 @@ export function normalizeTemplate (template: NuxtTemplate<any> | string): Resolv
|
||||
}
|
||||
if (!template.filename) {
|
||||
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}`
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ export default defineNuxtCommand({
|
||||
Builder: builder,
|
||||
UserConfig: Object.keys(nuxtConfig).map(key => '`' + key + '`').join(', '),
|
||||
RuntimeModules: listModules(nuxtConfig.modules),
|
||||
BuildModules: listModules(nuxtConfig.buildModules)
|
||||
BuildModules: listModules(nuxtConfig.buildModules || [])
|
||||
}
|
||||
|
||||
console.log('RootDir:', rootDir)
|
||||
|
@ -63,7 +63,6 @@ export const writeTypes = async (nuxt: Nuxt) => {
|
||||
}
|
||||
|
||||
const references: TSReference[] = [
|
||||
...nuxt.options.buildModules,
|
||||
...nuxt.options.modules,
|
||||
...nuxt.options._modules
|
||||
]
|
||||
|
@ -96,11 +96,7 @@ export function useAsyncData<
|
||||
options.server = options.server ?? true
|
||||
options.default = options.default ?? getDefault
|
||||
|
||||
// TODO: remove support for `defer` in Nuxt 3 RC
|
||||
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.lazy = options.lazy ?? false
|
||||
options.immediate = options.immediate ?? true
|
||||
|
||||
// Setup nuxt instance payload
|
||||
|
@ -21,9 +21,6 @@ export const showError = (_err: string | Error | Partial<NuxtError>) => {
|
||||
return err
|
||||
}
|
||||
|
||||
/** @deprecated Use `throw createError()` or `showError` */
|
||||
export const throwError = showError
|
||||
|
||||
export const clearError = async (options: { redirect?: string } = {}) => {
|
||||
const nuxtApp = useNuxtApp()
|
||||
const error = useError()
|
||||
|
@ -3,14 +3,14 @@ export { useAsyncData, useLazyAsyncData, refreshNuxtData, clearNuxtData } from '
|
||||
export type { AsyncDataOptions, AsyncData } from './asyncData'
|
||||
export { useHydration } from './hydrate'
|
||||
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 { useFetch, useLazyFetch } from './fetch'
|
||||
export type { FetchResult, UseFetchOptions } from './fetch'
|
||||
export { useCookie } from './cookie'
|
||||
export type { CookieOptions, CookieRef } from './cookie'
|
||||
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 { preloadComponents, prefetchComponents, preloadRouteComponents } from './preload'
|
||||
export { isPrerendered, loadPayload, preloadPayload } from './payload'
|
||||
|
@ -30,11 +30,6 @@ export const onBeforeRouteUpdate = (guard: NavigationGuard) => {
|
||||
onUnmounted(unsubscribe)
|
||||
}
|
||||
|
||||
/** @deprecated Use `useRoute` instead. */
|
||||
export const useActiveRoute = (): RouteLocationNormalizedLoaded => {
|
||||
return useNuxtApp()._route
|
||||
}
|
||||
|
||||
export interface RouteMiddleware {
|
||||
(to: RouteLocationNormalized, from: RouteLocationNormalized): ReturnType<NavigationGuard>
|
||||
}
|
||||
|
@ -78,8 +78,6 @@ export default defineNuxtModule<ComponentsOptions>({
|
||||
const transpile = typeof dirOptions.transpile === 'boolean' ? dirOptions.transpile : 'auto'
|
||||
const extensions = (dirOptions.extensions || nuxt.options.extensions).map(e => e.replace(/^\./g, ''))
|
||||
|
||||
dirOptions.level = Number(dirOptions.level || 0)
|
||||
|
||||
const present = isDirectory(dirPath)
|
||||
if (!present && !DEFAULT_COMPONENTS_DIRS_RE.test(dirOptions.path)) {
|
||||
// eslint-disable-next-line no-console
|
||||
|
@ -9,7 +9,6 @@ export const addModuleTranspiles = (opts: AddModuleTranspilesOptions = {}) => {
|
||||
|
||||
const modules = [
|
||||
...opts.additionalModules || [],
|
||||
...nuxt.options.buildModules,
|
||||
...nuxt.options.modules,
|
||||
...nuxt.options._modules
|
||||
]
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { join, normalize, resolve } from 'pathe'
|
||||
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'
|
||||
// Temporary until finding better placement
|
||||
/* eslint-disable import/no-restricted-paths */
|
||||
@ -116,7 +116,6 @@ async function initNuxt (nuxt: Nuxt) {
|
||||
// Init user modules
|
||||
await nuxt.callHook('modules:before')
|
||||
const modulesToInstall = [
|
||||
...nuxt.options.buildModules,
|
||||
...nuxt.options.modules,
|
||||
...nuxt.options._modules
|
||||
]
|
||||
@ -168,22 +167,6 @@ async function initNuxt (nuxt: Nuxt) {
|
||||
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
|
||||
if (!nuxt.options.dev && nuxt.options.experimental.payloadExtraction) {
|
||||
addPlugin(resolve(nuxt.options.appDir, 'plugins/payload.client'))
|
||||
@ -260,12 +243,3 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<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 { 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({
|
||||
meta: {
|
||||
|
@ -65,57 +65,6 @@ const globalProps = {
|
||||
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>
|
||||
export const NoScript = defineComponent({
|
||||
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 { createUnimport, Import, scanDirExports, toImports, Unimport } from 'unimport'
|
||||
import { ImportsOptions, ImportPresetWithDeprecation } from '@nuxt/schema'
|
||||
import defu from 'defu'
|
||||
import { TransformPlugin } from './transform'
|
||||
import { defaultPresets } from './presets'
|
||||
|
||||
@ -23,28 +22,12 @@ export default defineNuxtModule<Partial<ImportsOptions>>({
|
||||
}
|
||||
},
|
||||
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
|
||||
const presets = JSON.parse(JSON.stringify(options.presets)) as ImportPresetWithDeprecation[]
|
||||
|
||||
// Allow modules extending sources
|
||||
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
|
||||
// options.sources = options.sources.filter(source => source.disabled !== true)
|
||||
|
||||
|
@ -21,10 +21,6 @@ import { globalMiddleware, namedMiddleware } from '#build/middleware'
|
||||
declare module '@vue/runtime-core' {
|
||||
export interface GlobalComponents {
|
||||
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.
|
||||
*
|
||||
|
@ -199,9 +199,6 @@ export default defineUntypedSchema({
|
||||
*/
|
||||
modules: [],
|
||||
|
||||
/** @deprecated Use `modules` instead */
|
||||
buildModules: [],
|
||||
|
||||
/**
|
||||
* Customize default directory structure used by Nuxt.
|
||||
*
|
||||
@ -427,8 +424,6 @@ export default defineUntypedSchema({
|
||||
*/
|
||||
runtimeConfig: {
|
||||
$resolve: async (val: RuntimeConfig, get) => defu(val, {
|
||||
...await get('publicRuntimeConfig'),
|
||||
...await get('privateRuntimeConfig'),
|
||||
public: await get('publicRuntimeConfig'),
|
||||
app: {
|
||||
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
|
||||
*
|
||||
|
@ -2,7 +2,7 @@ import { defineUntypedSchema } from 'untyped'
|
||||
|
||||
export default defineUntypedSchema({
|
||||
/** @private */
|
||||
_majorVersion: 2,
|
||||
_majorVersion: 3,
|
||||
/** @private */
|
||||
_legacyGenerate: false,
|
||||
/** @private */
|
||||
|
@ -9,15 +9,6 @@ export interface Component {
|
||||
preload: boolean
|
||||
global?: boolean
|
||||
mode?: 'client' | 'server' | 'all'
|
||||
|
||||
/** @deprecated */
|
||||
level?: number
|
||||
/** @deprecated */
|
||||
import?: string
|
||||
/** @deprecated */
|
||||
asyncImport?: string
|
||||
/** @deprecated */
|
||||
async?: boolean
|
||||
}
|
||||
|
||||
export interface ScanDir {
|
||||
@ -46,11 +37,6 @@ export interface ScanDir {
|
||||
* Ignore scanning this directory if set to `true`
|
||||
*/
|
||||
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.
|
||||
* 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 { }
|
||||
|
||||
// TODO: remove before release of 3.0.0
|
||||
/** @deprecated use RuntimeConfig interface */
|
||||
export interface PrivateRuntimeConfig extends RuntimeConfigNamespace { }
|
||||
|
||||
export interface RuntimeConfig extends PrivateRuntimeConfig, RuntimeConfigNamespace {
|
||||
export interface RuntimeConfig extends RuntimeConfigNamespace {
|
||||
public: PublicRuntimeConfig
|
||||
}
|
||||
|
||||
@ -78,6 +74,8 @@ export interface AppConfigInput extends Record<string, any> {
|
||||
nuxt?: never
|
||||
/** @deprecated reserved */
|
||||
nitro?: never
|
||||
/** @deprecated reserved */
|
||||
server?: never
|
||||
}
|
||||
|
||||
export interface NuxtAppConfig {
|
||||
|
@ -40,10 +40,6 @@ export type NuxtLayout = {
|
||||
}
|
||||
|
||||
export interface ImportPresetWithDeprecation extends InlinePreset {
|
||||
/**
|
||||
* @deprecated renamed to `imports`
|
||||
*/
|
||||
names?: string[]
|
||||
}
|
||||
|
||||
export interface GenerateAppOptions {
|
||||
@ -76,14 +72,6 @@ export interface NuxtHooks {
|
||||
|
||||
'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:extend': (imports: Import[]) => HookResult
|
||||
'imports:dirs': (dirs: string[]) => HookResult
|
||||
|
@ -25,10 +25,6 @@ export interface Nuxt {
|
||||
}
|
||||
|
||||
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) */
|
||||
dst?: string
|
||||
/** 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
|
||||
*/
|
||||
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({})
|
||||
|
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
|
||||
},
|
||||
privateRuntimeConfig: {
|
||||
privateConfig: 'secret_key'
|
||||
}
|
||||
},
|
||||
modules: [
|
||||
'~/modules/example',
|
||||
|
2
test/fixtures/basic/types.ts
vendored
2
test/fixtures/basic/types.ts
vendored
@ -115,7 +115,7 @@ describe('modules', () => {
|
||||
describe('runtimeConfig', () => {
|
||||
it('generated runtimeConfig types', () => {
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
expectTypeOf(runtimeConfig.testConfig).toEqualTypeOf<number>()
|
||||
expectTypeOf(runtimeConfig.public.testConfig).toEqualTypeOf<number>()
|
||||
expectTypeOf(runtimeConfig.privateConfig).toEqualTypeOf<string>()
|
||||
expectTypeOf(runtimeConfig.unknown).toEqualTypeOf<any>()
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user