Skip to content

fix(deps): add support for unhead v3#795

Merged
harlan-zw merged 5 commits into
mainfrom
fix/unhead-v3
May 27, 2026
Merged

fix(deps): add support for unhead v3#795
harlan-zw merged 5 commits into
mainfrom
fix/unhead-v3

Conversation

@danielroe
Copy link
Copy Markdown
Member

🔗 Linked issue

closes #703

📚 Description

this is an initial stab at making nuxt/scripts pass in ecosystem-ci with nuxt v4.5 (which contains unhead v3)

I've made a few guesses but feel free to scrap this!

@danielroe danielroe requested a review from harlan-zw May 26, 2026 08:54
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
scripts-playground Error Error May 27, 2026 3:43am

link: [
{
rel: props.loading === 'eager' ? 'preconnect' : 'dns-prefetch',
rel: (props.loading === 'eager' ? 'preconnect' : 'dns-prefetch') as 'preconnect',
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct? do we not support dns-prefetch as a rel value

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the type issue was from the .filter() / undefined href, these are both properly unionised

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 26, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/scripts@795

commit: c5c15e5

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

Widen @unhead/vue peer dependency to accept v3, remove an unused NitroConfig type import and its Nuxt schema augmentation, apply non-null assertions and explicit casts around head/hook access and Partytown script typing, adjust Google Maps server head injection to respect the signed proxy flag, migrate warmup tests to createHead({ disableDefaults: true }), and add workspace fixtures plus e2e/unit tests to validate Unhead v3 compatibility.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding support for unhead v3 by widening peer dependency constraints and updating composables to handle v3 type requirements.
Description check ✅ Passed The description is directly related to the changeset, explaining the goal of making nuxt/scripts compatible with Nuxt v4.5 which contains unhead v3.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/unhead-v3

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Backstops @unhead/vue v3 compatibility while the default workspace
install resolves to v2. Scoped pnpm override pins only this fixture to
v3; e2e + typecheck regression tests skip when the workspace root is
already on v3 (e.g. ecosystem-ci runs).
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/unit/unhead-v3-typecheck.test.ts`:
- Around line 50-71: The test currently swallows exec failures by only copying
err.stdout/err.stderr, which can hide non-TypeScript failures; update the catch
block in the test (the exec(...) try/catch around nuxt typecheck) to fail the
test when the process rejects but parseTypecheckErrors(`${stdout}\n${stderr}`)
returns no diagnostics: after capturing stdout/stderr, if the caught error is
truthy and parseTypecheckErrors yields an empty array, rethrow the original
error or call expect.fail with the err so the test does not produce a false
negative; keep references to exec, parseTypecheckErrors, KNOWN_BASELINE_ERRORS
and newErrors to locate where to change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9dfeef9e-9b79-495b-b8de-a5b5a8f164da

📥 Commits

Reviewing files that changed from the base of the PR and between 93f525f and c5c15e5.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • package.json
  • pnpm-workspace.yaml
  • test/e2e/unhead-v3-compat.test.ts
  • test/fixtures/unhead-v3/app.vue
  • test/fixtures/unhead-v3/nuxt.config.ts
  • test/fixtures/unhead-v3/package.json
  • test/unit/unhead-v3-typecheck.test.ts
✅ Files skipped from review due to trivial changes (1)
  • test/fixtures/unhead-v3/package.json

Comment on lines +50 to +71
try {
const res = await exec('pnpm', ['exec', 'nuxt', 'typecheck'], {
cwd: fixtureDir,
env: { ...process.env, FORCE_COLOR: '0' },
maxBuffer: 32 * 1024 * 1024,
})
stdout = res.stdout
stderr = res.stderr
}
catch (err: any) {
stdout = err.stdout || ''
stderr = err.stderr || ''
}

const errors = parseTypecheckErrors(`${stdout}\n${stderr}`)
const newErrors = errors.filter(e => !KNOWN_BASELINE_ERRORS.has(e))

expect(newErrors, [
'New type errors detected when typechecking the unhead-v3 fixture.',
'Either: (a) fix the source so it compiles against @unhead/vue@^3, or',
'(b) add the error to KNOWN_BASELINE_ERRORS with a comment explaining why.',
].join('\n')).toEqual([])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

ls -la
echo "--- file listing (target) ---"
ls -la test/unit/unhead-v3-typecheck.test.ts || true

echo "--- show file with line numbers (relevant range) ---"
nl -ba test/unit/unhead-v3-typecheck.test.ts | sed -n '1,220p'

echo "--- find parseTypecheckErrors definition/usages ---"
rg -n "function parseTypecheckErrors|parseTypecheckErrors\s*=" -S .
rg -n "parseTypecheckErrors\(" -S .

echo "--- find KNOWN_BASELINE_ERRORS definition ---"
rg -n "KNOWN_BASELINE_ERRORS" -S .

echo "--- find exec import/definition ---"
rg -n "import\s+\{\s*exec\s*\}|from ['\"].*['\"].*exec|exec\(" test/unit/unhead-v3-typecheck.test.ts
rg -n "from ['\"]child_process['\"][^;]*exec|promisify.*exec|function exec\(" -S .

Repository: nuxt/scripts

Length of output: 1982


🏁 Script executed:

#!/bin/bash
set -u

FILE="test/unit/unhead-v3-typecheck.test.ts"

echo "--- show relevant range with line numbers (python) ---"
python3 - <<'PY'
from pathlib import Path
p = Path("test/unit/unhead-v3-typecheck.test.ts")
lines = p.read_text(encoding="utf-8").splitlines()
start, end = 1, 140
for i in range(start, min(end, len(lines)) + 1):
    print(f"{i:4d} {lines[i-1]}")
PY

echo "--- show lines 40-100 exactly ---"
python3 - <<'PY'
from pathlib import Path
p = Path("test/unit/unhead-v3-typecheck.test.ts")
lines = p.read_text(encoding="utf-8").splitlines()
start, end = 35, 110
for i in range(start, min(end, len(lines)) + 1):
    print(f"{i:4d} {lines[i-1]}")
PY

echo "--- find parseTypecheckErrors definition/usages ---"
rg -n "parseTypecheckErrors" test/unit -S
rg -n "function parseTypecheckErrors|const parseTypecheckErrors|let parseTypecheckErrors" -S .

echo "--- find KNOWN_BASELINE_ERRORS definition/usages ---"
rg -n "KNOWN_BASELINE_ERRORS" -S .

echo "--- find exec import/definition in the test file and nearby helpers ---"
rg -n "from ['\"][^'\"]+['\"]" test/unit/unhead-v3-typecheck.test.ts -S
rg -n "exec" test/unit/unhead-v3-typecheck.test.ts -S
rg -n "import\s+\{\s*exec\s*\}|from ['\"].*['\"]\s*;?|\bfunction exec\b|\bconst exec\b|\bexec\s*=" -S .

Repository: nuxt/scripts

Length of output: 50369


Fail the test when nuxt typecheck rejects without producing TS diagnostics

The catch block only copies err.stdout/err.stderr into strings; if execFile fails for non-TypeScript reasons (no TS output), parseTypecheckErrors() returns [] (it filters only lines matching error TS\d+), making newErrors empty and the test pass as a false negative.

💡 Proposed fix
   it('introduces no new type errors when compiled against `@unhead/vue`@^3', async () => {
     let stdout = ''
     let stderr = ''
+    let execError: unknown = null
     try {
       const res = await exec('pnpm', ['exec', 'nuxt', 'typecheck'], {
         cwd: fixtureDir,
         env: { ...process.env, FORCE_COLOR: '0' },
         maxBuffer: 32 * 1024 * 1024,
@@
     }
     catch (err: any) {
+      execError = err
       stdout = err.stdout || ''
       stderr = err.stderr || ''
     }

     const errors = parseTypecheckErrors(`${stdout}\n${stderr}`)
+    if (execError && errors.length === 0) {
+      throw execError
+    }
     const newErrors = errors.filter(e => !KNOWN_BASELINE_ERRORS.has(e))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/unit/unhead-v3-typecheck.test.ts` around lines 50 - 71, The test
currently swallows exec failures by only copying err.stdout/err.stderr, which
can hide non-TypeScript failures; update the catch block in the test (the
exec(...) try/catch around nuxt typecheck) to fail the test when the process
rejects but parseTypecheckErrors(`${stdout}\n${stderr}`) returns no diagnostics:
after capturing stdout/stderr, if the caught error is truthy and
parseTypecheckErrors yields an empty array, rethrow the original error or call
expect.fail with the err so the test does not produce a false negative; keep
references to exec, parseTypecheckErrors, KNOWN_BASELINE_ERRORS and newErrors to
locate where to change.

@harlan-zw harlan-zw merged commit fefd9fe into main May 27, 2026
18 of 19 checks passed
@harlan-zw harlan-zw deleted the fix/unhead-v3 branch May 27, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants