Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nuxt/cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.23.0
Choose a base ref
...
head repository: nuxt/cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.23.1
Choose a head ref
  • 6 commits
  • 14 files changed
  • 3 contributors

Commits on Mar 17, 2025

  1. chore: remove nitropack-nightly resolution

    danielroe committed Mar 17, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    00aa479 View commit details
  2. fix(dev): use nitro to render errors thrown while loading (#794)

    danielroe authored Mar 17, 2025
    Copy the full SHA
    aa02649 View commit details
  3. chore(deps): update all non-major dependencies (#791)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    Co-authored-by: Daniel Roe <daniel@roe.dev>
    renovate[bot] and danielroe authored Mar 17, 2025
    Copy the full SHA
    f7399db View commit details

Commits on Mar 18, 2025

  1. fix(dev): allow overriding inferred cors/allowedHosts config (#795)

    danielroe authored Mar 18, 2025
    Copy the full SHA
    b38656f View commit details
  2. chore(deps): update dependency consola to ^3.4.2 (#796)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Mar 18, 2025
    Copy the full SHA
    d5606a8 View commit details
  3. v3.23.1

    github-actions[bot] authored Mar 18, 2025
    Copy the full SHA
    2147058 View commit details
2 changes: 1 addition & 1 deletion .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ jobs:
with:
fetch-depth: 0
- run: npm i -g --force corepack && corepack enable
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: lts/*
cache: pnpm
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ jobs:
with:
fetch-depth: 0
- run: npm i -g --force corepack && corepack enable
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: lts/*
cache: pnpm
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ jobs:
with:
fetch-depth: 0
- run: npm i -g --force corepack && corepack enable
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: lts/*
cache: pnpm
@@ -76,7 +76,7 @@ jobs:
with:
fetch-depth: 0
- run: npm i -g --force corepack && corepack enable
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: lts/*
cache: pnpm
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ jobs:
with:
fetch-depth: 0
- run: npm i -g --force corepack && corepack enable
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: lts/*
registry-url: 'https://registry.npmjs.org/'
4 changes: 2 additions & 2 deletions .github/workflows/size.yml
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: npm i -g --force corepack && corepack enable
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: lts/*
cache: pnpm
@@ -50,7 +50,7 @@ jobs:
with:
ref: ${{ github.base_ref }}
- run: npm i -g --force corepack && corepack enable
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: lts/*
cache: pnpm
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"name": "nuxi-workspace",
"type": "module",
"private": true,
"packageManager": "pnpm@10.6.2",
"packageManager": "pnpm@10.6.4",
"description": "⚡️ Nuxt Generation CLI Experience",
"license": "MIT",
"repository": "nuxt/cli",
@@ -21,20 +21,20 @@
"test:unit": "vitest --coverage"
},
"devDependencies": {
"@antfu/eslint-config": "^4.8.1",
"@antfu/eslint-config": "^4.10.1",
"@nuxt/eslint-config": "^1.2.0",
"@types/node": "^22.13.10",
"@types/semver": "^7.5.8",
"@vitest/coverage-v8": "^3.0.8",
"@vitest/coverage-v8": "^3.0.9",
"changelogen": "^0.6.1",
"eslint": "^9.22.0",
"knip": "^5.45.0",
"pkg-pr-new": "^0.0.40",
"knip": "^5.46.0",
"pkg-pr-new": "^0.0.41",
"semver": "^7.7.1",
"std-env": "^3.8.1",
"tinyexec": "^0.3.2",
"typescript": "^5.8.2",
"vitest": "^3.0.8",
"vitest": "^3.0.9",
"vue": "^3.5.13"
},
"resolutions": {
@@ -43,7 +43,6 @@
"create-nuxt": "workspace:*",
"create-nuxt-app": "workspace:*",
"h3": "^1.15.1",
"nitropack": "npm:nitropack-nightly",
"nuxi": "workspace:*"
}
}
4 changes: 2 additions & 2 deletions packages/create-nuxt/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-nuxt",
"type": "module",
"version": "3.23.0",
"version": "3.23.1",
"description": "Create a Nuxt app in seconds",
"license": "MIT",
"repository": {
@@ -34,7 +34,7 @@
},
"devDependencies": {
"@types/node": "^22.13.10",
"rollup": "^4.35.0",
"rollup": "^4.36.0",
"rollup-plugin-visualizer": "^5.14.0",
"typescript": "^5.8.2",
"unbuild": "^3.5.0",
8 changes: 4 additions & 4 deletions packages/nuxi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nuxi",
"type": "module",
"version": "3.23.0",
"version": "3.23.1",
"description": "Nuxt CLI",
"license": "MIT",
"repository": {
@@ -48,7 +48,7 @@
"chokidar": "^4.0.3",
"citty": "^0.1.6",
"clipboardy": "^4.0.0",
"consola": "^3.4.0",
"consola": "^3.4.2",
"defu": "^6.1.4",
"fuse.js": "^7.1.0",
"giget": "^2.0.0",
@@ -64,7 +64,7 @@
"pathe": "^2.0.3",
"perfect-debounce": "^1.0.0",
"pkg-types": "^2.1.0",
"rollup": "^4.35.0",
"rollup": "^4.36.0",
"rollup-plugin-visualizer": "^5.14.0",
"scule": "^1.3.0",
"semver": "^7.7.1",
@@ -74,6 +74,6 @@
"ufo": "^1.5.4",
"unbuild": "^3.5.0",
"unplugin-purge-polyfills": "^0.0.7",
"vitest": "^3.0.8"
"vitest": "^3.0.9"
}
}
15 changes: 9 additions & 6 deletions packages/nuxi/src/commands/dev-child.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import defu from 'defu'
import { resolve } from 'pathe'
import { isTest } from 'std-env'

import { _getDevServerOverrides, createNuxtDevServer } from '../utils/dev'
import { _getDevServerDefaults, _getDevServerOverrides, createNuxtDevServer } from '../utils/dev'
import { overrideEnv } from '../utils/env'
import { logger } from '../utils/logger'
import { cwdArgs, envNameArgs, legacyRootDirArgs, logLevelArgs } from './_shared'
@@ -55,17 +55,20 @@ export default defineCommand({
process.exit()
})

ctx.data ||= {}
ctx.data.overrides = defu(ctx.data.overrides, _getDevServerOverrides({
hostname: devContext.hostname,
const devServerOverrides = _getDevServerOverrides({
public: devContext.public,
})

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

// Init Nuxt dev
const nuxtDev = await createNuxtDevServer({
cwd,
overrides: ctx.data?.overrides,
overrides: defu(ctx.data?.overrides, devServerOverrides),
defaults: devServerDefaults,
logLevel: ctx.args.logLevel as 'silent' | 'info' | 'verbose',
clear: !!ctx.args.clear,
dotenv: !!ctx.args.dotenv,
16 changes: 12 additions & 4 deletions packages/nuxi/src/commands/dev.ts
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ import { satisfies } from 'semver'

import { isBun, isTest } from 'std-env'
import { showVersions } from '../utils/banner'
import { _getDevServerOverrides } from '../utils/dev'
import { _getDevServerDefaults, _getDevServerOverrides } from '../utils/dev'
import { overrideEnv } from '../utils/env'
import { loadKit } from '../utils/kit'
import { logger } from '../utils/logger'
@@ -80,12 +80,20 @@ const command = defineCommand({
// Directly start Nuxt dev
const { createNuxtDevServer } = await import('../utils/dev')

ctx.data ||= {}
ctx.data.overrides = defu(ctx.data.overrides, _getDevServerOverrides(listenOptions))
const devServerOverrides = _getDevServerOverrides({
public: listenOptions.public,
})

const devServerDefaults = _getDevServerDefaults({
hostname: listenOptions.hostname,
https: listenOptions.https,
})

const devServer = await createNuxtDevServer(
{
cwd,
overrides: ctx.data?.overrides,
overrides: defu(ctx.data?.overrides, devServerOverrides),
defaults: devServerDefaults,
logLevel: ctx.args.logLevel as 'silent' | 'info' | 'verbose',
clear: ctx.args.clear,
dotenv: !!ctx.args.dotenv,
46 changes: 25 additions & 21 deletions packages/nuxi/src/utils/dev.ts
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ import { createJiti } from 'jiti'
import { listen } from 'listhen'
import { join, relative, resolve } from 'pathe'
import { debounce } from 'perfect-debounce'
import { provider } from 'std-env'
import { joinURL } from 'ufo'

import { clearBuildDir } from '../utils/fs'
@@ -45,6 +46,7 @@ interface NuxtDevServerOptions {
dotenv: boolean
envName: string
clear: boolean
defaults: NuxtConfig
overrides: NuxtConfig
port?: string | number
loadingTemplate?: ({ loading }: { loading: string }) => string
@@ -121,15 +123,15 @@ class NuxtDevServer extends EventEmitter {
this._handler(req, res)
}
else {
this._renderError(res)
this._renderLoadingScreen(res)
}
}

// @ts-expect-error we set it in wrapper function
this.listener = undefined
}

async _renderError(res: ServerResponse, _error?: Error) {
async _renderLoadingScreen(res: ServerResponse) {
res.statusCode = 503
res.setHeader('Content-Type', 'text/html')
const loadingTemplate
@@ -139,7 +141,7 @@ class NuxtDevServer extends EventEmitter {
|| ((params: { loading: string }) => `<h2>${params.loading}</h2>`)
res.end(
loadingTemplate({
loading: _error?.toString() || this._loadingMessage || 'Loading...',
loading: this._loadingMessage || 'Loading...',
}),
)
}
@@ -180,19 +182,16 @@ class NuxtDevServer extends EventEmitter {

const kit = await loadKit(this.options.cwd)

this.options.overrides = defu(this.options.overrides, _getDevServerOverrides({}, await this.listener.getURLs().then(r => r.map(r => r.url))))
const devServerDefaults = _getDevServerDefaults({}, await this.listener.getURLs().then(r => r.map(r => r.url)))

this._currentNuxt = await kit.loadNuxt({
cwd: this.options.cwd,
dev: true,
ready: false,
envName: this.options.envName,
defaults: defu(this.options.defaults, devServerDefaults),
overrides: {
logLevel: this.options.logLevel as 'silent' | 'info' | 'verbose',
nitro: {
devErrorHandler: (error, event) => {
this._renderError(event.node.res, error)
},
},
...this.options.overrides,
vite: {
clearScreen: this.options.clear,
@@ -346,25 +345,30 @@ function _getAddressURL(addr: AddressInfo, https: boolean) {
return `${proto}://${host}:${port}/`
}

export function _getDevServerOverrides(listenOptions: Partial<Pick<ListenOptions, 'hostname' | 'public' | 'https'>>, urls: string[] = []) {
const defaultOverrides: Partial<NuxtConfig> = {}
export function _getDevServerOverrides(listenOptions: Partial<Pick<ListenOptions, 'public'>>) {
if (listenOptions.public || provider === 'codesandbox') {
return {
devServer: { cors: { origin: '*' } },
vite: { server: { allowedHosts: true } },
}
}

return {}
}

export function _getDevServerDefaults(listenOptions: Partial<Pick<ListenOptions, 'hostname' | 'https'>>, urls: string[] = []) {
const defaultConfig: Partial<NuxtConfig> = {}

if (urls) {
defaultOverrides.vite = { server: { allowedHosts: urls.map(u => new URL(u).hostname) } }
defaultConfig.vite = { server: { allowedHosts: urls.map(u => new URL(u).hostname) } }
}

// defined hostname
if (listenOptions.hostname) {
const protocol = listenOptions.https ? 'https' : 'http'
defaultOverrides.devServer = { cors: { origin: [`${protocol}://${listenOptions.hostname}`, ...urls] } }
defaultOverrides.vite = defu(defaultOverrides.vite, { server: { allowedHosts: [listenOptions.hostname] } })
}

// TODO: https://github.com/unjs/std-env/pull/154
if (listenOptions.public || process.env.CODESANDBOX_HOST) {
defaultOverrides.devServer = { cors: { origin: '*' } }
defaultOverrides.vite = { server: { allowedHosts: true } }
defaultConfig.devServer = { cors: { origin: [`${protocol}://${listenOptions.hostname}`, ...urls] } }
defaultConfig.vite = defu(defaultConfig.vite, { server: { allowedHosts: [listenOptions.hostname] } })
}

return defaultOverrides
return defaultConfig
}
8 changes: 4 additions & 4 deletions packages/nuxt-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nuxt/cli",
"type": "module",
"version": "3.23.0",
"version": "3.23.1",
"description": "Nuxt CLI",
"license": "MIT",
"repository": {
@@ -37,7 +37,7 @@
"chokidar": "^4.0.3",
"citty": "^0.1.6",
"clipboardy": "^4.0.0",
"consola": "^3.4.0",
"consola": "^3.4.2",
"defu": "^6.1.4",
"fuse.js": "^7.1.0",
"giget": "^2.0.0",
@@ -59,11 +59,11 @@
},
"devDependencies": {
"@types/node": "^22.13.10",
"rollup": "^4.35.0",
"rollup": "^4.36.0",
"rollup-plugin-visualizer": "^5.14.0",
"typescript": "^5.8.2",
"unbuild": "^3.5.0",
"unplugin-purge-polyfills": "^0.0.7",
"vitest": "^3.0.8"
"vitest": "^3.0.9"
}
}
2 changes: 1 addition & 1 deletion packages/nuxt-cli/playground/package.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"name": "nuxt-cli-playground",
"version": "1.0.0",
"private": true,
"packageManager": "pnpm@10.6.2",
"packageManager": "pnpm@10.6.4",
"dependencies": {
"nuxt": "^3.16.0"
}
Loading