Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b7811f6
chore: add srvx
danielroe Jun 4, 2025
835c274
perf: slight performance optimisations for fast path
danielroe Jun 4, 2025
82738d2
perf(dev): use standalone dev entrypoint
danielroe Jun 4, 2025
af177ac
fix: lazy import jiti + use exsolve to resolve paths
danielroe Jun 4, 2025
19baee8
refactor: deduplicate code for no-fork mode
danielroe Jun 4, 2025
297f4aa
perf(dev): initiate fork in parallel with creating proxy
danielroe Jun 4, 2025
466590c
fix: pass cwd to initialize
danielroe Jun 4, 2025
f342cd5
refactor: pass args through dev context
danielroe Jun 4, 2025
4f2ce92
build: fix nuxt-cli build
danielroe Jun 4, 2025
dab2e80
fix: pass listen options to no-forked dev server
danielroe Jun 4, 2025
422c8b8
chore: remove srvx (not yet used)
danielroe Jun 4, 2025
54d180c
[autofix.ci] apply automated fixes
autofix-ci[bot] Jun 4, 2025
18312aa
chore: ignore `exsolve`
danielroe Jun 4, 2025
78d33d0
chore: assert devEntry
danielroe Jun 4, 2025
556b30b
fix: don't spin up ipc if we're in a vitest child process
danielroe Jun 6, 2025
ffc6187
fix: use nitro dev server types
danielroe Jun 6, 2025
dda110f
perf: start initially in no-fork mode
danielroe Jun 6, 2025
d3282e2
test: add test for running dev server
danielroe Jun 6, 2025
a075173
fix: use `__NUXT__FORK` to check for forked environment
danielroe Jun 6, 2025
534035b
chore: add nuxt prepare postinstall step
danielroe Jun 6, 2025
968ccd5
chore: prepare playground first
danielroe Jun 6, 2025
df5ad34
test: skip dev test temporarily
danielroe Jun 6, 2025
c3649b4
chore: lint + guard send
danielroe Jun 6, 2025
4a4f33e
Merge remote-tracking branch 'origin/main' into refactor/dev
danielroe Jun 6, 2025
f7cd477
chore: ignore test/utils
danielroe Jun 6, 2025
e6c52c0
test: close servers
danielroe Jun 6, 2025
6b954a8
test: close
danielroe Jun 7, 2025
dd2514f
test: kill/close within each bench
danielroe Jun 7, 2025
c39565b
chore: try just fork
danielroe Jun 7, 2025
38c8d61
ci: sync bench tests
danielroe Jun 7, 2025
9c1a513
test: sync
danielroe Jun 7, 2025
7304802
test: sync
danielroe Jun 7, 2025
fa235ca
test: split out again
danielroe Jun 7, 2025
9172060
Update dev.bench.ts
danielroe Jun 7, 2025
5253c74
chore: fix entrypoint
danielroe Jun 7, 2025
f44af73
chore: fix entrypoint urls
danielroe Jun 7, 2025
6d16100
chore: for goodness' sake
danielroe Jun 7, 2025
9f97a40
chore: remove teardown for requests
danielroe Jun 7, 2025
c4b88ae
Update dev.bench.ts
danielroe Jun 7, 2025
b39891d
test: only no-fork
danielroe Jun 7, 2025
085d867
test: non-async describe
danielroe Jun 7, 2025
0571e2e
Merge remote-tracking branch 'origin/main' into refactor/dev
danielroe Jun 7, 2025
47e713c
chore: remove duplicate function
danielroe Jun 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"packages/nuxt-cli/playground": {
"ignoreDependencies": [
"@nuxt/test-utils",
"nuxt"
]
},
Expand All @@ -21,6 +22,7 @@
"clipboardy",
"consola",
"defu",
"exsolve",
"fuse.js",
"giget",
"h3",
Expand Down
1 change: 1 addition & 0 deletions packages/nuxi/bin/nuxi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { runMain } from '../dist/index.mjs'
globalThis.__nuxt_cli__ = {
startTime: Date.now(),
entry: fileURLToPath(import.meta.url),
devEntry: fileURLToPath(new URL('../dist/dev/index.mjs', import.meta.url)),
}

