fix(nuxi): ignore error if nitro is not enabled on bridge (#22642)

This commit is contained in:
Daniel Roe 2023-08-15 10:48:57 +01:00 committed by GitHub
parent 33389dc4e0
commit a522f1ee3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -41,6 +41,7 @@
"listhen": "1.3.0",
"mlly": "1.4.0",
"mri": "1.2.0",
"nitropack": "^2.5.2",
"ohash": "1.1.3",
"pathe": "1.1.1",
"perfect-debounce": "1.0.0",

View File

@ -1,5 +1,6 @@
import { relative, resolve } from 'pathe'
import { consola } from 'consola'
import type { Nitro } from 'nitropack'
// we are deliberately inlining this code as a backup in case user has `@nuxt/schema<3.7`
import { writeTypes as writeTypesLegacy } from '../../../kit/src/template'
@ -38,8 +39,12 @@ export default defineNuxtCommand({
}
})
// Use ? for backward compatibility for Nuxt <= RC.10
const nitro = useNitro?.()
let nitro: Nitro | undefined
// In Bridge, if nitro is not enabled, useNitro will throw an error
try {
// Use ? for backward compatibility for Nuxt <= RC.10
nitro = useNitro?.()
} catch {}
await clearBuildDir(nuxt.options.buildDir)

View File

@ -316,6 +316,9 @@ importers:
mri:
specifier: 1.2.0
version: 1.2.0
nitropack:
specifier: ^2.5.2
version: 2.5.2
ohash:
specifier: 1.1.3
version: 1.1.3