Follow-up to #1475 / #1559. The attribute rename (data-vinext-head → data-next-head) was split into #1559 as a small isolated patch. Two other parts of #1475 remain and need their own work:
Problem (remaining parts)
1. charset/viewport ordering
Pages Router <Head> emission does not match Next.js's canonical order for charset and viewport tags. The Next.js e2e suite (test/e2e/next-head/index.test.ts) asserts that charset appears first, followed by viewport, then user tags — in that specific order. vinext currently emits them out of order.
2. _document.getInitialProps() head-tag merge
When a custom _document defines getInitialProps() and returns head tags via Head.rewind() / head: [...], those tags must be merged into the SSR HTML before the user's next/head tags. vinext currently does not call _document.getInitialProps() for head purposes at all, so downstream tag lookups in _document fail.
Reference
.nextjs-ref/test/e2e/next-head/index.test.ts — assertions on ordering and on _document.getInitialProps() merge
.nextjs-ref/packages/next/src/pages/_document.tsx — canonical merge logic
Estimated impact
~2 e2e test failures remaining after #1559.
Recommendation
- Reproduce in vinext's own test suite with a Pages Router fixture that imports
next/head plus a custom _document with getInitialProps(). Assert (a) charset/viewport ordering, (b) that _document.getInitialProps() head tags appear ahead of user next/head tags.
- Update
packages/vinext/src/shims/head.ts (or wherever head tags are aggregated for SSR) to:
- emit charset and viewport in Next.js's canonical position
- call the user's
_document.getInitialProps() (when defined) and merge its head output ahead of user next/head tags
- Mirror
.nextjs-ref/packages/next/src/pages/_document.tsx for the exact merge semantics.
Part of #1328.
Follow-up to #1475 / #1559. The attribute rename (
data-vinext-head→data-next-head) was split into #1559 as a small isolated patch. Two other parts of #1475 remain and need their own work:Problem (remaining parts)
1. charset/viewport ordering
Pages Router
<Head>emission does not match Next.js's canonical order for charset and viewport tags. The Next.js e2e suite (test/e2e/next-head/index.test.ts) asserts that charset appears first, followed by viewport, then user tags — in that specific order. vinext currently emits them out of order.2.
_document.getInitialProps()head-tag mergeWhen a custom
_documentdefinesgetInitialProps()and returns head tags viaHead.rewind()/head: [...], those tags must be merged into the SSR HTML before the user'snext/headtags. vinext currently does not call_document.getInitialProps()for head purposes at all, so downstream tag lookups in_documentfail.Reference
.nextjs-ref/test/e2e/next-head/index.test.ts— assertions on ordering and on_document.getInitialProps()merge.nextjs-ref/packages/next/src/pages/_document.tsx— canonical merge logicEstimated impact
~2 e2e test failures remaining after #1559.
Recommendation
next/headplus a custom_documentwithgetInitialProps(). Assert (a) charset/viewport ordering, (b) that_document.getInitialProps()head tags appear ahead of usernext/headtags.packages/vinext/src/shims/head.ts(or wherever head tags are aggregated for SSR) to:_document.getInitialProps()(when defined) and merge its head output ahead of usernext/headtags.nextjs-ref/packages/next/src/pages/_document.tsxfor the exact merge semantics.Part of #1328.