Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fdd4677
fix(image): honor trailingSlash, fix custom-loader srcSet, support im…
AhmedElBanna80 Oct 3, 2026
aa3ae0d
test(image): update shims.test.ts custom-loader assertions for per-br…
AhmedElBanna80 Oct 4, 2026
7f7f69c
fix(image): wire images.loaderFile without a root test alias and matc…
james-elicx Oct 6, 2026
3f15479
Merge branch 'main' of https://github.com/cloudflare/vinext into pr-3686
james-elicx Oct 6, 2026
8323621
fix(image): match Next.js for configured loaders on fill, overrideSrc…
james-elicx Oct 6, 2026
db8b569
fix(image): skip custom loaders for inline sources and keep src after…
james-elicx Oct 6, 2026
b27f365
fix(image): match Next.js loaderFile resolution and scope it to next/…
james-elicx Oct 6, 2026
ea6fda7
fix(image): keep priority, data-nimg and blur styles on custom-loader…
james-elicx Oct 6, 2026
c08f0b3
fix(image): treat empty sources as unoptimized and ignore caller srcSet
james-elicx Oct 6, 2026
873ef69
refactor(image): share the unoptimized and custom loader render path
james-elicx Oct 7, 2026
c9602a2
Merge commit 'fc06b50345838ff94fdc54522ae078731b7cef91' into pr-3686-b
james-elicx Oct 7, 2026
d927ceb
fix(image): keep next/legacy/image from importing images.loaderFile
james-elicx Oct 7, 2026
17031ff
test(image): cover trailingSlash, loader srcSet and loaderFile in the…
james-elicx Oct 8, 2026
764c619
Merge branch 'main' of https://github.com/cloudflare/vinext into pr-3…
james-elicx Oct 8, 2026
9445847
fix(image): never send data:, blob: or empty sources through /_next/i…
james-elicx Oct 8, 2026
ba15bbc
fix(image): keep next/legacy/image layout rules for custom-loader srcSet
AhmedElBanna80 Oct 14, 2026
a82b0bd
Merge remote-tracking branch 'upstream/main' into fix/c3-image-shim-t…
AhmedElBanna80 Oct 14, 2026
7f7e313
Merge remote-tracking branch 'upstream/main' into fix/c3-image-shim-t…
AhmadElBanna80 Oct 14, 2026
5c1389a
Merge remote-tracking branch 'origin/main' into HEAD
AhmedElBanna80 Oct 15, 2026
254502d
chore: re-run CI (Windows create-next-app job hung)
AhmedElBanna80 Oct 15, 2026
7f9bbff
ci: retrigger (codspeed installer download failed)
AhmedElBanna80 Oct 17, 2026
eded672
Merge main into fix/c3-image-shim-trailing-slash-srcset
AhmedElBanna80 Oct 27, 2026
1b771e5
Merge remote-tracking branch 'upstream/main' into up-3686
AhmedElBanna80 Nov 1, 2026
aff2b14
Merge main into fix/c3-image-shim-trailing-slash-srcset
AhmedElBanna80 Nov 2, 2026
620528e
Merge remote-tracking branch 'upstream/main' into m-c3-image-shim-tra…
AhmedElBanna80 Nov 11, 2026
ad41a5f
fix(image): keep images.loaderFile out of next/legacy/image
AhmedElBanna80 Nov 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/vinext/src/build/client-build-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ const ROUTE_OWNED_CLIENT_SHIMS = new Set([
"dynamic-preload-chunks",
"form",
"image",
"image-base",
// Only image-props imports it. A group also takes in its modules'
// dependencies, so in "vinext" it would load ipaddr.js on every page.
"image-config",
"image-loader",
"image-props",
"internal/hybrid-client-route-owner",
"layout-segment-context",
Expand All @@ -43,7 +45,9 @@ const PAGE_OWNED_CLIENT_SHIMS = new Set([
"dynamic-preload-chunks",
"form",
"image",
"image-base",
"image-config",
"image-loader",
"image-props",
"legacy-image",
"offline",
Expand Down
2 changes: 1 addition & 1 deletion packages/vinext/src/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const CONFIG_SUPPORT: Record<string, { status: Status; detail?: string }> = {
images: {
status: "partial",
detail:
"remotePatterns, deviceSizes/imageSizes, qualities, localPatterns (production only) and SVG/CSP options honoured; resizing needs an optimizer via vinext({ images: { optimizer } }), images are served as-is otherwise; loader/loaderFile are ignored",
"remotePatterns, deviceSizes/imageSizes, qualities, localPatterns (production only), SVG/CSP options and loaderFile honoured; resizing needs an optimizer via vinext({ images: { optimizer } }), images are served as-is otherwise; the imgix/cloudinary/akamai loader presets are ignored",
},
allowedDevOrigins: { status: "supported", detail: "dev server cross-origin allowlist" },
output: {
Expand Down
4 changes: 4 additions & 0 deletions packages/vinext/src/config/next-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ export type NextConfig = {
headers?: () => Promise<NextHeader[]> | NextHeader[];
/** Image optimization config */
images?: {
/** Image loader. Defaults to "default"; only "default" and "custom" can be combined with `loaderFile`. */
loader?: "default" | "imgix" | "cloudinary" | "akamai" | "custom";
/** Path (relative to the project root) to a module whose default export is the image loader. */
loaderFile?: string;
remotePatterns?: Array<
| URL
| {
Expand Down
39 changes: 38 additions & 1 deletion packages/vinext/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1528,12 +1528,35 @@ const _appBrowserServerActionClientPath = resolveShimModulePath(
const _appRscCombinedHandlerPath = resolveShimModulePath(_serverDir, "app-rsc-combined-handler");
const _appRscHandlerPath = resolveShimModulePath(_serverDir, "app-rsc-handler");
const _pagesClientAssetsPath = resolveShimModulePath(_serverDir, "pages-client-assets");
const _imageLoaderFilePath = resolveShimModulePath(_shimsDir, "image-loader-file");
// Source checkouts resolve to TypeScript and must stay in Vite's graph so tests
// do not execute a stale dist build. Published packages resolve to emitted JS,
// which Node can load natively outside the RSC transform graph.
const _canExternalizeAppRscHandler =
_appRscHandlerPath.endsWith(".js") && _appRscCombinedHandlerPath.endsWith(".js");

/**
* Resolve the module behind `vinext/shims/image-loader-file`. Ported from
* Next.js's `images.loaderFile` normalization in server/config.ts: the file
* is used when `images.loader` is unset, "default" or "custom", and must exist.
*/
function resolveImageLoaderFile(images: NextConfig["images"], root: string): string {
const loaderFile = images?.loaderFile;
if (!loaderFile) return _imageLoaderFilePath;
Comment thread
AhmedElBanna80 marked this conversation as resolved.
Resolved
const loader = images.loader ?? "default";
if (loader !== "default" && loader !== "custom") {
throw new Error(
`Specified images.loader property (${loader}) cannot be used with images.loaderFile property. Please set images.loader to "custom".`,
);
}
// path.join (not resolve), as in Next.js: "/loader.js" is project-relative.
const absolutePath = path.join(root, loaderFile);
if (!fs.existsSync(absolutePath)) {
throw new Error(`Specified images.loaderFile does not exist at "${absolutePath}".`);
}
return absolutePath;
}

function isValidExportIdentifier(name: string): boolean {
return /^[$A-Z_a-z][$\w]*$/.test(name);
}
Expand Down Expand Up @@ -3279,6 +3302,14 @@ export default function vinext(options: VinextOptions = {}): PluginOption[] {
defines["process.env.__VINEXT_IMAGE_UNOPTIMIZED"] = JSON.stringify(
String(nextConfig.images?.unoptimized === true),
);
// images.loader / images.loaderFile modes the next/image shim validates
// against at render time (shims/image-props.ts, shims/image.tsx).
defines["process.env.__VINEXT_IMAGE_CUSTOM_LOADER"] = JSON.stringify(
String(nextConfig.images?.loader === "custom"),
);
defines["process.env.__VINEXT_IMAGE_LOADER_FILE"] = JSON.stringify(
String(Boolean(nextConfig.images?.loaderFile)),
);
// Build ID — resolved from next.config generateBuildId() or random UUID.
// Server entries read it, and it namespaces ISR cache keys so a
// previous deploy's entries are never served. The real value is a
Expand Down Expand Up @@ -3706,6 +3737,11 @@ export default function vinext(options: VinextOptions = {}): PluginOption[] {
...nextConfig.aliases,
...nextShimMap,
"vinext/server/pages-client-assets": _pagesClientAssetsPath,
// shims/image-loader.ts imports this slot for `images.loaderFile`.
// Like Next.js (which aliases next/dist/shared/lib/image-loader
// to the file), point it at the user's file, resolved against
// the project root; otherwise keep vinext's `undefined` default.
"vinext/shims/image-loader-file": resolveImageLoaderFile(nextConfig.images, root),
};
if (config.resolve) {
// Vite retains the inline resolve object for server.restart(). Do not
Expand Down Expand Up @@ -5530,7 +5566,8 @@ export default function vinext(options: VinextOptions = {}): PluginOption[] {
// gives plugin-rsc a package client reference, like vinext's other
// client shims.
return [
`export { getImageProps, imageOptimizationUrl } from "vinext/shims/image-props";`,
`export { getImageProps } from "vinext/shims/image-loader";`,
`export { imageOptimizationUrl } from "vinext/shims/image-props";`,
`export { default } from "vinext/shims/image";`,
"",
].join("\n");
Expand Down
Loading
Loading