mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxi): resolve @nuxt/ui-templates
from modulesDir
(#21836)
This commit is contained in:
parent
4709c3acf9
commit
1cc22aa4aa
@ -25,20 +25,6 @@ export default defineNuxtCommand({
|
|||||||
async invoke (args, options = {}) {
|
async invoke (args, options = {}) {
|
||||||
overrideEnv('development')
|
overrideEnv('development')
|
||||||
|
|
||||||
const { listen } = await import('listhen')
|
|
||||||
const { toNodeListener } = await import('h3')
|
|
||||||
let currentHandler: RequestListener | undefined
|
|
||||||
let loadingMessage = 'Nuxt is starting...'
|
|
||||||
const loadingHandler: RequestListener = async (_req, res) => {
|
|
||||||
const { loading: loadingTemplate } = await importModule('@nuxt/ui-templates')
|
|
||||||
res.setHeader('Content-Type', 'text/html; charset=UTF-8')
|
|
||||||
res.statusCode = 503 // Service Unavailable
|
|
||||||
res.end(loadingTemplate({ loading: loadingMessage }))
|
|
||||||
}
|
|
||||||
const serverHandler: RequestListener = (req, res) => {
|
|
||||||
return currentHandler ? currentHandler(req, res) : loadingHandler(req, res)
|
|
||||||
}
|
|
||||||
|
|
||||||
const rootDir = resolve(args._[0] || '.')
|
const rootDir = resolve(args._[0] || '.')
|
||||||
showVersions(rootDir)
|
showVersions(rootDir)
|
||||||
|
|
||||||
@ -55,6 +41,20 @@ export default defineNuxtCommand({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { listen } = await import('listhen')
|
||||||
|
const { toNodeListener } = await import('h3')
|
||||||
|
let currentHandler: RequestListener | undefined
|
||||||
|
let loadingMessage = 'Nuxt is starting...'
|
||||||
|
const loadingHandler: RequestListener = async (_req, res) => {
|
||||||
|
const { loading: loadingTemplate } = await importModule('@nuxt/ui-templates', config.modulesDir)
|
||||||
|
res.setHeader('Content-Type', 'text/html; charset=UTF-8')
|
||||||
|
res.statusCode = 503 // Service Unavailable
|
||||||
|
res.end(loadingTemplate({ loading: loadingMessage }))
|
||||||
|
}
|
||||||
|
const serverHandler: RequestListener = (req, res) => {
|
||||||
|
return currentHandler ? currentHandler(req, res) : loadingHandler(req, res)
|
||||||
|
}
|
||||||
|
|
||||||
const listener = await listen(serverHandler, {
|
const listener = await listen(serverHandler, {
|
||||||
showURL: false,
|
showURL: false,
|
||||||
clipboard: args.clipboard,
|
clipboard: args.clipboard,
|
||||||
|
@ -7,7 +7,7 @@ export async function tryResolveModule (id: string, url = import.meta.url) {
|
|||||||
} catch { }
|
} catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function importModule (id: string, url = import.meta.url) {
|
export async function importModule (id: string, url: string | string[] = import.meta.url) {
|
||||||
const resolvedPath = await resolvePath(id, { url })
|
const resolvedPath = await resolvePath(id, { url })
|
||||||
return import(pathToFileURL(resolvedPath).href).then(interopDefault)
|
return import(pathToFileURL(resolvedPath).href).then(interopDefault)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user