fix(image): emit /_next/image URLs#1562
Conversation
Closes #1513 The default image loader and optimization endpoint switched from the vinext-specific /_vinext/image path to Next.js's canonical /_next/image. This unblocks the deploy suite tests that import Next.js's expected URL shape (/_next/image?url=...&w=...&q=...).
|
/bigbonk review |
commit: |
|
There was a problem hiding this comment.
Clean, mechanical rename — LGTM.
Verified:
- Zero remaining
/_vinext/imagereferences in production code. The 3 remaining occurrences intests/image-component.test.tsare intentional negative assertions (regression guards for #1513). IMAGE_OPTIMIZATION_PATHconstant updated correctly.- TPR filter change in
tpr.tsis correct: the old single-underscore/_vinext/prefix no longer exists anywhere in the codebase, so replacing it with/__vinext/(double underscore, used for internal prerender endpoints) keeps the filter accurate. - All hardcoded comparison sites (
index.ts,deploy.ts,app-rsc-handler.ts) are updated consistently.
One minor observation (not blocking): index.ts:2800, deploy.ts:505,641, and app-rsc-handler.ts:447 hardcode "/_next/image" instead of importing IMAGE_OPTIMIZATION_PATH. prod-server.ts already uses the constant. Not worth blocking on since this PR is a focused rename, but worth consolidating later to avoid future drift.
|
Review posted and approved on PR #1562. Here's the summary: Approved — clean, mechanical rename with no issues found. Key things verified:
Left a non-blocking note about consolidating the hardcoded |
…ll sites Replace hardcoded "/_next/image" strings in index.ts, app-rsc-handler.ts, and the generated worker entry templates in deploy.ts with the IMAGE_OPTIMIZATION_PATH constant from server/image-optimization, matching the pattern already used in prod-server.ts. Prevents future drift if the path ever changes again.
…izer Add a VINEXT_IMAGE_OPTIMIZATION_PATH constant and an isImageOptimizationPath() helper, then route through every match site (prod-server, dev server passthrough, app RSC handler, generated worker templates, and shipped example workers). Apps that wire image URLs to either prefix now hit the same handler; new URLs are still emitted via IMAGE_OPTIMIZATION_PATH.
|
/bigbonk review |
There was a problem hiding this comment.
LGTM — clean rename with good backward compatibility.
What changed across the 3 commits:
- Commit 1 (
8092463): Mechanical rename from/_vinext/imageto/_next/imageacross all production code, examples, and tests. - Commit 2 (
51c7cef): Consolidates the remaining hardcoded"/_next/image"strings inindex.ts,app-rsc-handler.ts, anddeploy.tsto useisImageOptimizationPath()— addressing the non-blocking note from the first review. - Commit 3 (
caa2906): AddsVINEXT_IMAGE_OPTIMIZATION_PATHconstant andisImageOptimizationPath()helper to accept both/_next/imageand/_vinext/imageat all match sites, providing backward compat for apps wired to the old prefix.
Verified:
- Zero hardcoded
"/_next/image"or"/_vinext/image"string comparisons remain in production code outsideimage-optimization.ts. All match sites useisImageOptimizationPath(). imageOptimizationUrl()inshims/image.tsx:274correctly emits/_next/imagefor newly generated URLs — only the server-side acceptors are dual-path.tpr.ts:468filter change is correct: old/_vinext/prefix (single underscore) no longer exists in the codebase; replaced with/__vinext/(double underscore) which is the internal prerender endpoint prefix used throughoutbuild/prerender.ts,server/prod-server.ts,server/pages-i18n.ts, andserver/app-rsc-request-normalization.ts.- The
/_next/filter intpr.tsnow covers the image optimization path since it was renamed from/_vinext/imageto/_next/image. - All remaining
/_vinext/imagereferences (10 total) are in test files — either testing the backward-compat alias, assertingVINEXT_IMAGE_OPTIMIZATION_PATH, or negative assertions guarding against regression (#1513). - The
isImageOptimizationPathhelper correctly uses strict equality (no prefix matching) so it won't accidentally match/_next/image.pngor/_next/image/. - Worker entry examples (
apps/web,app-router-cloudflare,app-router-playground) and generated entries (deploy.ts) all switched from inline string comparison to the helper import.
CI is green on all completed checks (Check, E2E, deploys, smoke tests). Vitest shards still in progress but no concerns given the mechanical nature of the changes.
|
Review posted and approved on PR #1562. Summary: This is a well-structured 3-commit PR that renames the image optimization endpoint from |
Refs #1513 — URL prefix rename only. Follow-up issue: #1570.
Summary
next/imageloader, optimization endpoint route match, and generated Cloudflare Workers entries from/_vinext/imageto/_next/imageso emitted URLs and the server route match Next.js canonical behavior.IMAGE_OPTIMIZATION_PATHconstant now exports/_next/image.apps/web,examples/app-router-cloudflare,examples/app-router-playground) and README updated to the new prefix.Out of scope (tracked in #1570)
/_next/image(or Cloudflare Images proxy). The endpoint currently still returns 400 /text/html; only the URL rename is in this PR.Do not close #1513 when this PR merges — close it when #1570 also lands.
Test plan
tests/image-component.test.ts→ "default loader emits /_next/image URLs (issuenext/image: default loader emits/_vinext/imageinstead of/_next/imageoptimization endpoint #1513)") assertingimageOptimizationUrl()and<Image>SSR src use the/_next/imageprefix.tests/shims.test.ts,tests/image-component.test.ts,tests/image-optimization-parity.test.ts,tests/deploy.test.ts, andtests/pages-router.test.ts.vp checkpasses.