mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 07:40:33 +00:00
fix(bridge): improve warnings for @nuxtjs/composition-api
migration (#1237)
This commit is contained in:
parent
4526af78a9
commit
2256b2b86a
@ -78,7 +78,7 @@ warnOnce('import', `\`@nuxtjs/composition-api\` is deprecated. ${checkDocsMsg}`)
|
|||||||
|
|
||||||
// Stub functions that provided type support
|
// Stub functions that provided type support
|
||||||
export const defineNuxtMiddleware = mw => mw
|
export const defineNuxtMiddleware = mw => mw
|
||||||
export const defineNuxtPlugin = unsupported('You are using `defineNuxtPlugin`, which can be replaced with `defineNuxtPlugin` from `@nuxt/bridge`.')
|
export const defineNuxtPlugin = unsupported('You are using `defineNuxtPlugin`, which can be replaced with `defineNuxtPlugin` (import from `#app`).')
|
||||||
|
|
||||||
// Internal exports
|
// Internal exports
|
||||||
export const setMetaPlugin = unsupported('`setMetaPlugin` is an internal function that is no longer used.')
|
export const setMetaPlugin = unsupported('`setMetaPlugin` is an internal function that is no longer used.')
|
||||||
@ -128,13 +128,13 @@ export const ssrPromise = (value, key) => {
|
|||||||
|
|
||||||
// Composition API functions
|
// Composition API functions
|
||||||
export const onGlobalSetup = (fn) => {
|
export const onGlobalSetup = (fn) => {
|
||||||
warnOnce('onGlobalSetup', '`onGlobalSetup` is deprecated and can be replaced with `defineNuxtPlugin` and `nuxt.provide`.')
|
warnOnce('onGlobalSetup', '`onGlobalSetup` is deprecated and can be replaced with `defineNuxtPlugin(nuxtApp => nuxtApp.provide)` (import from `#app`).')
|
||||||
const app = useNuxtApp()
|
const app = useNuxtApp()
|
||||||
app._setupFns.push(fn)
|
app._setupFns.push(fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useAsync = (cb, key) => {
|
export const useAsync = (cb, key) => {
|
||||||
warnOnce('useAsync', 'You are using `useAsync`, which can be replaced with `useAsyncData` from `@nuxt/bridge`.')
|
warnOnce('useAsync', 'You are using `useAsync`, which is deprecated.')
|
||||||
|
|
||||||
const _ref = isRef(key) ? key : ssrRef(null, key)
|
const _ref = isRef(key) ? key : ssrRef(null, key)
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ export const useAsync = (cb, key) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useContext = () => {
|
export const useContext = () => {
|
||||||
warnOnce('useContext', 'You are using `useContext`, which can be replaced with `useNuxtApp` from `@nuxt/bridge`.')
|
warnOnce('useContext', 'You are using `useContext`, which can be replaced with `useNuxtApp` (import from `#app`).')
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const nuxt = useNuxtApp()
|
const nuxt = useNuxtApp()
|
||||||
@ -246,12 +246,12 @@ export const wrapProperty = (property, makeComputed = true) => () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useRouter = () => {
|
export const useRouter = () => {
|
||||||
warnOnce('useRouter', 'You are using `useRouter`, which can be replaced with `useRouter` from `@nuxt/bridge`.')
|
warnOnce('useRouter', 'You are using `useRouter`, which can be replaced with `useRouter` (import from `#app`).')
|
||||||
return getCurrentInstance().$router
|
return getCurrentInstance().$router
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useRoute = () => {
|
export const useRoute = () => {
|
||||||
warnOnce('useRoute', 'You are using `useRoute`, which can be replaced with `useRoute` from `@nuxt/bridge`.')
|
warnOnce('useRoute', 'You are using `useRoute`, which can be replaced with `useRoute` (import from `#app`).')
|
||||||
const vm = getCurrentInstance()
|
const vm = getCurrentInstance()
|
||||||
return computed(() => vm.$route)
|
return computed(() => vm.$route)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user