@@ -19,7 +19,11 @@ import {
1919 invalidateRouteCache ,
2020 matchRoute ,
2121} from "./routing/pages-router.js" ;
22- import { generateServerEntry as _generateServerEntry } from "./entries/pages-server-entry.js" ;
22+ import {
23+ generatePagesRequestEntry as _generatePagesRequestEntry ,
24+ generatePagesResponseEntry as _generatePagesResponseEntry ,
25+ generateServerEntry as _generateServerEntry ,
26+ } from "./entries/pages-server-entry.js" ;
2327import { generateClientEntry as _generateClientEntry } from "./entries/pages-client-entry.js" ;
2428import {
2529 appRouteGraph ,
@@ -50,7 +54,9 @@ import { createDirectRunner } from "./server/dev-module-runner.js";
5054import { generateRscEntry } from "./entries/app-rsc-entry.js" ;
5155import { generateSsrEntry } from "./entries/app-ssr-entry.js" ;
5256import {
57+ VIRTUAL_CDN_CACHE_ADAPTER ,
5358 VIRTUAL_CACHE_ADAPTERS ,
59+ generateCdnCacheAdapterModule ,
5460 generateCacheAdaptersModule ,
5561 hasVerbatimResponseVary ,
5662 VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY ,
@@ -1093,6 +1099,10 @@ const VIRTUAL_WORKER_ENTRY = "virtual:vinext-worker-entry";
10931099const RESOLVED_WORKER_ENTRY = VIRTUAL_PREFIX + VIRTUAL_WORKER_ENTRY ;
10941100const VIRTUAL_SERVER_ENTRY = "virtual:vinext-server-entry" ;
10951101const RESOLVED_SERVER_ENTRY = VIRTUAL_PREFIX + VIRTUAL_SERVER_ENTRY ;
1102+ const VIRTUAL_PAGES_REQUEST_ENTRY = "virtual:vinext-pages-request-entry" ;
1103+ const RESOLVED_PAGES_REQUEST_ENTRY = VIRTUAL_PREFIX + VIRTUAL_PAGES_REQUEST_ENTRY ;
1104+ const VIRTUAL_PAGES_RESPONSE_ENTRY = "virtual:vinext-pages-response-entry" ;
1105+ const RESOLVED_PAGES_RESPONSE_ENTRY = VIRTUAL_PREFIX + VIRTUAL_PAGES_RESPONSE_ENTRY ;
10961106const VIRTUAL_CLIENT_ENTRY = "virtual:vinext-client-entry" ;
10971107const RESOLVED_CLIENT_ENTRY = VIRTUAL_PREFIX + VIRTUAL_CLIENT_ENTRY ;
10981108const VIRTUAL_PAGES_CLIENT_ASSETS = "virtual:vinext-pages-client-assets" ;
@@ -1113,6 +1123,8 @@ const VIRTUAL_ROOT_PARAMS = "virtual:vinext-root-params";
11131123const RESOLVED_ROOT_PARAMS = VIRTUAL_PREFIX + VIRTUAL_ROOT_PARAMS ;
11141124/** Virtual module that registers config-driven cache adapters (see VinextOptions.cache). */
11151125const RESOLVED_CACHE_ADAPTERS = VIRTUAL_PREFIX + VIRTUAL_CACHE_ADAPTERS ;
1126+ /** CDN-only registrar kept out of the data-cache response graph. */
1127+ const RESOLVED_CDN_CACHE_ADAPTER = VIRTUAL_PREFIX + VIRTUAL_CDN_CACHE_ADAPTER ;
11161128/** Virtual module that registers the config-driven image optimizer (see VinextOptions.images). */
11171129const RESOLVED_IMAGE_ADAPTERS = VIRTUAL_PREFIX + VIRTUAL_IMAGE_ADAPTERS ;
11181130/** Virtual module for composed instrumentation-client bootstrap. */
@@ -1601,6 +1613,33 @@ export default function vinext(options: VinextOptions = {}): PluginOption[] {
16011613 ) ;
16021614 }
16031615
1616+ async function generatePagesRequestEntry ( configuredPublicDir : string | false ) : Promise < string > {
1617+ const publicFiles =
1618+ isServeCommand && devPublicFileRoutes
1619+ ? [ ...devPublicFileRoutes ] . sort ( )
1620+ : scanPublicFileRoutes ( root , configuredPublicDir === "" ? false : configuredPublicDir ) ;
1621+ return _generatePagesRequestEntry (
1622+ pagesDir ,
1623+ nextConfig ,
1624+ fileMatcher ,
1625+ middlewarePath ,
1626+ instrumentationPath ,
1627+ publicFiles ,
1628+ prerenderSecret ,
1629+ ) ;
1630+ }
1631+
1632+ function generatePagesResponseEntry ( ) : Promise < string > {
1633+ return _generatePagesResponseEntry (
1634+ pagesDir ,
1635+ nextConfig ,
1636+ fileMatcher ,
1637+ middlewarePath ,
1638+ instrumentationPath ,
1639+ prerenderSecret ,
1640+ ) ;
1641+ }
1642+
16041643 /**
16051644 * Generate the virtual client hydration entry module.
16061645 * This is the entry point for `vite build` (client bundle).
@@ -3962,10 +4001,18 @@ export default function vinext(options: VinextOptions = {}): PluginOption[] {
39624001
39634002 // Pages Router virtual modules
39644003 if ( cleanId === VIRTUAL_SERVER_ENTRY ) return RESOLVED_SERVER_ENTRY ;
4004+ if ( cleanId === VIRTUAL_PAGES_REQUEST_ENTRY ) return RESOLVED_PAGES_REQUEST_ENTRY ;
4005+ if ( cleanId === VIRTUAL_PAGES_RESPONSE_ENTRY ) return RESOLVED_PAGES_RESPONSE_ENTRY ;
39654006 if ( cleanId === VIRTUAL_CLIENT_ENTRY ) return RESOLVED_CLIENT_ENTRY ;
39664007 if ( cleanId . endsWith ( "/" + VIRTUAL_SERVER_ENTRY ) ) {
39674008 return RESOLVED_SERVER_ENTRY ;
39684009 }
4010+ if ( cleanId . endsWith ( "/" + VIRTUAL_PAGES_REQUEST_ENTRY ) ) {
4011+ return RESOLVED_PAGES_REQUEST_ENTRY ;
4012+ }
4013+ if ( cleanId . endsWith ( "/" + VIRTUAL_PAGES_RESPONSE_ENTRY ) ) {
4014+ return RESOLVED_PAGES_RESPONSE_ENTRY ;
4015+ }
39694016 if ( cleanId . endsWith ( "/" + VIRTUAL_CLIENT_ENTRY ) ) {
39704017 return RESOLVED_CLIENT_ENTRY ;
39714018 }
@@ -3992,6 +4039,12 @@ export default function vinext(options: VinextOptions = {}): PluginOption[] {
39924039 ) {
39934040 return RESOLVED_CACHE_ADAPTERS ;
39944041 }
4042+ if (
4043+ cleanId === VIRTUAL_CDN_CACHE_ADAPTER ||
4044+ cleanId . endsWith ( "/" + VIRTUAL_CDN_CACHE_ADAPTER )
4045+ ) {
4046+ return RESOLVED_CDN_CACHE_ADAPTER ;
4047+ }
39954048 if (
39964049 cleanId === VIRTUAL_IMAGE_ADAPTERS ||
39974050 cleanId . endsWith ( "/" + VIRTUAL_IMAGE_ADAPTERS )
@@ -4049,6 +4102,16 @@ export default function vinext(options: VinextOptions = {}): PluginOption[] {
40494102 this . environment . config . publicDir === "" ? false : this . environment . config . publicDir ,
40504103 ) ;
40514104 }
4105+ if ( id === RESOLVED_PAGES_REQUEST_ENTRY ) {
4106+ recordServerEntryLoad ( this . environment ?. name , id ) ;
4107+ return await generatePagesRequestEntry (
4108+ this . environment . config . publicDir === "" ? false : this . environment . config . publicDir ,
4109+ ) ;
4110+ }
4111+ if ( id === RESOLVED_PAGES_RESPONSE_ENTRY ) {
4112+ recordServerEntryLoad ( this . environment ?. name , id ) ;
4113+ return await generatePagesResponseEntry ( ) ;
4114+ }
40524115 if ( id === RESOLVED_CLIENT_ENTRY ) {
40534116 return await generateClientEntry ( ) ;
40544117 }
@@ -4180,6 +4243,9 @@ export default function vinext(options: VinextOptions = {}): PluginOption[] {
41804243 if ( id === RESOLVED_CACHE_ADAPTERS ) {
41814244 return generateCacheAdaptersModule ( options . cache ) ;
41824245 }
4246+ if ( id === RESOLVED_CDN_CACHE_ADAPTER ) {
4247+ return generateCdnCacheAdapterModule ( options . cache ) ;
4248+ }
41834249 if ( id === RESOLVED_IMAGE_ADAPTERS ) {
41844250 return generateImageAdaptersModule ( options . images ) ;
41854251 }
0 commit comments