From ef2e2464f033b9a4768da09c9da5e8065949d629 Mon Sep 17 00:00:00 2001 From: Harlan Wilton Date: Wed, 18 Nov 2026 16:07:32 +1100 Subject: [PATCH] fix(deps): key dependency patches by whole major A range such as ^2.13.4 still skips an older copy in the same major without a warning, which is the failure #702 fixed. Each patch now covers its whole major, so any copy takes the patch or fails install. The Vitest prefix alias for nitropack/runtime also caught the separate nitropack/runtime/meta export, which then failed to resolve, and a missing nitropack dependency would have fallen back to the hoisted copy without a warning. --- pnpm-lock.yaml | 6 +++--- pnpm-workspace.yaml | 13 ++++++------- vitest.config.ts | 15 +++++++++++---- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0e2a1813..04dd9c71 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -399,9 +399,9 @@ overrides: nuxt-ai-ready: 3.5.0 patchedDependencies: - hookable@^5.5.3: 3b44da13a743bfa2eab02aef7246065e4dfd56e9878c206f34b51322832cfb2c - hookable@^6.1.1: 7530364d493fa95257cb863d105ed55a1bb4b46d5c9a178a6d64cb73028ed344 - nitropack@^2.13.4: a99fd975a7a90d0358937d8bdc06a0df631a088825383710a2e3875c7cc0051a + hookable@5: 3b44da13a743bfa2eab02aef7246065e4dfd56e9878c206f34b51322832cfb2c + hookable@6: 7530364d493fa95257cb863d105ed55a1bb4b46d5c9a178a6d64cb73028ed344 + nitropack@2: a99fd975a7a90d0358937d8bdc06a0df631a088825383710a2e3875c7cc0051a importers: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index d0e8c3ff..286cf99b 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -266,14 +266,13 @@ packages: overrides: nuxt-ai-ready: 3.5.0 -# Key each patch by a version range, never an exact version. An exact key -# skips any other installed version without a warning: a Nuxt bump on -# 2026-11-12 added nitropack 2.13.6, and production shipped it unpatched. -# A range key patches every installed copy, or the install fails. +# Key each patch by a whole major. Any other key skips copies outside it +# silently: on 2026-11-12 an exact key shipped nitropack 2.13.6 unpatched. +# Every copy in the major takes the patch, or the install fails. patchedDependencies: - hookable@^5.5.3: patches/hookable@5.5.3.patch - hookable@^6.1.1: patches/hookable@6.patch - nitropack@^2.13.4: patches/nitropack@2.patch + hookable@5: patches/hookable@5.5.3.patch + hookable@6: patches/hookable@6.patch + nitropack@2: patches/nitropack@2.patch catalog: '@antfu/eslint-config': ^9.3.0 '@cloudflare/sandbox': 1.0.0 diff --git a/vitest.config.ts b/vitest.config.ts index 174ebd59..b2b04946 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,5 +1,5 @@ import type { ConfigEnv, TestProjectConfiguration, ViteUserConfig } from 'vitest/config' -import { realpathSync } from 'node:fs' +import { readFileSync, realpathSync } from 'node:fs' import { findPackageJSON } from 'node:module' import { availableParallelism } from 'node:os' import { dirname } from 'node:path' @@ -37,19 +37,26 @@ function isNuxtRuntimeEntry(file: string): boolean { * patched 2.13.4. The cache tests kept passing against 2.13.4, and production * shipped the unpatched cache (Sentry SKILLD-5A). */ -function shippedNitroRuntime(): string { +function shippedNitropack(): string { const packageOf = (specifier: string, from: string) => realpathSync(findPackageJSON(specifier, pathToFileURL(from))!) const nitroServer = packageOf('@nuxt/nitro-server', packageOf('nuxt', fileURLToPath(import.meta.url))) - return `${dirname(packageOf('nitropack', nitroServer))}/dist/runtime` + // Without its own dependency, Node falls back to pnpm's hoisted copy, which the build may not bundle. + if (!JSON.parse(readFileSync(nitroServer, 'utf8')).dependencies?.nitropack) + throw new Error('@nuxt/nitro-server no longer depends on nitropack. Point the nitropack aliases in vitest.config.ts at the copy the build bundles.') + return dirname(packageOf('nitropack', nitroServer)) } +const nitropack = shippedNitropack() + const nuxtVitestConfig = defineVitestConfig({ resolve: { // Keep the object form: `defineVitestConfig` merges Nuxt's own aliases // (`#app`, `#imports`) into an object and drops them from an array. alias: { '#checkin/checks': fileURLToPath(new URL('./test/fixtures/checkin-registry.ts', import.meta.url)), - 'nitropack/runtime': shippedNitroRuntime(), + // A prefix alias also matches `nitropack/runtime/meta`, a separate export, so map it first. + 'nitropack/runtime/meta': `${nitropack}/runtime-meta.mjs`, + 'nitropack/runtime': `${nitropack}/dist/runtime`, }, }, test: {