fix(nuxi): use file url to start nuxi (#19676)

This commit is contained in:
Daniel Roe 2023-03-14 14:06:48 +00:00 committed by GitHub
parent 2ebf5f4c44
commit 01ee5bd7c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,14 +5,14 @@ import { fileURLToPath } from 'node:url'
import { fork } from 'node:child_process'
import type { ChildProcess } from 'node:child_process'
const cliEntry = fileURLToPath(new URL('../dist/cli-run.mjs', import.meta.url))
const cliEntry = new URL('../dist/cli-run.mjs', import.meta.url)
// Only enable wrapper for nuxt dev command
if (process.argv[2] === 'dev') {
process.env.__CLI_ARGV__ = JSON.stringify(process.argv)
startSubprocess()
} else {
import(cliEntry)
import(cliEntry.href)
}
function startSubprocess () {
@ -33,7 +33,7 @@ function startSubprocess () {
start()
function start () {
childProc = fork(cliEntry)
childProc = fork(fileURLToPath(cliEntry))
childProc.on('close', (code) => { if (code) { process.exit(code) } })
childProc.on('message', (message) => {
if ((message as { type: string })?.type === 'nuxt:restart') {