mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +00:00
refactor: remove unnecessary optional chaining (#1991)
This commit is contained in:
parent
4ba637a5ea
commit
a08b435f51
@ -42,7 +42,7 @@ export default defineComponent({
|
|||||||
const { $docus } = useContext()
|
const { $docus } = useContext()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const currentSlug = computed(() => {
|
const currentSlug = computed(() => {
|
||||||
return route.value.path !== '/' && route?.value?.params?.pathMatch
|
return route.value.path !== '/' && route.value.params?.pathMatch
|
||||||
? route.value.params.pathMatch.split('/')[0]
|
? route.value.params.pathMatch.split('/')[0]
|
||||||
: null
|
: null
|
||||||
})
|
})
|
||||||
|
@ -20,7 +20,7 @@ export default defineComponent({
|
|||||||
const { $menu } = useContext()
|
const { $menu } = useContext()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const currentSlug = computed(() => {
|
const currentSlug = computed(() => {
|
||||||
return route.value.path !== '/' && route?.value?.params?.pathMatch
|
return route.value.path !== '/' && route.value.params?.pathMatch
|
||||||
? route.value.params.pathMatch.split('/')[0]
|
? route.value.params.pathMatch.split('/')[0]
|
||||||
: null
|
: null
|
||||||
})
|
})
|
||||||
|
@ -74,5 +74,5 @@ export const useNuxtApp = () => {
|
|||||||
return currentNuxtAppInstance
|
return currentNuxtAppInstance
|
||||||
}
|
}
|
||||||
|
|
||||||
return vm?.proxy.$_nuxtApp
|
return vm.proxy.$_nuxtApp
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
|
|||||||
prefix = 'nuxt'
|
prefix = 'nuxt'
|
||||||
} else if (lastModule.startsWith(nitroContext._internal.runtimeDir)) {
|
} else if (lastModule.startsWith(nitroContext._internal.runtimeDir)) {
|
||||||
prefix = 'nitro'
|
prefix = 'nitro'
|
||||||
} else if (!prefix && nitroContext.middleware.find(m => lastModule.startsWith(m.handle as string))) {
|
} else if (nitroContext.middleware.find(m => lastModule.startsWith(m.handle as string))) {
|
||||||
prefix = 'middleware'
|
prefix = 'middleware'
|
||||||
} else if (lastModule.includes('assets')) {
|
} else if (lastModule.includes('assets')) {
|
||||||
prefix = 'assets'
|
prefix = 'assets'
|
||||||
|
@ -76,7 +76,7 @@ for (const [dirname, dirOpts] of Object.entries(dirs)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function normalizeKey (key) {
|
function normalizeKey (key) {
|
||||||
return key.replace(/[/\\\\]/g, ':').replace(/^:|:$/g, '')
|
return key.replace(/[/\\]/g, ':').replace(/^:|:$/g, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAssetProd (assets: Record<string, Asset>) {
|
function getAssetProd (assets: Record<string, Asset>) {
|
||||||
|
@ -44,7 +44,7 @@ export default defineNuxtCommand({
|
|||||||
const isNuxt3 = nuxtVersion.startsWith('3')
|
const isNuxt3 = nuxtVersion.startsWith('3')
|
||||||
const useVite = isNuxt3
|
const useVite = isNuxt3
|
||||||
? nuxtConfig.vite !== false
|
? nuxtConfig.vite !== false
|
||||||
: (nuxtConfig?.buildModules?.find(m => m === 'nuxt-vite'))
|
: (nuxtConfig.buildModules?.find(m => m === 'nuxt-vite'))
|
||||||
|
|
||||||
let packageManager = getPackageManager(rootDir)
|
let packageManager = getPackageManager(rootDir)
|
||||||
if (packageManager) {
|
if (packageManager) {
|
||||||
|
Loading…
Reference in New Issue
Block a user