Repository navigation
Conversation
Exploration of nuxt/content-v4-temp#42 on nuxt.com: `@nuxt/content` v4 owns nuxt.com's own content (`site`) in `server/content.ts`, as a live surface. The app reads it through the module's `content` client and renders documents with `<ContentDocument>`. The docs, cli, examples and module docs instances stay on comark-content. - `live.ref` resolves `site` through the same ref pointers as the other instances (`resolveInstanceSha('site')`), so a content-only push is served once the push webhook moves the pointer, without a deployment. The webhook also pins its own process with `revalidateContent()`. - The module ships `site`'s build snapshot, stamped with the commit resolved on build; `modules/snapshot` skips `site`. - The module's copy of `server/content.ts` (types, dev) reads the checkout. - Patch nuxt-agent-discovery 0.8.2 to accept `@nuxt/content` v4. Amp-Thread-ID: https://ampcode.com/threads/T-01a1ba1f-8ebe-766e-8f0e-204cf68f9904
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…surfaces Amp-Thread-ID: https://ampcode.com/threads/T-01a1ba1f-8ebe-766e-8f0e-204cf68f9904 # Conflicts: # pnpm-lock.yaml
Bundle sizeClient 1.38 MB
And 330 more routes. Largest changes in the client
And 60 more packages or files. Largest changes in the server
And 105 more packages or files. Brotli sizes. Changes under 100 B are left out of the tables. Initial page load counts the JavaScript and CSS a route loads before it renders. Measured by nuxt-bundle-analyzer for |
The preview build of nuxt/content-v4-temp#42 at fbc7204 calls `live.ref` on every request, and drops `ttl`, `live: true` and pinning a commit through `revalidateContent()`. `site` now has one `live: { ref }` outside dev. The module's copy of `server/content.ts` no longer calls `ref`, so it doesn't need its own `live: true`. The push webhook is back to what it is on `main`: it warms a separate instance at the pushed commit. It read the instance `@nuxt/content` serves `site` from and disposed it after warming it. Amp-Thread-ID: https://ampcode.com/threads/T-01a1eec3-272f-75f4-b9d7-264930c267d0
The preview build of nuxt/content-v4-temp#42 at 3744e90 includes #58: `createNuxtContent()` returns an instance typed by its `name`, so `content.withRef()` and `resolveContent(content)` need no cast. `content` is imported from `server/content.ts` instead of auto-imported: the app tsconfig also checks this file through Nitro's auto-import types, and there `content` is the browser client. The functions returning `site` return `AnyComarkContent`, since an instance named `site` isn't assignable to a `ComarkContent` named `string`. Amp-Thread-ID: https://ampcode.com/threads/T-01a1eec3-272f-75f4-b9d7-264930c267d0
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Exploration, not for merge. It tries nuxt/content-v4-temp#42 (live content surfaces) on nuxt.com, through its preview build
@nuxt/content4@3744e90, which also includes nuxt/content-v4-temp#58 (createNuxtContent()typed byname). It doesn't touch #2621.The first attempt to move
siteto Nuxt Content v4 was reverted: the module bundledsitewith the build, andvercel.jsonskips deploys for content-only pushes, so those edits never went live. With #42,siteis a live surface: each request is served at the commitmain's content last changed in, and a cold start hydrates from a build snapshot stamped with a commit.What changed
server/content.ts:siteis the module'scontentexport, withlive.refresolving the commit through the same ref pointers as the other instances (resolveInstanceSha('site')).live.refon each request, so the pointer is read each time, asgetInstanceAtHead()does for the other instances.live.ref, andsiteis typed from its declared schema, so the generated types no longer list its paths.external-linksplugin, and atypegen:fieldhook to open the generated types.server/api/revalidate.post.ts): unchanged frommain, andsitestays in it. It moves the pointer, which every process reads on its next request, and warms a separate instance at the pushed commit.getInstanceAtHead('site')returnsresolveContent(content), andcontentInstanceAt('site', sha)returnscontent.withRef(sha).contentis typed as an instance namedsite. It's imported fromserver/content.ts, because the app tsconfig also checks this file through Nitro's auto-import types, wherecontentis the browser client.AnyComarkContent: an instance namedsiteisn't assignable to aComarkContentnamedstring.getInstanceAtHead()still returnsComarkContent.modules/snapshotskipssite: the module ships its snapshot.useContent('site')is the module's client, and documents render with<ContentDocument>.nuxt-agent-discovery@0.8.2is patched to accept@nuxt/contentv4.Evidence
From a local production build (
nuxt build, node-server preset) in an Amp orb, on 139bf45 with the preview buildfbc7204:/__nuxt_content/snapshot/site.jsonresolved the ref, so the snapshot is stamped with08b79481, the last commit that touchedcontent/onmain. It holds 182 items./blog/v4,/deploy/vercel,/enterprise/agencies,/design-kit,/team,/sponsors,/design.md,/raw/blog/v4.mdand/__nuxt_content/get/blog/v4.api.github.comrejected, a cold start still answers 200 for/blog/v4,/raw/blog/v4.mdand/__nuxt_content/get/blog/v4. The server logs once that it servessiteat08b79481, the snapshot's commit.pnpm test:types, the unit tests (78 files, 827 tests) and eslint on the changed files pass.3744e90:pnpm test:types, the unit tests (78 files, 827 tests) and eslint on the changed files pass. Not built locally; the Vercel build and e2e check it./, and the comparisons with production below.From the first build of this PR, with the preview build
6ca4a87:/raw/blog/v4.mdand/design.mdare byte-identical to production, with nonofollowadded./blog/v4renders like production in screenshots, and its links have the samerelvalues./wasn't checked either. It waits on npm's download-stats API, which rate-limited the orb (429).Found: content pages load more JavaScript
The bundle-size report on this PR builds
mainand this branch the same way and compares them (brotli). Client total: +73.4 kB (+5.6%). Initial page load:/enterprise/agencies/:slug()/deploy/:slug()/design-kit/docs/:slug(.*)*/blog/:slug()The likely cause is the module's component map, used by
<ContentDocument>. It statically imports everyapp/components/content/component, includingSandbox.vue(StackBlitz), while nuxt.com's per-pagemarkdownComponentsmaps only load what each page lists. In a local build,/blog/v4preloaded a StackBlitz chunk and a 224 kB three.js chunk that production doesn't. This comes from the v4 module's component map, not fromlive: withsitenot live, the preloads were about the same.An earlier version of this description said
/blog/v4preloads 3.6× more JavaScript. That compared a local node-server build against production, not like for like; the report above is the fair comparison.Still to do before nuxt.com could adopt v4
external-linkscan't be turned off,markdowncan't takelistingFields, and types are closed with an explicit schema.sitemoved. The docs, cli, examples and module docs instances could become extra live surfaces with their own base paths, which feat(auth): email login #42 supports. nuxt.com's routing, pull previews and l10n assume its own handlers, so that is a larger change.