runMain()
5 changes: 4 additions & 1 deletion packages/nuxi/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export default defineBuildConfig({
exportConditions: ['production', 'node'],
},
},
entries: ['src/index'],
entries: [
'src/index',
'src/dev/index.ts',
],
externals: [
'@nuxt/test-utils',
'fsevents',
Expand Down
1 change: 1 addition & 0 deletions packages/nuxi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"clipboardy": "^4.0.0",
"consola": "^3.4.2",
"defu": "^6.1.4",
"exsolve": "^1.0.5",
"fuse.js": "^7.1.0",
"giget": "^2.0.0",
"h3": "^1.15.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxi/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default defineCommand({

const cwd = resolve(ctx.args.cwd || ctx.args.rootDir)

await showVersions(cwd)
showVersions(cwd)

const kit = await loadKit(cwd)

Expand Down
83 changes: 8 additions & 75 deletions packages/nuxi/src/commands/dev-child.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import type { NuxtDevContext, NuxtDevIPCMessage } from '../utils/dev'

import process from 'node:process'

import { defineCommand } from 'citty'
import defu from 'defu'
import { resolve } from 'pathe'
import { isTest } from 'std-env'

import { _getDevServerDefaults, _getDevServerOverrides, createNuxtDevServer } from '../utils/dev'
import { overrideEnv } from '../utils/env'
import { logger } from '../utils/logger'
import { cwdArgs, dotEnvArgs, envNameArgs, legacyRootDirArgs, logLevelArgs } from './_shared'

export default defineCommand({
Expand All @@ -23,80 +16,20 @@ export default defineCommand({
...envNameArgs,
...dotEnvArgs,
...legacyRootDirArgs,
clear: {
type: 'boolean',
description: 'Clear console on restart',
negativeDescription: 'Disable clear console on restart',
},
},
async run(ctx) {
if (!process.send && !isTest) {
logger.warn('`nuxi _dev` is an internal command and should not be used directly. Please use `nuxi dev` instead.')
console.warn('`nuxi _dev` is an internal command and should not be used directly. Please use `nuxi dev` instead.')
}

// Prepare
overrideEnv('development')
const cwd = resolve(ctx.args.cwd || ctx.args.rootDir)

// Get dev context info
const devContext: NuxtDevContext = JSON.parse(process.env.__NUXT_DEV__ || 'null') || {}

// IPC Hooks
function sendIPCMessage<T extends NuxtDevIPCMessage>(message: T) {
if (process.send) {
process.send(message)
}
else {
logger.info(
'Dev server event:',
Object.entries(message)
.map(e => `${e[0]}=${JSON.stringify(e[1])}`)
.join(' '),
)
}
}

process.once('unhandledRejection', (reason) => {
sendIPCMessage({ type: 'nuxt:internal:dev:rejection', message: reason instanceof Error ? reason.toString() : 'Unhandled Rejection' })
process.exit()
})

const devServerOverrides = _getDevServerOverrides({
public: devContext.public,
})

const devServerDefaults = _getDevServerDefaults({
hostname: devContext.hostname,
https: devContext.proxy?.https,
}, devContext.publicURLs)

// Init Nuxt dev
const nuxtDev = await createNuxtDevServer({
cwd,
overrides: defu(ctx.data?.overrides, devServerOverrides),
defaults: devServerDefaults,
logLevel: ctx.args.logLevel as 'silent' | 'info' | 'verbose',
clear: !!ctx.args.clear,
dotenv: { cwd, fileName: ctx.args.dotenv },
envName: ctx.args.envName,
port: process.env._PORT ?? undefined,
devContext,
})

nuxtDev.on('loading:error', (_error) => {
sendIPCMessage({ type: 'nuxt:internal:dev:loading:error', error: {
message: _error.message,
stack: _error.stack,
name: _error.name,
code: _error.code,
} })
})
nuxtDev.on('loading', (message) => {
sendIPCMessage({ type: 'nuxt:internal:dev:loading', message })
})
nuxtDev.on('restart', () => {
sendIPCMessage({ type: 'nuxt:internal:dev:restart' })
})
nuxtDev.on('ready', (payload) => {
sendIPCMessage({ type: 'nuxt:internal:dev:ready', port: payload.port })
})

// Init server
await nuxtDev.init()
const { initialize } = await import('../dev')
await initialize({ cwd, args: ctx.args }, ctx)
},
})
Loading
Loading