@wular/pnext 0.0.4 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (395) hide show
  1. package/README.md +22 -16
  2. package/bin/pnext +6 -1
  3. package/config/lint/base.js +7 -7
  4. package/config/ts/base.json +2 -4
  5. package/config/ts/react.json +2 -6
  6. package/package.json +23 -2
  7. package/reference/compat.md +87 -22
  8. package/reference/config.md +40 -93
  9. package/reference/css.md +42 -33
  10. package/reference/dev.md +26 -33
  11. package/reference/env.md +18 -20
  12. package/reference/getting-started.md +132 -0
  13. package/reference/metadata.md +31 -46
  14. package/reference/navigation.md +65 -105
  15. package/reference/performance.md +21 -142
  16. package/reference/rendering.md +78 -75
  17. package/reference/routing.md +97 -107
  18. package/reference/typegen.md +27 -29
  19. package/src/api/cache.ts +36 -37
  20. package/src/api/client-cache.ts +2 -2
  21. package/src/api/client-navigation.ts +121 -114
  22. package/src/api/dynamic.tsx +58 -55
  23. package/src/api/link.tsx +52 -53
  24. package/src/api/navigation.ts +59 -58
  25. package/src/api/server.ts +152 -144
  26. package/src/api/suspense.ts +4 -4
  27. package/src/cli/adapters/vercel-warm.ts +126 -121
  28. package/src/cli/adapters/vercel.ts +437 -443
  29. package/src/cli/analyze.ts +333 -144
  30. package/src/cli/{named-bin.ts → boot/named-bin.ts} +37 -37
  31. package/src/cli/{boot-trace.ts → boot/trace.ts} +10 -10
  32. package/src/cli/build.ts +976 -978
  33. package/src/cli/create.ts +72 -64
  34. package/src/cli/dev.ts +116 -116
  35. package/src/cli/index.ts +94 -85
  36. package/src/cli/migrate/package-json.ts +73 -71
  37. package/src/cli/migrate/report.ts +32 -33
  38. package/src/cli/migrate/{index.ts → run.ts} +48 -49
  39. package/src/cli/migrate/scan.ts +46 -46
  40. package/src/cli/migrate/spinner.ts +9 -9
  41. package/src/cli/migrate/tsconfig.ts +35 -35
  42. package/src/cli/{server-entry.ts → serve/entry.ts} +57 -57
  43. package/src/cli/{request-pipeline.ts → serve/pipeline.ts} +386 -394
  44. package/src/cli/{serve-ui.ts → serve/ui.ts} +47 -47
  45. package/src/cli/start.ts +65 -66
  46. package/src/{typegen.ts → cli/typegen.ts} +59 -59
  47. package/src/client/build.ts +802 -768
  48. package/src/client/chunk-fold.ts +245 -240
  49. package/src/client/{paths.ts → chunk-name.ts} +6 -6
  50. package/src/client/entry.ts +162 -147
  51. package/src/client/prebuilt.ts +231 -223
  52. package/src/client/profile.ts +29 -29
  53. package/src/client/react-compiler.ts +20 -15
  54. package/src/client/{compat-surface.ts → react-tier.ts} +64 -64
  55. package/src/client/reference-stub.ts +51 -51
  56. package/src/client/reference.ts +19 -19
  57. package/src/{api → client}/router/events.ts +32 -17
  58. package/src/{api → client}/router/history.ts +16 -16
  59. package/src/{api → client}/router/hub.ts +52 -53
  60. package/src/{api/router.ts → client/router/index.ts} +61 -60
  61. package/src/{api → client}/router/policies.ts +24 -24
  62. package/src/{api → client}/router/runtime.ts +2022 -1995
  63. package/src/{api → client}/router/types.ts +98 -98
  64. package/src/compat/actions/client-plugin.ts +42 -43
  65. package/src/compat/actions/client-stub.ts +14 -14
  66. package/src/compat/actions/{action-client.ts → client.ts} +194 -193
  67. package/src/compat/actions/config.ts +63 -64
  68. package/src/compat/actions/detect.ts +68 -68
  69. package/src/compat/actions/discovery.ts +105 -105
  70. package/src/compat/actions/{action-dispatch.ts → dispatch.ts} +277 -274
  71. package/src/compat/actions/early-submit.ts +1 -1
  72. package/src/compat/actions/endpoint.ts +198 -198
  73. package/src/compat/actions/extensions.ts +811 -0
  74. package/src/compat/actions/flight.ts +23 -23
  75. package/src/compat/actions/form-state.ts +34 -34
  76. package/src/compat/actions/hoist.ts +382 -236
  77. package/src/compat/actions/ids.ts +7 -12
  78. package/src/compat/actions/index.ts +8 -8
  79. package/src/compat/actions/instances.ts +46 -46
  80. package/src/compat/actions/origin.ts +47 -48
  81. package/src/compat/actions/protocol.ts +22 -22
  82. package/src/compat/actions/registry.ts +19 -19
  83. package/src/compat/{misc/action-return.ts → actions/return.ts} +60 -57
  84. package/src/compat/actions/rewrite.ts +125 -125
  85. package/src/compat/actions/{action-router.ts → router.ts} +10 -10
  86. package/src/compat/actions/serve.ts +132 -136
  87. package/src/compat/actions/server-tag.ts +4 -4
  88. package/src/compat/actions/{action-shared.ts → shared.ts} +34 -34
  89. package/src/compat/actions/unrecognized-error.ts +4 -4
  90. package/src/compat/{index.ts → aliases.ts} +112 -109
  91. package/src/compat/bundler/bun-externals.ts +18 -18
  92. package/src/compat/bundler/cjs-exports.ts +271 -223
  93. package/src/compat/bundler/config.ts +116 -111
  94. package/src/compat/bundler/externals.ts +12 -12
  95. package/src/compat/bundler/import-meta-url.ts +19 -19
  96. package/src/compat/bundler/modularize-imports.ts +36 -33
  97. package/src/compat/bundler/new-url-asset.ts +22 -24
  98. package/src/compat/bundler/optimize-package-imports.ts +111 -107
  99. package/src/compat/bundler/polyfill.ts +28 -28
  100. package/src/compat/bundler/react-compiler.ts +35 -29
  101. package/src/compat/bundler/react-profiler.tsx +11 -11
  102. package/src/compat/bundler/relay-transform.ts +48 -47
  103. package/src/compat/bundler/require-context.ts +119 -113
  104. package/src/compat/bundler/resolve-extensions.ts +19 -19
  105. package/src/compat/bundler/source-cache.ts +25 -25
  106. package/src/compat/bundler/static-imports.ts +7 -7
  107. package/src/compat/bundler/symlink-imports.ts +46 -46
  108. package/src/compat/bundler/tsconfig-paths.ts +13 -15
  109. package/src/compat/bundler/wasm.ts +58 -60
  110. package/src/compat/bundler/webpack-loaders.ts +254 -241
  111. package/src/compat/bundler/worker.ts +101 -104
  112. package/src/compat/cache/build-flags.ts +29 -29
  113. package/src/compat/cache/build-prerender-errors.ts +40 -44
  114. package/src/compat/cache/custom-handler.ts +60 -53
  115. package/src/compat/cache/fetch-patch.ts +240 -240
  116. package/src/compat/cache/handler.ts +27 -31
  117. package/src/compat/cache/modern-handler.ts +148 -126
  118. package/src/compat/cache/resume-data-cache.ts +47 -45
  119. package/src/compat/cache/revalidate.ts +233 -232
  120. package/src/compat/cache/runtime-error.ts +35 -35
  121. package/src/compat/cache/use-cache-transform.ts +442 -417
  122. package/src/compat/cache/use-cache.ts +650 -614
  123. package/src/compat/cache-control.ts +140 -142
  124. package/src/compat/client/base-path.ts +21 -20
  125. package/src/compat/client/css-order.ts +18 -18
  126. package/src/compat/client/errors/bare-boundary.ts +11 -11
  127. package/src/compat/client/errors/control-flow.ts +23 -23
  128. package/src/compat/client/errors/error-boundary.ts +61 -61
  129. package/src/compat/client/errors/global-error.ts +101 -91
  130. package/src/compat/client/errors/install.ts +71 -72
  131. package/src/compat/client/errors/lazy.ts +23 -23
  132. package/src/compat/client/errors/primitive-throw.ts +47 -45
  133. package/src/compat/client/errors/soft-refresh.ts +4 -4
  134. package/src/compat/client/link-status.ts +33 -33
  135. package/src/compat/client/{nav-compat-runtime.ts → nav-runtime.ts} +20 -20
  136. package/src/compat/client/{nav-compat.ts → nav.ts} +12 -13
  137. package/src/compat/client/navigation-scroll.ts +63 -63
  138. package/src/compat/client/optimistic-routing.ts +93 -88
  139. package/src/compat/client/prefetch-cache.ts +23 -24
  140. package/src/compat/client/route-announcer.ts +35 -35
  141. package/src/compat/client/segment-cache-policy.ts +20 -20
  142. package/src/compat/client/segment-cache.ts +309 -315
  143. package/src/compat/client/segment-prefetch.ts +127 -132
  144. package/src/compat/client/trailing-slash.ts +5 -4
  145. package/src/compat/css/chunking.ts +113 -116
  146. package/src/compat/css/inline-css.ts +21 -21
  147. package/src/compat/css/lightningcss.ts +37 -38
  148. package/src/compat/css/modules.ts +161 -175
  149. package/src/compat/css/nonce.ts +7 -7
  150. package/src/compat/css/sass-plugin.ts +18 -21
  151. package/src/compat/css/sass.ts +150 -152
  152. package/src/compat/css/styled-jsx-runtime.ts +27 -27
  153. package/src/compat/css/styled-jsx.ts +21 -21
  154. package/src/compat/edge-runtime.ts +27 -27
  155. package/src/compat/{adapter → export}/build-complete.ts +72 -75
  156. package/src/compat/export/client.ts +29 -31
  157. package/src/compat/export/{index.ts → emit.ts} +111 -110
  158. package/src/compat/export/standalone.ts +62 -54
  159. package/src/compat/image-optimizer/cache.ts +51 -49
  160. package/src/compat/image-optimizer/detect.ts +52 -52
  161. package/src/compat/image-optimizer/{index.ts → optimize.ts} +189 -194
  162. package/src/compat/image-optimizer/source.ts +77 -80
  163. package/src/compat/lifecycle/after-scope.ts +26 -26
  164. package/src/compat/lifecycle/after.ts +48 -45
  165. package/src/compat/lifecycle/error-funnel.ts +98 -102
  166. package/src/compat/lifecycle/error-serialize.ts +30 -26
  167. package/src/compat/lifecycle/error-ui.ts +67 -32
  168. package/src/compat/lifecycle/instrumentation-client.ts +36 -38
  169. package/src/compat/lifecycle/instrumentation.ts +85 -85
  170. package/src/compat/lifecycle/node-console.ts +11 -11
  171. package/src/compat/lifecycle/testmode.ts +160 -132
  172. package/src/compat/mdx/compile.ts +60 -57
  173. package/src/compat/mdx/plugin.ts +11 -11
  174. package/src/compat/mdx/{next-mdx-stub.ts → stub.ts} +5 -5
  175. package/src/compat/{metadata-route-artifacts.ts → metadata-artifacts.ts} +195 -191
  176. package/src/compat/metadata.ts +75 -81
  177. package/src/compat/next/cache.ts +68 -69
  178. package/src/compat/next/canonical-url.ts +9 -9
  179. package/src/compat/next/client-cache.ts +19 -19
  180. package/src/compat/next/client-navigation.ts +112 -116
  181. package/src/compat/next/client-only.ts +1 -1
  182. package/src/compat/next/client-script.tsx +99 -93
  183. package/src/compat/next/client-server.ts +10 -10
  184. package/src/compat/next/config-loader.ts +176 -173
  185. package/src/compat/next/config.ts +7 -7
  186. package/src/compat/next/constants.cjs +6 -6
  187. package/src/compat/next/constants.ts +6 -6
  188. package/src/compat/next/custom-server.ts +26 -24
  189. package/src/compat/next/dist/client/components/app-router-headers.ts +21 -21
  190. package/src/compat/next/dist/server/app-render/work-unit-async-storage.external.cjs +3 -4
  191. package/src/compat/next/dist/server/web/spec-extension/revalidate.ts +1 -1
  192. package/src/compat/next/dist/server/web/spec-extension/unstable-cache.ts +1 -1
  193. package/src/compat/next/dist/server/web/spec-extension/unstable-no-store.ts +1 -1
  194. package/src/compat/next/dynamic.tsx +21 -18
  195. package/src/compat/next/error.tsx +52 -52
  196. package/src/compat/next/font/cache.ts +74 -74
  197. package/src/compat/next/font/google.ts +2 -2
  198. package/src/compat/next/font/index.ts +1 -1
  199. package/src/compat/next/font/local.ts +3 -3
  200. package/src/compat/next/font/runtime-client.ts +17 -15
  201. package/src/compat/next/font/runtime.ts +443 -408
  202. package/src/compat/next/font/shared.ts +120 -108
  203. package/src/compat/next/form.tsx +63 -63
  204. package/src/compat/next/head.tsx +2 -2
  205. package/src/compat/next/headers.ts +103 -95
  206. package/src/compat/next/image/client.tsx +220 -0
  207. package/src/compat/next/image/config.ts +56 -58
  208. package/src/compat/next/image/optimizer.ts +40 -36
  209. package/src/compat/next/image/patterns.ts +37 -40
  210. package/src/compat/next/{image-props.ts → image/props.ts} +208 -202
  211. package/src/compat/next/image/shared.ts +65 -57
  212. package/src/compat/next/image/static-metadata.ts +98 -107
  213. package/src/compat/next/image/validate.ts +79 -88
  214. package/src/compat/next/image.tsx +19 -23
  215. package/src/compat/next/index.ts +1 -1
  216. package/src/compat/next/legacy-image.tsx +59 -60
  217. package/src/compat/next/{link-validation-transform.ts → link-transform.ts} +95 -96
  218. package/src/compat/next/link.tsx +158 -158
  219. package/src/compat/next/navigation.cjs +12 -3
  220. package/src/compat/next/navigation.ts +48 -50
  221. package/src/compat/next/offline.ts +27 -27
  222. package/src/compat/next/og.ts +121 -124
  223. package/src/compat/next/preferred-region.ts +13 -14
  224. package/src/compat/next/redirects.ts +58 -56
  225. package/src/compat/next/resource-hints.ts +73 -76
  226. package/src/compat/next/rewrites.ts +130 -133
  227. package/src/compat/next/root-params.ts +45 -45
  228. package/src/compat/next/{optimistic-route-state.ts → route-state.ts} +52 -52
  229. package/src/compat/next/router.cjs +4 -2
  230. package/src/compat/next/router.ts +58 -61
  231. package/src/compat/next/script.tsx +108 -108
  232. package/src/compat/next/server-only.ts +1 -1
  233. package/src/compat/next/server.ts +19 -19
  234. package/src/compat/next/svgr.ts +18 -17
  235. package/src/compat/next/telemetry.ts +24 -24
  236. package/src/compat/next/{image-usage.ts → usage.ts} +70 -39
  237. package/src/compat/next/user-agent.ts +53 -49
  238. package/src/compat/next/web-vitals.ts +22 -24
  239. package/src/compat/otel/api.ts +41 -41
  240. package/src/compat/otel/client-trace-metadata.ts +25 -27
  241. package/src/compat/otel/fetch-span.ts +29 -29
  242. package/src/compat/otel/tracer.ts +331 -331
  243. package/src/compat/pages/api.ts +456 -0
  244. package/src/compat/pages/client-plugin.ts +36 -36
  245. package/src/compat/pages/router-state.ts +34 -34
  246. package/src/compat/pages/{index.ts → router.ts} +130 -135
  247. package/src/compat/ppr/io.ts +12 -12
  248. package/src/compat/ppr/missing-root-params.ts +34 -38
  249. package/src/compat/ppr/root-params-scan.ts +66 -66
  250. package/src/compat/ppr/root-params-transform.ts +24 -26
  251. package/src/compat/ppr/root-params.ts +30 -30
  252. package/src/compat/ppr/segment-config-incompat.ts +6 -7
  253. package/src/compat/protocol.ts +71 -70
  254. package/src/compat/react/action-state.ts +47 -48
  255. package/src/compat/react/client-lite.ts +15 -15
  256. package/src/compat/react/client.ts +4 -4
  257. package/src/compat/react/compiler-runtime.ts +11 -11
  258. package/src/compat/react/dom-client.ts +44 -44
  259. package/src/compat/react/dom-react-server.ts +10 -16
  260. package/src/compat/react/dom-server.ts +10 -10
  261. package/src/compat/react/dom.ts +52 -52
  262. package/src/compat/react/hooks-extra.ts +34 -35
  263. package/src/compat/react/parity.ts +64 -61
  264. package/src/compat/react/preact.ts +81 -82
  265. package/src/compat/react/react-server.ts +28 -28
  266. package/src/compat/react/router-shim.ts +1 -1
  267. package/src/compat/react/server-component-use.ts +8 -8
  268. package/src/compat/react/server-inserted-html.ts +30 -31
  269. package/src/compat/react/server.ts +53 -55
  270. package/src/compat/react/use.ts +32 -32
  271. package/src/compat/react/view-transition.ts +20 -20
  272. package/src/compat/register/actions.ts +35 -824
  273. package/src/compat/register/boot.ts +41 -41
  274. package/src/compat/register/build-tier.ts +5 -5
  275. package/src/compat/register/build.ts +74 -70
  276. package/src/compat/register/bundler.ts +161 -156
  277. package/src/compat/register/cache.ts +20 -20
  278. package/src/compat/register/client-errors.ts +3 -3
  279. package/src/compat/register/config.ts +6 -6
  280. package/src/compat/register/css-extras.ts +30 -34
  281. package/src/compat/register/edge-runtime.ts +3 -3
  282. package/src/compat/register/errors.ts +10 -12
  283. package/src/compat/register/export.ts +16 -16
  284. package/src/compat/register/font.ts +11 -11
  285. package/src/compat/register/hooks.ts +2 -2
  286. package/src/compat/register/image.ts +40 -40
  287. package/src/compat/register/index.ts +59 -62
  288. package/src/compat/register/instrumentation-client.ts +10 -10
  289. package/src/compat/register/lifecycle.ts +25 -28
  290. package/src/compat/register/mdx.ts +10 -10
  291. package/src/compat/register/middleware.ts +226 -16
  292. package/src/compat/register/otel.ts +80 -88
  293. package/src/compat/register/pages-api.ts +10 -463
  294. package/src/compat/register/ppr.ts +16 -16
  295. package/src/compat/register/protocol.ts +17 -18
  296. package/src/compat/register/proxy.ts +49 -51
  297. package/src/compat/register/render.ts +79 -76
  298. package/src/compat/register/routing.ts +162 -159
  299. package/src/compat/register/segment.ts +24 -1897
  300. package/src/compat/register/static-image.ts +3 -3
  301. package/src/compat/register/{misc.ts → taint.ts} +9 -9
  302. package/src/compat/register/typed-routes.ts +14 -14
  303. package/src/compat/register/{usecache.ts → use-cache.ts} +39 -39
  304. package/src/compat/register/validation.ts +18 -18
  305. package/src/compat/segment/loading-boundary.ts +43 -45
  306. package/src/compat/segment/page-slot.ts +69 -69
  307. package/src/compat/segment/serve.ts +1884 -0
  308. package/src/compat/segment/tree.ts +113 -112
  309. package/src/compat/segment/vary-key.ts +38 -38
  310. package/src/compat/segment/vary-params.ts +138 -142
  311. package/src/compat/static-params.ts +14 -12
  312. package/src/compat/tsconfig-defaults.ts +87 -91
  313. package/src/compat/typecheck/{index.ts → check.ts} +234 -212
  314. package/src/compat/typecheck/worker.ts +15 -12
  315. package/src/compat/typed-routes/{index.ts → generate.ts} +36 -36
  316. package/src/compat/typed-routes/manifest.ts +174 -170
  317. package/src/compat/typed-routes/typegen.ts +127 -110
  318. package/src/compat/validation/errors.ts +16 -19
  319. package/src/compat/validation/prerender-diagnostics.ts +521 -504
  320. package/src/compat/validation/{index.ts → validate.ts} +647 -648
  321. package/src/compat-bootstrap.ts +16 -16
  322. package/src/config.ts +86 -69
  323. package/src/css/build.ts +230 -227
  324. package/src/css/postcss.ts +79 -80
  325. package/src/css/worker.ts +14 -15
  326. package/src/dev/client-actions.ts +10 -10
  327. package/src/dev/client-chunk-store.ts +27 -27
  328. package/src/dev/{client-key-cache.ts → restart/client-key.ts} +76 -76
  329. package/src/dev/{restart-cache.ts → restart/enabled.ts} +1 -1
  330. package/src/dev/{global-css-cache.ts → restart/global-css.ts} +91 -83
  331. package/src/dev/{node-module-bundle-cache.ts → restart/node-modules.ts} +24 -24
  332. package/src/dev/{route-bundle-key-cache.ts → restart/route-bundle-key.ts} +53 -53
  333. package/src/dev/{route-facts-cache.ts → restart/route-facts.ts} +82 -82
  334. package/src/dev/server.ts +804 -820
  335. package/src/env.ts +46 -43
  336. package/src/extensions.ts +491 -478
  337. package/src/index.ts +8 -8
  338. package/src/internal.ts +20 -23
  339. package/src/{islands → render}/boundary-error.ts +3 -3
  340. package/src/render/hooks.ts +71 -71
  341. package/src/render/island-context.ts +14 -14
  342. package/src/render/metadata.ts +310 -310
  343. package/src/{ppr-postpone.ts → render/postpone.ts} +5 -5
  344. package/src/{ppr.ts → render/ppr.ts} +244 -245
  345. package/src/render/renderer.ts +2087 -2082
  346. package/src/render/resource-hints.ts +16 -17
  347. package/src/render/slots.tsx +224 -235
  348. package/src/{islands → render}/static-children.ts +9 -12
  349. package/src/{islands → render}/static-slots.ts +37 -37
  350. package/src/{cache/context.ts → request/cache.ts} +20 -20
  351. package/src/request/context.ts +107 -107
  352. package/src/{dynamic/source.ts → resolve/dynamic.ts} +139 -139
  353. package/src/resolve/engine.ts +90 -77
  354. package/src/resolve/imports.ts +475 -463
  355. package/src/resolve/scan-facts.ts +318 -296
  356. package/src/resolve/source-text.ts +37 -37
  357. package/src/{dynamic → resolve}/tree-shake.ts +132 -128
  358. package/src/routing/forwarded.ts +19 -19
  359. package/src/routing/handler.ts +84 -91
  360. package/src/routing/href.ts +87 -70
  361. package/src/routing/{metadata.ts → metadata-files.ts} +403 -401
  362. package/src/{proxy.ts → routing/proxy.ts} +306 -312
  363. package/src/routing/{request-runtime.ts → request-environment.ts} +10 -10
  364. package/src/routing/routes.ts +827 -815
  365. package/src/routing/slots.ts +164 -160
  366. package/src/runtime/loader.ts +954 -0
  367. package/src/{dev → runtime}/module-cache.ts +309 -287
  368. package/src/{dev → runtime}/module-generations.ts +9 -9
  369. package/src/{dev → runtime}/module-transform.ts +81 -72
  370. package/src/{dev/imports.ts → runtime/modules.ts} +934 -847
  371. package/src/runtime/{server.ts → vendor-build.ts} +848 -1696
  372. package/src/runtime/vendor.ts +428 -406
  373. package/src/styles.d.ts +9 -0
  374. package/src/types.ts +324 -335
  375. package/src/utils/ansi.ts +5 -5
  376. package/src/utils/{source.ts → code.ts} +15 -12
  377. package/src/utils/content-type.ts +3 -3
  378. package/src/utils/decode.ts +2 -2
  379. package/src/utils/dev-profile.ts +13 -13
  380. package/src/utils/error-log.ts +6 -6
  381. package/src/utils/esbuild.ts +18 -18
  382. package/src/utils/fs-cache.ts +13 -13
  383. package/src/utils/fs.ts +57 -49
  384. package/src/utils/html.ts +20 -24
  385. package/src/utils/native-require.ts +8 -8
  386. package/src/utils/serialize.ts +139 -146
  387. package/src/utils/verbose.ts +18 -18
  388. package/reference/overview.md +0 -35
  389. package/src/cli/analyze-print.ts +0 -181
  390. package/src/compat/middleware/manifest.ts +0 -210
  391. package/src/compat/next/image-client.tsx +0 -215
  392. package/src/compat/next/link-usage.ts +0 -29
  393. package/src/css/index.ts +0 -2
  394. package/src/render/index.ts +0 -1
  395. package/src/style-modules.d.ts +0 -9
package/src/extensions.ts CHANGED
@@ -8,17 +8,12 @@
8
8
  // registers its behavior here. Types stay intentionally structural (plain function shapes,
9
9
  // `unknown` payloads) so core carries no type dependency on any compat module.
10
10
 
11
- import type { OnLoadResult, Plugin } from 'esbuild';
12
- import type { CompatAliasTarget, ResolvedConfig } from './config';
13
- import type { StaticMetadataFile } from './routing/metadata';
14
- import type {
15
- BuildManifest,
16
- ClientEntryReason,
17
- RouteManifestEntry,
18
- RouteParamValue,
19
- } from './types';
20
- import type { VerboseLogger } from './utils/verbose';
21
- import { escapeRegex } from './utils/source';
11
+ import type { OnLoadResult, Plugin } from 'esbuild'
12
+ import type { CompatAliasTarget, ResolvedConfig } from './config'
13
+ import type { StaticMetadataFile } from './routing/metadata-files'
14
+ import type { BuildManifest, ClientEntryReason, RouteManifestEntry, RouteParamValue } from './types'
15
+ import type { VerboseLogger } from './utils/verbose'
16
+ import { escapeRegex } from './utils/code'
22
17
 
23
18
  /** Per-build wiring for the server plugin chain. */
24
19
  export interface ServerEsbuildPluginOptions {
@@ -27,13 +22,13 @@ export interface ServerEsbuildPluginOptions {
27
22
  * reference. Composed into the chain's single claiming onLoad, so the scan
28
23
  * costs no extra plugin-callback round trips.
29
24
  */
30
- vendorClientBoundary?: (file: string) => Promise<OnLoadResult | undefined>;
25
+ vendorClientBoundary?: (file: string) => Promise<OnLoadResult | undefined>
31
26
  /**
32
27
  * The build's entries are realpath-resolved before esbuild sees them (the vendor chains), so
33
28
  * workspace-link symlinks alone cannot put a symlinked importer in the graph - the symlink-import plugin
34
29
  * may skip registration.
35
30
  */
36
- realPathEntries?: boolean;
31
+ realPathEntries?: boolean
37
32
  }
38
33
 
39
34
  // The extension host - ONE instance owning every domain registry below. A normal process runs on the
@@ -42,22 +37,22 @@ export interface ServerEsbuildPluginOptions {
42
37
  // embedder) creates an isolated host and swaps it in, so registrations cannot leak between apps.
43
38
 
44
39
  export interface ExtensionHost {
45
- compatMode: CompatModeExtensions;
46
- render: RenderExtensions;
47
- request: RequestExtensions;
48
- runtime: RuntimeExtensions;
49
- build: BuildExtensions;
50
- routing: RoutingExtensions;
51
- proxy: ProxyExtensions;
52
- proxyResponse: ProxyResponseProtocol;
53
- routerProtocol: RouterProtocolExtensions;
54
- bundler: BundlerExtensions;
55
- importAlias: ImportAliasExtensions;
56
- asset: AssetExtensions;
40
+ compatMode: CompatModeExtensions
41
+ render: RenderExtensions
42
+ request: RequestExtensions
43
+ runtime: RuntimeExtensions
44
+ build: BuildExtensions
45
+ routing: RoutingExtensions
46
+ proxy: ProxyExtensions
47
+ proxyResponse: ProxyResponseProtocol
48
+ routerProtocol: RouterProtocolExtensions
49
+ bundler: BundlerExtensions
50
+ importAlias: ImportAliasExtensions
51
+ asset: AssetExtensions
57
52
  /** Import-only loadable extensions; page extensions live on `routing`. */
58
- loadable: string[];
53
+ loadable: string[]
59
54
  /** Memoized union of the server-transform chain's sniff tokens. */
60
- serverSniff?: { pattern: RegExp | undefined };
55
+ serverSniff?: { pattern: RegExp | undefined }
61
56
  }
62
57
 
63
58
  export function createExtensionHost(): ExtensionHost {
@@ -75,30 +70,30 @@ export function createExtensionHost(): ExtensionHost {
75
70
  importAlias: createImportAliasExtensions(),
76
71
  asset: createAssetExtensions(),
77
72
  loadable: [],
78
- };
73
+ }
79
74
  }
80
75
 
81
- let activeHost = createExtensionHost();
76
+ let activeHost = createExtensionHost()
82
77
 
83
78
  /** The host every accessor in this module reads. */
84
79
  export function getExtensionHost(): ExtensionHost {
85
- return activeHost;
80
+ return activeHost
86
81
  }
87
82
 
88
83
  // Registration guards that live OUTSIDE any host — compat-bootstrap's promises,
89
84
  // each register-* module's `registered` flag — must clear when the host is
90
85
  // swapped, or the fresh host is left permanently empty. Module-global on
91
86
  // purpose: the guards they clear are module-global too.
92
- const resetHandlers: (() => void)[] = [];
87
+ const resetHandlers: (() => void)[] = []
93
88
 
94
89
  // The detectors are regex sweeps over whole sources, and a route's layout chain is re-detected for
95
90
  // every route below it. The answer depends only on the source and the registered detector set, so
96
91
  // memoize on exactly that. Cleared whenever a detector registers.
97
- const clientEntryReasonCache = new Map<string, ClientEntryReason[]>();
92
+ const clientEntryReasonCache = new Map<string, ClientEntryReason[]>()
98
93
 
99
94
  /** Run `handler` whenever the active host is swapped. */
100
95
  export function onExtensionHostReset(handler: () => void): void {
101
- resetHandlers.push(handler);
96
+ resetHandlers.push(handler)
102
97
  }
103
98
 
104
99
  /**
@@ -107,66 +102,66 @@ export function onExtensionHostReset(handler: () => void): void {
107
102
  * core defaults with them. Restored in place rather than replaced - consumers may hold the object.
108
103
  */
109
104
  export function restoreWithExtensionHost<T extends object>(registry: T): void {
110
- const defaults = { ...registry };
105
+ const defaults = { ...registry }
111
106
  onExtensionHostReset(() => {
112
- for (const key of Object.keys(registry)) delete (registry as Record<string, unknown>)[key];
113
- Object.assign(registry, defaults);
114
- });
107
+ for (const key of Object.keys(registry)) delete (registry as Record<string, unknown>)[key]
108
+ Object.assign(registry, defaults)
109
+ })
115
110
  }
116
111
 
117
112
  /** Install `host` as the active one; the returned function restores the previous. */
118
113
  export function setActiveHost(host: ExtensionHost): () => void {
119
- const previous = activeHost;
120
- activeHost = host;
121
- announceHostChange();
114
+ const previous = activeHost
115
+ activeHost = host
116
+ announceHostChange()
122
117
  return () => {
123
- activeHost = previous;
124
- announceHostChange();
125
- };
118
+ activeHost = previous
119
+ announceHostChange()
120
+ }
126
121
  }
127
122
 
128
123
  /** Swap in a fresh host, dropping every registration on the current one. */
129
124
  export function resetExtensionHost(): ExtensionHost {
130
- const host = createExtensionHost();
131
- setActiveHost(host);
132
- return host;
125
+ const host = createExtensionHost()
126
+ setActiveHost(host)
127
+ return host
133
128
  }
134
129
 
135
130
  /** Run `callback` against `host`, restoring the previous host afterwards. */
136
131
  export function withExtensionHost<T>(host: ExtensionHost, callback: () => T): T {
137
- const restore = setActiveHost(host);
132
+ const restore = setActiveHost(host)
138
133
  try {
139
- const result = callback();
140
- if (isThenable(result)) return Promise.resolve(result).finally(restore) as T;
141
- restore();
142
- return result;
134
+ const result = callback()
135
+ if (isThenable(result)) return Promise.resolve(result).finally(restore) as T
136
+ restore()
137
+ return result
143
138
  } catch (error) {
144
- restore();
145
- throw error;
139
+ restore()
140
+ throw error
146
141
  }
147
142
  }
148
143
 
149
144
  function announceHostChange() {
150
- for (const handler of resetHandlers) handler();
145
+ for (const handler of resetHandlers) handler()
151
146
  // Consumers latch the loadable-extension set (the server load plugin's filter
152
147
  // regex); a swap changes it, so invalidate exactly as a registration would.
153
- for (const listener of loadableExtensionListeners) listener();
148
+ for (const listener of loadableExtensionListeners) listener()
154
149
  // Memoized detector answers belong to the host that registered the detectors.
155
- clientEntryReasonCache.clear();
150
+ clientEntryReasonCache.clear()
156
151
  }
157
152
 
158
153
  // ---------------------------------------------------------------------------
159
- // Compat mode extensions — populated by compat/index.
154
+ // Compat mode extensions — populated by compat/aliases.
160
155
  // ---------------------------------------------------------------------------
161
156
 
162
157
  export interface ReactCompilerOptions {
163
- target: string;
158
+ target: string
164
159
  }
165
160
 
166
161
  export interface CompatModeExtensions {
167
- nextEnabled: (config: ResolvedConfig) => boolean;
168
- reactEnabled: (config: ResolvedConfig) => boolean;
169
- reactCompilerOptions: (config: ResolvedConfig) => ReactCompilerOptions | undefined;
162
+ nextEnabled: (config: ResolvedConfig) => boolean
163
+ reactEnabled: (config: ResolvedConfig) => boolean
164
+ reactCompilerOptions: (config: ResolvedConfig) => ReactCompilerOptions | undefined
170
165
  }
171
166
 
172
167
  function createCompatModeExtensions(): CompatModeExtensions {
@@ -174,15 +169,15 @@ function createCompatModeExtensions(): CompatModeExtensions {
174
169
  nextEnabled: () => false,
175
170
  reactEnabled: () => false,
176
171
  reactCompilerOptions: () => undefined,
177
- };
172
+ }
178
173
  }
179
174
 
180
175
  export function getCompatModeExtensions(): CompatModeExtensions {
181
- return activeHost.compatMode;
176
+ return activeHost.compatMode
182
177
  }
183
178
 
184
179
  export function setCompatModeExtensions(overrides: Partial<CompatModeExtensions>): void {
185
- Object.assign(activeHost.compatMode, overrides);
180
+ Object.assign(activeHost.compatMode, overrides)
186
181
  }
187
182
 
188
183
  // ---------------------------------------------------------------------------
@@ -192,27 +187,27 @@ export function setCompatModeExtensions(overrides: Partial<CompatModeExtensions>
192
187
 
193
188
  /** Result of collecting cache metadata around a render (matches compat/cache/revalidate collectRenderCacheMeta). */
194
189
  export interface RenderCacheMetaResult<T> {
195
- value: T;
196
- tags: string[];
197
- revalidateSeconds?: number;
190
+ value: T
191
+ tags: string[]
192
+ revalidateSeconds?: number
198
193
  /** Aggregated `use cache` cacheLife expire/stale windows (min across scopes). */
199
- expireSeconds?: number;
200
- staleSeconds?: number;
201
- noStore?: boolean;
194
+ expireSeconds?: number
195
+ staleSeconds?: number
196
+ noStore?: boolean
202
197
  }
203
198
 
204
199
  /** Options threaded into a cache-meta collection scope. */
205
200
  export interface CollectRenderMetaOptions {
206
- fetchCache?: string;
207
- refreshFetches?: boolean;
208
- blockingStaleFetches?: boolean;
209
- route?: string;
201
+ fetchCache?: string
202
+ refreshFetches?: boolean
203
+ blockingStaleFetches?: boolean
204
+ route?: string
210
205
  /** True for build-time static generation renders (prerender fetch caching). */
211
- prerender?: boolean;
206
+ prerender?: boolean
212
207
  /** True when the render is a route handler (vs a page/layout render). */
213
- handler?: boolean;
208
+ handler?: boolean
214
209
  /** True when a static render must reject dynamic request APIs. */
215
- dynamicError?: boolean;
210
+ dynamicError?: boolean
216
211
  }
217
212
 
218
213
  export interface RenderExtensions {
@@ -230,34 +225,34 @@ export interface RenderExtensions {
230
225
  | 'stream'
231
226
  >,
232
227
  state: {
233
- route: string;
234
- params: Record<string, RouteParamValue>;
235
- catchAllOptional?: boolean;
236
- pageVary?: string[];
228
+ route: string
229
+ params: Record<string, RouteParamValue>
230
+ catchAllOptional?: boolean
231
+ pageVary?: string[]
237
232
  },
238
233
  ) => {
239
- route: string;
240
- params: Record<string, RouteParamValue>;
241
- catchAllOptional?: boolean;
234
+ route: string
235
+ params: Record<string, RouteParamValue>
236
+ catchAllOptional?: boolean
242
237
  /** Baked-shell vary set (see renderer `bakedShellPageVary`). */
243
- pageVary?: string[];
244
- staticChildren?: string[];
245
- staticChildrenBySegment?: Record<string, string[]>;
246
- prefetchKind?: 'shell' | 'eager';
238
+ pageVary?: string[]
239
+ staticChildren?: string[]
240
+ staticChildrenBySegment?: Record<string, string[]>
241
+ prefetchKind?: 'shell' | 'eager'
247
242
  /** `prefetch = 'allow-runtime'` — the shell is per-URL, not route-shared. */
248
- runtimePrefetch?: boolean;
249
- };
243
+ runtimePrefetch?: boolean
244
+ }
250
245
  /**
251
246
  * Wrap a single server-component invocation. Compat (react) installs the
252
247
  * use()-thenable replay wrapper here (compat/react/preact withUseThenableState
253
248
  * + render/index.tsx invokeServerComponentWithUse). Default: call through untouched.
254
249
  */
255
- wrapServerComponentInvoke: <T>(invoke: () => T) => T;
250
+ wrapServerComponentInvoke: <T>(invoke: () => T) => T
256
251
 
257
252
  /**
258
253
  * Optional one-time render-module initialization side effect. Default: noop.
259
254
  */
260
- onRenderInit: () => void;
255
+ onRenderInit: () => void
261
256
 
262
257
  /**
263
258
  * Convert a value crossing the server->client boundary into a serializable
@@ -273,7 +268,7 @@ export interface RenderExtensions {
273
268
  serializeServerActionProp: (
274
269
  value: unknown,
275
270
  context: ServerActionPropContext,
276
- ) => ActionRef | undefined;
271
+ ) => ActionRef | undefined
277
272
 
278
273
  /**
279
274
  * Run `produce` inside a cache-meta collection scope, returning its value plus
@@ -284,7 +279,7 @@ export interface RenderExtensions {
284
279
  collectRenderMeta: <T>(
285
280
  produce: () => Promise<T>,
286
281
  options?: CollectRenderMetaOptions,
287
- ) => Promise<RenderCacheMetaResult<T>>;
282
+ ) => Promise<RenderCacheMetaResult<T>>
288
283
 
289
284
  /**
290
285
  * The effective `use cache` stale window (seconds) recorded SO FAR by the surrounding
@@ -293,13 +288,13 @@ export interface RenderExtensions {
293
288
  * its caches with the route's real reuse window. The route manifest's `cacheLife` cannot serve
294
289
  * here: it is captured FROM this very render and persisted only after the HTML exists.
295
290
  */
296
- currentCacheStaleSeconds: () => number | undefined;
291
+ currentCacheStaleSeconds: () => number | undefined
297
292
 
298
293
  /**
299
294
  * Override the generic error shell title. Compat uses this for Next's
300
295
  * production client-error page copy; core keeps the compact default.
301
296
  */
302
- genericErrorTitle: (context: GenericErrorTitleContext) => string | undefined;
297
+ genericErrorTitle: (context: GenericErrorTitleContext) => string | undefined
303
298
 
304
299
  /**
305
300
  * Whether islands travel the wire as comment markers instead of elements. Core's wire format is
@@ -308,7 +303,7 @@ export interface RenderExtensions {
308
303
  * structural selectors against the live DOM (`body > p`), which a wrapper element would break, so
309
304
  * compat turns the elements into comment pairs plus a bootstrap that materializes them back.
310
305
  */
311
- islandCommentWireFormat: () => boolean;
306
+ islandCommentWireFormat: () => boolean
312
307
 
313
308
  /**
314
309
  * Serialize a caught render error into the `{ name, message, digest }` shape
@@ -318,7 +313,7 @@ export interface RenderExtensions {
318
313
  * and log the original stack once to the server console. Default: return
319
314
  * undefined so core keeps its own compact serialization.
320
315
  */
321
- serializeError: (context: SerializeErrorContext) => SerializedError | undefined;
316
+ serializeError: (context: SerializeErrorContext) => SerializedError | undefined
322
317
 
323
318
  /**
324
319
  * Next-pixel-exact default UI for an HTTP-access fallback (not-found 404,
@@ -328,7 +323,7 @@ export interface RenderExtensions {
328
323
  * keeps a compact built-in when this is absent. `status` is the HTTP status,
329
324
  * `message` the copy shown in the `h2`.
330
325
  */
331
- httpAccessFallbackUi: (status: number, message: string) => unknown;
326
+ httpAccessFallbackUi: (status: number, message: string) => unknown
332
327
 
333
328
  /**
334
329
  * Next-pixel-exact built-in global-error document ("This page couldn't load"
@@ -336,7 +331,7 @@ export interface RenderExtensions {
336
331
  * root layout and the app ships no global-error.*. Returns a render tree
337
332
  * (preact VNode, opaque to core) or undefined to keep core's compact fallback.
338
333
  */
339
- defaultGlobalErrorUi: (error: SerializedError) => unknown;
334
+ defaultGlobalErrorUi: (error: SerializedError) => unknown
340
335
 
341
336
  /**
342
337
  * Inline bootstrap markup appended to a global-error document (built-in
@@ -345,7 +340,7 @@ export interface RenderExtensions {
345
340
  * (Playwright `pageerror`). Returns an HTML string (typically a `<script>`
346
341
  * tag) or undefined to render the document with no bootstrap (core default).
347
342
  */
348
- globalErrorReportScript: (error: SerializedError) => string | undefined;
343
+ globalErrorReportScript: (error: SerializedError) => string | undefined
349
344
 
350
345
  /**
351
346
  * Wrap a non-Error thrown value (a `throw undefined`/`null`/'msg' from a
@@ -355,21 +350,21 @@ export interface RenderExtensions {
355
350
  * digest gains Next's `@E394` suffix for nullish throws. Default: undefined
356
351
  * (core wraps with a plain `new Error(String(value))`).
357
352
  */
358
- wrapThrownValue: (value: unknown) => Error | undefined;
353
+ wrapThrownValue: (value: unknown) => Error | undefined
359
354
 
360
355
  /**
361
356
  * Format the server-console log line for a render error that carries a boundary digest. Compat
362
357
  * emits Next's exact prod shape, plus any environment tag the error carries (an error funneled out
363
358
  * of a 'use cache' scope inspects as `{ environmentName: 'Cache', digest }`).
364
359
  */
365
- formatErrorLog: (trace: string, digest: string, error?: Error) => string | undefined;
360
+ formatErrorLog: (trace: string, digest: string, error?: Error) => string | undefined
366
361
 
367
362
  /**
368
363
  * True when the app opted into the global-not-found convention: an unmatched URL then renders the
369
364
  * global-not-found document, and with no global-not-found.* file it falls back to the BUILT-IN
370
365
  * default 404, never the app's root not-found.* boundary (reserved for explicit notFound() calls).
371
366
  */
372
- globalNotFoundEnabled: () => boolean;
367
+ globalNotFoundEnabled: () => boolean
373
368
 
374
369
  /**
375
370
  * Wrap a render's concrete `params` / `searchParams` object in a tracking view so compat can record
@@ -379,53 +374,53 @@ export interface RenderExtensions {
379
374
  trackVaryParams: <T extends Record<string, unknown>>(
380
375
  value: T,
381
376
  context: VaryParamsTrackingContext,
382
- ) => T;
377
+ ) => T
383
378
 
384
379
  /** Optional opaque state lifecycle around partial prerenders. */
385
- prerenderSidecar: PrerenderSidecarExtension;
380
+ prerenderSidecar: PrerenderSidecarExtension
386
381
  }
387
382
 
388
383
  /** What kind of object `trackVaryParams` is being handed, plus route shape. */
389
384
  export interface VaryParamsTrackingContext {
390
- kind: 'params' | 'searchParams';
385
+ kind: 'params' | 'searchParams'
391
386
  /**
392
387
  * Which route segment is about to read this object. Compat keys its
393
388
  * per-segment vary sets on it, so a layout that reads more params than the
394
389
  * page does not force the page's cache entry to vary on them too. Defaults
395
390
  * to the leaf page.
396
391
  */
397
- segment?: 'page' | 'layout';
392
+ segment?: 'page' | 'layout'
398
393
  /**
399
394
  * Name of an OPTIONAL catch-all param of this route (`[[...slug]]`), when
400
395
  * any. Its key is absent from `params` at the empty value, so tracking it
401
396
  * needs the name up front.
402
397
  */
403
- optionalCatchAllParam?: string;
398
+ optionalCatchAllParam?: string
404
399
  }
405
400
 
406
401
  export interface GenericErrorTitleContext {
407
- error: Error;
408
- dev: boolean;
402
+ error: Error
403
+ dev: boolean
409
404
  }
410
405
 
411
406
  /** Context handed to the error-serialization extension. */
412
407
  export interface SerializeErrorContext {
413
- error: Error;
414
- dev: boolean;
408
+ error: Error
409
+ dev: boolean
415
410
  }
416
411
 
417
412
  /** The `{ name, message, digest }` object passed to an error boundary component. */
418
413
  export interface SerializedError {
419
- name: string;
420
- message: string;
421
- digest?: string;
414
+ name: string
415
+ message: string
416
+ digest?: string
422
417
  }
423
418
 
424
419
  /** Opaque scope handed to serializeServerActionProp (config + per-render key). */
425
420
  export interface ServerActionPropContext {
426
- config: ResolvedConfig;
421
+ config: ResolvedConfig
427
422
  /** Stable per-render identity; core passes its RenderOptions object. */
428
- renderKey: object;
423
+ renderKey: object
429
424
  /**
430
425
  * Only answer for a function that is IDENTIFIABLY a server action (a tagged
431
426
  * module export, a compile-tagged inline `'use server'` closure, an
@@ -438,29 +433,29 @@ export interface ServerActionPropContext {
438
433
  * the element with a bogus action wire and shift the occurrence indices real
439
434
  * inline actions are keyed on.
440
435
  */
441
- identifiedOnly?: boolean;
436
+ identifiedOnly?: boolean
442
437
  }
443
438
 
444
439
  /** Serializable marker a compat client runtime revives back into an action. */
445
- export type ActionRef = Record<string, unknown>;
440
+ export type ActionRef = Record<string, unknown>
446
441
 
447
442
  export interface PrerenderSidecarContext {
448
- outPath: string;
449
- routeId: string;
450
- routePath: string;
443
+ outPath: string
444
+ routeId: string
445
+ routePath: string
451
446
  }
452
447
 
453
448
  export interface PrerenderSidecarExtension {
454
- begin: (context: PrerenderSidecarContext) => void | Promise<void>;
455
- collect: (context: PrerenderSidecarContext) => Promise<unknown>;
456
- persist: (context: PrerenderSidecarContext, value: unknown) => Promise<void>;
457
- seed: (context: PrerenderSidecarContext) => void | Promise<void>;
449
+ begin: (context: PrerenderSidecarContext) => void | Promise<void>
450
+ collect: (context: PrerenderSidecarContext) => Promise<unknown>
451
+ persist: (context: PrerenderSidecarContext, value: unknown) => Promise<void>
452
+ seed: (context: PrerenderSidecarContext) => void | Promise<void>
458
453
  /**
459
454
  * Whether the persisted sidecar/shell went stale. `true` = hard staleness
460
455
  * (block and regenerate before responding); `'soft'` = stale-while-
461
456
  * revalidate (serve the stale shell once, regenerate in the background).
462
457
  */
463
- isStale: (context: PrerenderSidecarContext) => boolean | 'soft' | Promise<boolean | 'soft'>;
458
+ isStale: (context: PrerenderSidecarContext) => boolean | 'soft' | Promise<boolean | 'soft'>
464
459
  }
465
460
 
466
461
  function createRenderExtensions(): RenderExtensions {
@@ -488,15 +483,15 @@ function createRenderExtensions(): RenderExtensions {
488
483
  seed: () => undefined,
489
484
  isStale: () => false,
490
485
  },
491
- };
486
+ }
492
487
  }
493
488
 
494
489
  export function getRenderExtensions(): RenderExtensions {
495
- return activeHost.render;
490
+ return activeHost.render
496
491
  }
497
492
 
498
493
  export function setRenderExtensions(overrides: Partial<RenderExtensions>): void {
499
- Object.assign(activeHost.render, overrides);
494
+ Object.assign(activeHost.render, overrides)
500
495
  }
501
496
 
502
497
  // ---------------------------------------------------------------------------
@@ -513,18 +508,18 @@ export function setRenderExtensions(overrides: Partial<RenderExtensions>): void
513
508
  export type RequestInterceptor = (
514
509
  request: Request,
515
510
  ctx: RequestInterceptorContext,
516
- ) => Promise<Response | { request: Request } | undefined>;
511
+ ) => Promise<Response | { request: Request } | undefined>
517
512
 
518
513
  /** Context handed to each request interceptor. */
519
514
  export interface RequestInterceptorContext {
520
- config: ResolvedConfig;
515
+ config: ResolvedConfig
521
516
  /**
522
517
  * The request's path falls OUTSIDE the configured basePath, so core would
523
518
  * otherwise 404 it. Only rules that opt out of the basePath (next.config's
524
519
  * `basePath: false` rewrites/redirects) may answer such a request; every other
525
520
  * interceptor must decline. Absent (falsy) on every in-app request.
526
521
  */
527
- outsideBasePath?: boolean;
522
+ outsideBasePath?: boolean
528
523
  }
529
524
 
530
525
  // Response finalizers - ordered fns run before the first flush of every response-producing call site
@@ -533,16 +528,16 @@ export interface RequestInterceptorContext {
533
528
  // compat adds RSC Vary values, x-nextjs-* headers and exact ISR cache-control strings here.
534
529
 
535
530
  /** How the matched route was served — shapes the finalizer decisions. */
536
- export type ResponseRouteKind = 'html' | 'data' | 'static-asset' | 'route-handler';
531
+ export type ResponseRouteKind = 'html' | 'data' | 'static-asset' | 'route-handler'
537
532
 
538
533
  /** The route's caching disposition when known (page/handler renders). */
539
- export type ResponseRouteMode = 'static' | 'isr' | 'dynamic';
534
+ export type ResponseRouteMode = 'static' | 'isr' | 'dynamic'
540
535
 
541
536
  /** Read-only request facts a finalizer keys its header/status decisions on. */
542
537
  export interface ResponseFinalizerRequest {
543
- method: string;
544
- url: URL;
545
- headers: Headers;
538
+ method: string
539
+ url: URL
540
+ headers: Headers
546
541
  }
547
542
 
548
543
  /**
@@ -554,43 +549,43 @@ export interface ResponseFinalizerRequest {
554
549
  * `hints`.
555
550
  */
556
551
  export interface ResponseFinalizerContext {
557
- request: ResponseFinalizerRequest;
552
+ request: ResponseFinalizerRequest
558
553
  /** How the response was produced. */
559
- routeKind: ResponseRouteKind;
554
+ routeKind: ResponseRouteKind
560
555
  /** Caching disposition of the matched route, when core knows it. */
561
- routeMode?: ResponseRouteMode;
556
+ routeMode?: ResponseRouteMode
562
557
  /** Outgoing status; assign to override before first flush. */
563
- status: number;
558
+ status: number
564
559
  /** Outgoing headers; mutate in place (merge Vary, set Cache-Control, ...). */
565
- headers: Headers;
560
+ headers: Headers
566
561
  /** Compat-only classification hints (RSC kind, rewrite target, ...). */
567
- hints?: Record<string, unknown>;
562
+ hints?: Record<string, unknown>
568
563
  }
569
564
 
570
565
  /** A response finalizer runs before first flush; mutations land on the response. */
571
- export type ResponseFinalizer = (ctx: ResponseFinalizerContext) => void | Promise<void>;
566
+ export type ResponseFinalizer = (ctx: ResponseFinalizerContext) => void | Promise<void>
572
567
 
573
568
  /** Request facts handed to the error funnel (Next's onRequestError request arg). */
574
569
  export interface RequestErrorInfo {
575
- method: string;
576
- url: string;
577
- headers: Headers;
570
+ method: string
571
+ url: string
572
+ headers: Headers
578
573
  }
579
574
 
580
575
  /** Work-unit facts handed to the error funnel (phase, matched route kind). */
581
576
  export interface RequestErrorContext {
582
577
  /** The active work-unit phase when the error was caught, if any. */
583
- phase?: string;
578
+ phase?: string
584
579
  /** How the failing request was being served. */
585
- routeKind?: ResponseRouteKind;
580
+ routeKind?: ResponseRouteKind
586
581
  /** Optional compat-neutral details forwarded by the active work unit. */
587
- renderSource?: string;
588
- revalidateReason?: string;
582
+ renderSource?: string
583
+ revalidateReason?: string
589
584
  }
590
585
 
591
586
  export interface RequestExtensions {
592
587
  /** Ordered interceptors run before route matching (action dispatch, rewrites). */
593
- interceptors: RequestInterceptor[];
588
+ interceptors: RequestInterceptor[]
594
589
 
595
590
  /**
596
591
  * Fixed first-request costs an extension would otherwise pay inside the first
@@ -598,14 +593,14 @@ export interface RequestExtensions {
598
593
  * them in the background after Ready; they must be idempotent, cheap to skip,
599
594
  * and never route-specific.
600
595
  */
601
- warmHooks: ((config: ResolvedConfig) => void)[];
596
+ warmHooks: ((config: ResolvedConfig) => void)[]
602
597
 
603
598
  /**
604
599
  * Interceptors for a request whose path lies OUTSIDE the configured basePath - one core 404s before
605
600
  * any routing. Only rules that explicitly opt out of the basePath belong here; everything else must
606
601
  * not see such a request. Never consulted without a basePath.
607
602
  */
608
- outsideBasePathInterceptors: RequestInterceptor[];
603
+ outsideBasePathInterceptors: RequestInterceptor[]
609
604
 
610
605
  /**
611
606
  * Ordered response finalizers run before the first flush on every
@@ -613,7 +608,7 @@ export interface RequestExtensions {
613
608
  * status/headers and may mutate status/headers in place. Compat appends RSC
614
609
  * Vary values, x-nextjs-* headers, and exact ISR cache-control strings.
615
610
  */
616
- responseFinalizers: ResponseFinalizer[];
611
+ responseFinalizers: ResponseFinalizer[]
617
612
 
618
613
  /**
619
614
  * The request-level error funnel. Core calls this exactly once from the single place it catches a
@@ -625,22 +620,22 @@ export interface RequestExtensions {
625
620
  error: unknown,
626
621
  requestInfo: RequestErrorInfo,
627
622
  context: RequestErrorContext,
628
- ) => void | Promise<void>;
623
+ ) => void | Promise<void>
629
624
 
630
625
  /**
631
626
  * Whether a prebuilt static file for `pathname` (written at `mtimeMs`, with the given cache `tags`)
632
627
  * has been invalidated since it was built - the ISR on-demand staleness check. Default: never stale.
633
628
  */
634
- staticStaleness: (pathname: string, mtimeMs: number, tags: readonly string[]) => boolean;
629
+ staticStaleness: (pathname: string, mtimeMs: number, tags: readonly string[]) => boolean
635
630
  /** Why the same static file is stale, when available. */
636
631
  staticStalenessReason: (
637
632
  pathname: string,
638
633
  mtimeMs: number,
639
634
  tags: readonly string[],
640
- ) => 'stale' | 'on-demand' | 'soft' | undefined;
635
+ ) => 'stale' | 'on-demand' | 'soft' | undefined
641
636
 
642
637
  /** Trigger immediate ISR regeneration for pages API res.revalidate(). */
643
- onDemandRevalidatePath: (pathname: string) => void | Promise<void>;
638
+ onDemandRevalidatePath: (pathname: string) => void | Promise<void>
644
639
 
645
640
  /**
646
641
  * The preview-mode id an `x-prerender-revalidate` request header must match
@@ -648,7 +643,7 @@ export interface RequestExtensions {
648
643
  * route re-renders fresh (`x-nextjs-cache: REVALIDATED`). Compat registers
649
644
  * the id it writes into prerender-manifest.json. Default: none (no bypass).
650
645
  */
651
- revalidateBypassToken: () => string | undefined;
646
+ revalidateBypassToken: () => string | undefined
652
647
  }
653
648
 
654
649
  function createRequestExtensions(): RequestExtensions {
@@ -662,28 +657,28 @@ function createRequestExtensions(): RequestExtensions {
662
657
  staticStalenessReason: () => undefined,
663
658
  onDemandRevalidatePath: () => undefined,
664
659
  revalidateBypassToken: () => undefined,
665
- };
660
+ }
666
661
  }
667
662
 
668
663
  export function getRequestExtensions(): RequestExtensions {
669
- return activeHost.request;
664
+ return activeHost.request
670
665
  }
671
666
 
672
667
  /** Append request interceptors in order (compat registers action dispatch + rewrites). */
673
668
  export function registerRequestInterceptors(...interceptors: RequestInterceptor[]): void {
674
- activeHost.request.interceptors.push(...interceptors);
669
+ activeHost.request.interceptors.push(...interceptors)
675
670
  }
676
671
 
677
672
  /** Register a fixed first-request cost the dev warm can pay in the background. */
678
673
  export function registerRequestWarmHooks(...hooks: ((config: ResolvedConfig) => void)[]): void {
679
- activeHost.request.warmHooks.push(...hooks);
674
+ activeHost.request.warmHooks.push(...hooks)
680
675
  }
681
676
 
682
677
  /** Pay every registered first-request cost up front. Failures are never fatal. */
683
678
  export function runRequestWarmHooks(config: ResolvedConfig): void {
684
679
  for (const hook of activeHost.request.warmHooks) {
685
680
  try {
686
- hook(config);
681
+ hook(config)
687
682
  } catch {
688
683
  // A warm that fails just leaves the cost on the first request.
689
684
  }
@@ -692,17 +687,17 @@ export function runRequestWarmHooks(config: ResolvedConfig): void {
692
687
 
693
688
  /** Append interceptors that may answer a request from outside the basePath. */
694
689
  export function registerOutsideBasePathInterceptors(...interceptors: RequestInterceptor[]): void {
695
- activeHost.request.outsideBasePathInterceptors.push(...interceptors);
690
+ activeHost.request.outsideBasePathInterceptors.push(...interceptors)
696
691
  }
697
692
 
698
693
  /** Append response finalizers in order (compat registers RSC headers + ISR cache-control). */
699
694
  export function registerResponseFinalizers(...finalizers: ResponseFinalizer[]): void {
700
- activeHost.request.responseFinalizers.push(...finalizers);
695
+ activeHost.request.responseFinalizers.push(...finalizers)
701
696
  }
702
697
 
703
698
  /** Register the preview-mode id that authorizes on-demand revalidate requests. */
704
699
  export function registerRevalidateBypassToken(token: () => string | undefined): void {
705
- activeHost.request.revalidateBypassToken = token;
700
+ activeHost.request.revalidateBypassToken = token
706
701
  }
707
702
 
708
703
  /**
@@ -716,13 +711,13 @@ export async function finalizeResponse(
716
711
  response: Response,
717
712
  request: ResponseFinalizerRequest,
718
713
  info: {
719
- routeKind: ResponseRouteKind;
720
- routeMode?: ResponseRouteMode;
721
- hints?: Record<string, unknown>;
714
+ routeKind: ResponseRouteKind
715
+ routeMode?: ResponseRouteMode
716
+ hints?: Record<string, unknown>
722
717
  },
723
718
  ): Promise<Response> {
724
- const finalizers = activeHost.request.responseFinalizers;
725
- if (finalizers.length === 0) return response;
719
+ const finalizers = activeHost.request.responseFinalizers
720
+ if (finalizers.length === 0) return response
726
721
  const ctx: ResponseFinalizerContext = {
727
722
  request,
728
723
  routeKind: info.routeKind,
@@ -730,20 +725,20 @@ export async function finalizeResponse(
730
725
  ...(info.hints ? { hints: info.hints } : {}),
731
726
  status: response.status,
732
727
  headers: response.headers,
733
- };
734
- for (const finalizer of finalizers) await finalizer(ctx);
735
- if (ctx.status === response.status) return response;
728
+ }
729
+ for (const finalizer of finalizers) await finalizer(ctx)
730
+ if (ctx.status === response.status) return response
736
731
  return new Response(response.body, {
737
732
  status: ctx.status,
738
733
  statusText: response.statusText,
739
734
  headers: response.headers,
740
- });
735
+ })
741
736
  }
742
737
 
743
738
  export function setRequestExtensions(
744
739
  overrides: Partial<Omit<RequestExtensions, 'interceptors' | 'responseFinalizers'>>,
745
740
  ): void {
746
- Object.assign(activeHost.request, overrides);
741
+ Object.assign(activeHost.request, overrides)
747
742
  }
748
743
 
749
744
  /**
@@ -757,9 +752,9 @@ export async function reportRequestError(
757
752
  context: RequestErrorContext,
758
753
  ): Promise<void> {
759
754
  try {
760
- await activeHost.request.onRequestError(error, requestInfo, context);
755
+ await activeHost.request.onRequestError(error, requestInfo, context)
761
756
  } catch (reportError) {
762
- console.error('onRequestError funnel failed:', reportError);
757
+ console.error('onRequestError funnel failed:', reportError)
763
758
  }
764
759
  }
765
760
 
@@ -769,52 +764,52 @@ export async function reportRequestError(
769
764
 
770
765
  export interface RuntimeExtensions {
771
766
  /** Run user code with Edge-runtime globals installed. Default: no-op. */
772
- withEdgeRuntime: <T>(callback: () => T) => T;
767
+ withEdgeRuntime: <T>(callback: () => T) => T
773
768
  }
774
769
 
775
770
  function createRuntimeExtensions(): RuntimeExtensions {
776
- return { withEdgeRuntime: callback => callback() };
771
+ return { withEdgeRuntime: callback => callback() }
777
772
  }
778
773
 
779
774
  export function getRuntimeExtensions(): RuntimeExtensions {
780
- return activeHost.runtime;
775
+ return activeHost.runtime
781
776
  }
782
777
 
783
778
  export function setRuntimeExtensions(overrides: Partial<RuntimeExtensions>): void {
784
- Object.assign(activeHost.runtime, overrides);
779
+ Object.assign(activeHost.runtime, overrides)
785
780
  }
786
781
 
787
782
  export function withRouteRuntime<T>(runtime: string | undefined, callback: () => T): T {
788
- const edge = runtime === 'edge' || runtime === 'experimental-edge';
783
+ const edge = runtime === 'edge' || runtime === 'experimental-edge'
789
784
  // eslint-disable-next-line turbo/no-undeclared-env-vars
790
- const previous = process.env.NEXT_RUNTIME;
785
+ const previous = process.env.NEXT_RUNTIME
791
786
  // eslint-disable-next-line turbo/no-undeclared-env-vars
792
- process.env.NEXT_RUNTIME = edge ? 'edge' : 'nodejs';
787
+ process.env.NEXT_RUNTIME = edge ? 'edge' : 'nodejs'
793
788
  try {
794
- const result = edge ? activeHost.runtime.withEdgeRuntime(callback) : callback();
789
+ const result = edge ? activeHost.runtime.withEdgeRuntime(callback) : callback()
795
790
  if (isThenable(result)) {
796
- return Promise.resolve(result).finally(() => restoreNextRuntime(previous)) as T;
791
+ return Promise.resolve(result).finally(() => restoreNextRuntime(previous)) as T
797
792
  }
798
- restoreNextRuntime(previous);
799
- return result;
793
+ restoreNextRuntime(previous)
794
+ return result
800
795
  } catch (error) {
801
- restoreNextRuntime(previous);
802
- throw error;
796
+ restoreNextRuntime(previous)
797
+ throw error
803
798
  }
804
799
  }
805
800
 
806
801
  function restoreNextRuntime(value: string | undefined) {
807
802
  if (value === undefined) {
808
803
  // eslint-disable-next-line turbo/no-undeclared-env-vars
809
- delete process.env.NEXT_RUNTIME;
804
+ delete process.env.NEXT_RUNTIME
810
805
  } else {
811
806
  // eslint-disable-next-line turbo/no-undeclared-env-vars
812
- process.env.NEXT_RUNTIME = value;
807
+ process.env.NEXT_RUNTIME = value
813
808
  }
814
809
  }
815
810
 
816
811
  function isThenable<T>(value: T): value is T & PromiseLike<unknown> {
817
- return typeof (value as { then?: unknown } | null | undefined)?.then === 'function';
812
+ return typeof (value as { then?: unknown } | null | undefined)?.then === 'function'
818
813
  }
819
814
 
820
815
  // ---------------------------------------------------------------------------
@@ -824,10 +819,10 @@ function isThenable<T>(value: T): value is T & PromiseLike<unknown> {
824
819
 
825
820
  /** Minimal build context handed to each build step (kept structural on purpose). */
826
821
  export interface BuildStepContext {
827
- config: ResolvedConfig;
828
- routes: unknown[];
829
- manifest: unknown;
830
- log: BuildStepLogger;
822
+ config: ResolvedConfig
823
+ routes: unknown[]
824
+ manifest: unknown
825
+ log: BuildStepLogger
831
826
  }
832
827
 
833
828
  /**
@@ -835,7 +830,7 @@ export interface BuildStepContext {
835
830
  * to the concrete VerboseLogger (core utility) so build.ts can pass its logger
836
831
  * verbatim without a structural-variance mismatch on `step`.
837
832
  */
838
- export type BuildStepLogger = VerboseLogger;
833
+ export type BuildStepLogger = VerboseLogger
839
834
 
840
835
  /** A build step runs during `pnext build` (action discovery/bundling, manifest writes). */
841
836
  export type BuildStep = ((ctx: BuildStepContext) => Promise<void>) & {
@@ -843,49 +838,49 @@ export type BuildStep = ((ctx: BuildStepContext) => Promise<void>) & {
843
838
  * Opt in to running under the route-facts scan instead of after it. An early step may read `ctx.config`
844
839
  * and route *paths* only - the facts (imports, use-client, CSS) are still being materialized while it runs.
845
840
  */
846
- early?: boolean;
841
+ early?: boolean
847
842
  /**
848
843
  * Gate the build: run serially before any artifact-producing stage, so this
849
844
  * step's diagnostics always precede a downstream failure it would have
850
845
  * explained. Non-gate steps run concurrently with the client bundle stage.
851
846
  */
852
- gate?: boolean;
853
- };
847
+ gate?: boolean
848
+ }
854
849
  export type BuildCompleteHook = (ctx: {
855
- config: ResolvedConfig;
856
- manifest: BuildManifest;
857
- log: BuildStepLogger;
858
- }) => Promise<void>;
850
+ config: ResolvedConfig
851
+ manifest: BuildManifest
852
+ log: BuildStepLogger
853
+ }) => Promise<void>
859
854
 
860
855
  export interface CacheLifeStashLike {
861
- expireSeconds?: number;
862
- staleSeconds?: number;
863
- revalidateSeconds?: number;
856
+ expireSeconds?: number
857
+ staleSeconds?: number
858
+ revalidateSeconds?: number
864
859
  }
865
860
 
866
861
  export interface SegmentPrefetchTree {
867
- tree: SegmentTreeNodeLike;
868
- staleTime: number;
869
- isStatic: boolean;
862
+ tree: SegmentTreeNodeLike
863
+ staleTime: number
864
+ isStatic: boolean
870
865
  }
871
866
 
872
867
  export interface SegmentTreeNodeLike {
873
- name: string;
874
- param: null | { type: 'd' | 'c' | 'oc'; key: string | null; siblings: string[] | null };
875
- slots: Record<string, SegmentTreeNodeLike> | null;
876
- prefetchHints: number;
877
- sizeBytes?: number;
878
- segmentPath?: string;
868
+ name: string
869
+ param: null | { type: 'd' | 'c' | 'oc'; key: string | null; siblings: string[] | null }
870
+ slots: Record<string, SegmentTreeNodeLike> | null
871
+ prefetchHints: number
872
+ sizeBytes?: number
873
+ segmentPath?: string
879
874
  }
880
875
 
881
876
  export interface SegmentMetaLike {
882
- status: number;
883
- staleTime: number;
884
- postponed: boolean;
885
- segmentPaths: string[];
886
- segmentSizes?: Record<string, number>;
887
- inlinedSegmentPaths?: string[];
888
- prefetchHints?: Record<string, number>;
877
+ status: number
878
+ staleTime: number
879
+ postponed: boolean
880
+ segmentPaths: string[]
881
+ segmentSizes?: Record<string, number>
882
+ inlinedSegmentPaths?: string[]
883
+ prefetchHints?: Record<string, number>
889
884
  }
890
885
 
891
886
  /**
@@ -894,8 +889,8 @@ export interface SegmentMetaLike {
894
889
  * shape lives in compat.
895
890
  */
896
891
  export interface BuildResponseVary {
897
- params: string[];
898
- search: boolean;
892
+ params: string[]
893
+ search: boolean
899
894
  }
900
895
 
901
896
  export interface BuildCompatExtensions {
@@ -905,20 +900,20 @@ export interface BuildCompatExtensions {
905
900
  */
906
901
  withVaryParamsTracking: <T>(
907
902
  produce: () => Promise<T>,
908
- ) => Promise<{ value: T; vary?: BuildResponseVary }>;
903
+ ) => Promise<{ value: T; vary?: BuildResponseVary }>
909
904
  /** The wire vary names for one segment kind of a tracked render. */
910
- varyNamesFor: (vary: BuildResponseVary, kind: 'body' | 'head' | 'page' | 'layout') => string[];
905
+ varyNamesFor: (vary: BuildResponseVary, kind: 'body' | 'head' | 'page' | 'layout') => string[]
911
906
  warnMetadataIssues: (input: {
912
- appPath: string;
913
- routes: RouteManifestEntry[];
914
- staticMetadataFiles: StaticMetadataFile[];
915
- }) => Promise<void>;
916
- nextOutputExport: () => boolean;
907
+ appPath: string
908
+ routes: RouteManifestEntry[]
909
+ staticMetadataFiles: StaticMetadataFile[]
910
+ }) => Promise<void>
911
+ nextOutputExport: () => boolean
917
912
  /** The configured `output` mode when it blocks `next start` ('export' | 'standalone'), else undefined. */
918
- nextOutputMode: () => 'export' | 'standalone' | undefined;
919
- nextScriptWorkersEnabled: () => boolean;
920
- defaultExpireTimeSeconds: () => number | undefined;
921
- takeCacheLifeStash: () => CacheLifeStashLike | undefined;
913
+ nextOutputMode: () => 'export' | 'standalone' | undefined
914
+ nextScriptWorkersEnabled: () => boolean
915
+ defaultExpireTimeSeconds: () => number | undefined
916
+ takeCacheLifeStash: () => CacheLifeStashLike | undefined
922
917
  /**
923
918
  * The `Link` header value for the font preloads stashed during the current
924
919
  * render work unit (next/font), or undefined when none. A static prerender
@@ -926,30 +921,30 @@ export interface BuildCompatExtensions {
926
921
  * build bakes the header into the manifest. Must be called inside the render
927
922
  * work unit before it unwinds. No-op default for pure-core apps.
928
923
  */
929
- takeFontLinkHeader: () => string | undefined;
930
- normalizeStaticParamsModule: (module: Record<string, unknown>) => Record<string, unknown>;
931
- defaultDynamicStaleTimeSeconds: number;
932
- defaultStaticStaleTimeSeconds: number;
924
+ takeFontLinkHeader: () => string | undefined
925
+ normalizeStaticParamsModule: (module: Record<string, unknown>) => Record<string, unknown>
926
+ defaultDynamicStaleTimeSeconds: number
927
+ defaultStaticStaleTimeSeconds: number
933
928
  buildRootTreePrefetch: (options: {
934
- pathname: string;
935
- isStatic: boolean;
936
- staleTimeSeconds?: number;
937
- buildId?: string;
938
- routeId?: string;
939
- bodySizeBytes?: number;
940
- inlineBudgetBytes?: number;
941
- runtimePrefetch?: boolean;
942
- postponed?: boolean;
943
- }) => SegmentPrefetchTree;
944
- rootTreePrefetchText: (payload: SegmentPrefetchTree, format?: 'json' | 'flight') => string;
929
+ pathname: string
930
+ isStatic: boolean
931
+ staleTimeSeconds?: number
932
+ buildId?: string
933
+ routeId?: string
934
+ bodySizeBytes?: number
935
+ inlineBudgetBytes?: number
936
+ runtimePrefetch?: boolean
937
+ postponed?: boolean
938
+ }) => SegmentPrefetchTree
939
+ rootTreePrefetchText: (payload: SegmentPrefetchTree, format?: 'json' | 'flight') => string
945
940
  buildSegmentMeta: (options: {
946
- status: number;
947
- staleTime: number;
948
- postponed: boolean;
949
- bodySizeBytes?: number;
950
- inlineBudgetBytes?: number;
951
- prefetchHints?: Record<string, number>;
952
- }) => SegmentMetaLike;
941
+ status: number
942
+ staleTime: number
943
+ postponed: boolean
944
+ bodySizeBytes?: number
945
+ inlineBudgetBytes?: number
946
+ prefetchHints?: Record<string, number>
947
+ }) => SegmentMetaLike
953
948
  /**
954
949
  * `--experimental-build-mode generate` prerender diagnostics: Next's exact
955
950
  * blocking-prerender error block for a cacheComponents route that cannot be
@@ -957,11 +952,11 @@ export interface BuildCompatExtensions {
957
952
  * diagnostics (generate never fails).
958
953
  */
959
954
  diagnoseCacheComponentsPrerender: (input: {
960
- route: string;
961
- pageFile: string;
962
- appPath: string;
963
- debugPrerender: boolean;
964
- }) => string | undefined;
955
+ route: string
956
+ pageFile: string
957
+ appPath: string
958
+ debugPrerender: boolean
959
+ }) => string | undefined
965
960
  /**
966
961
  * The shared "Error occurred prerendering page" + export-error footer.
967
962
  * `omitErrorLine` drops the leading error line for diagnostics that already
@@ -971,24 +966,24 @@ export interface BuildCompatExtensions {
971
966
  route: string,
972
967
  debugPrerender: boolean,
973
968
  omitErrorLine?: boolean,
974
- ) => string;
969
+ ) => string
975
970
  /** Whether a diagnostic block already opens with the prerender-error line. */
976
- diagnosticLeadsWithErrorLine: (diagnostic: string) => boolean;
971
+ diagnosticLeadsWithErrorLine: (diagnostic: string) => boolean
977
972
  /**
978
973
  * Persist build inputs the SERVING runtime needs (compat: the
979
974
  * `--debug-prerender` flag, which selects the shape of the runtime
980
975
  * 'use cache' error log). Pure-core default: no-op.
981
976
  */
982
- recordBuildFlags: (outPath: string, debugPrerender: boolean) => void;
983
- segmentDir: (outPath: string, routeId: string) => string;
984
- treeSegmentFile: (outPath: string, routeId: string) => string;
985
- bodySegmentFile: (outPath: string, routeId: string) => string;
986
- segmentMetaFile: (outPath: string, routeId: string) => string;
977
+ recordBuildFlags: (outPath: string, debugPrerender: boolean) => void
978
+ segmentDir: (outPath: string, routeId: string) => string
979
+ treeSegmentFile: (outPath: string, routeId: string) => string
980
+ bodySegmentFile: (outPath: string, routeId: string) => string
981
+ segmentMetaFile: (outPath: string, routeId: string) => string
987
982
  }
988
983
 
989
984
  /** Which entry point is running the init hooks (`pnext build` vs a server). */
990
985
  export interface InitHookContext {
991
- build: boolean;
986
+ build: boolean
992
987
  }
993
988
 
994
989
  /**
@@ -997,21 +992,21 @@ export interface InitHookContext {
997
992
  */
998
993
  export interface BuildParallelPhase {
999
994
  /** Label for the reported line ("Typecheck"). */
1000
- name: string;
995
+ name: string
1001
996
  /** Resolves with the phase's OWN elapsed ms (not the time spent awaiting it). */
1002
- run: Promise<number>;
997
+ run: Promise<number>
1003
998
  }
1004
999
 
1005
1000
  export interface BuildExtensions {
1006
1001
  /** Ordered build steps (compat registers action discovery + server-reference manifest). */
1007
- steps: BuildStep[];
1002
+ steps: BuildStep[]
1008
1003
  /** Ordered hooks run after manifest.json is written. */
1009
- completeHooks: BuildCompleteHook[];
1004
+ completeHooks: BuildCompleteHook[]
1010
1005
  /** Init hooks run at the start of build + start (compat registers installCompatFetchCache). */
1011
- initHooks: ((config: ResolvedConfig, context: InitHookContext) => void)[];
1006
+ initHooks: ((config: ResolvedConfig, context: InitHookContext) => void)[]
1012
1007
  /** Background phases started by a build step, awaited before the summary. */
1013
- parallelPhases: BuildParallelPhase[];
1014
- compat: BuildCompatExtensions;
1008
+ parallelPhases: BuildParallelPhase[]
1009
+ compat: BuildCompatExtensions
1015
1010
  }
1016
1011
 
1017
1012
  function createBuildExtensions(): BuildExtensions {
@@ -1033,10 +1028,10 @@ function createBuildExtensions(): BuildExtensions {
1033
1028
  options.staleTimeSeconds ??
1034
1029
  (options.isStatic
1035
1030
  ? compat.defaultStaticStaleTimeSeconds
1036
- : compat.defaultDynamicStaleTimeSeconds);
1037
- const bodySize = options.bodySizeBytes ?? 0;
1038
- const budget = options.inlineBudgetBytes ?? 32 * 1024;
1039
- const canInlineBody = options.isStatic && !options.postponed && bodySize <= budget;
1031
+ : compat.defaultDynamicStaleTimeSeconds)
1032
+ const bodySize = options.bodySizeBytes ?? 0
1033
+ const budget = options.inlineBudgetBytes ?? 32 * 1024
1034
+ const canInlineBody = options.isStatic && !options.postponed && bodySize <= budget
1040
1035
  return {
1041
1036
  tree: {
1042
1037
  name: '',
@@ -1055,53 +1050,58 @@ function createBuildExtensions(): BuildExtensions {
1055
1050
  },
1056
1051
  staleTime,
1057
1052
  isStatic: options.isStatic,
1058
- };
1053
+ }
1059
1054
  },
1060
1055
  rootTreePrefetchText: (payload, format = 'json') => {
1061
- const json = JSON.stringify(payload);
1062
- return format === 'flight' ? `0:${json}` : json;
1056
+ const json = JSON.stringify(payload)
1057
+ return format === 'flight' ? `0:${json}` : json
1063
1058
  },
1064
1059
  buildSegmentMeta: options => {
1065
1060
  const inlined =
1066
1061
  !options.postponed &&
1067
1062
  options.bodySizeBytes !== undefined &&
1068
- options.bodySizeBytes <= (options.inlineBudgetBytes ?? 32 * 1024);
1063
+ options.bodySizeBytes <= (options.inlineBudgetBytes ?? 32 * 1024)
1069
1064
  return {
1070
1065
  status: options.status,
1071
1066
  staleTime: options.staleTime,
1072
1067
  postponed: options.postponed,
1073
1068
  segmentPaths: ['/_tree', '/'],
1074
- ...(options.bodySizeBytes !== undefined ? { segmentSizes: { '/': options.bodySizeBytes } } : {}),
1069
+ ...(options.bodySizeBytes !== undefined
1070
+ ? { segmentSizes: { '/': options.bodySizeBytes } }
1071
+ : {}),
1075
1072
  ...(inlined ? { inlinedSegmentPaths: ['/'] } : {}),
1076
1073
  ...(options.prefetchHints ? { prefetchHints: options.prefetchHints } : {}),
1077
- };
1074
+ }
1078
1075
  },
1079
1076
  diagnoseCacheComponentsPrerender: () => undefined,
1080
1077
  prerenderFailureFooter: () => '',
1081
1078
  diagnosticLeadsWithErrorLine: () => false,
1082
1079
  recordBuildFlags: () => undefined,
1083
1080
  segmentDir: (outPath, routeId) => `${outPath}/segments/${routeId}`,
1084
- treeSegmentFile: (outPath, routeId) => `${compat.segmentDir(outPath, routeId)}/_tree.segment.rsc`,
1085
- bodySegmentFile: (outPath, routeId) => `${compat.segmentDir(outPath, routeId)}/index.segment.rsc`,
1086
- segmentMetaFile: (outPath, routeId) => `${compat.segmentDir(outPath, routeId)}/route.segment.meta`,
1087
- };
1088
- return { steps: [], completeHooks: [], initHooks: [], parallelPhases: [], compat };
1081
+ treeSegmentFile: (outPath, routeId) =>
1082
+ `${compat.segmentDir(outPath, routeId)}/_tree.segment.rsc`,
1083
+ bodySegmentFile: (outPath, routeId) =>
1084
+ `${compat.segmentDir(outPath, routeId)}/index.segment.rsc`,
1085
+ segmentMetaFile: (outPath, routeId) =>
1086
+ `${compat.segmentDir(outPath, routeId)}/route.segment.meta`,
1087
+ }
1088
+ return { steps: [], completeHooks: [], initHooks: [], parallelPhases: [], compat }
1089
1089
  }
1090
1090
 
1091
1091
  export function getBuildExtensions(): BuildExtensions {
1092
- return activeHost.build;
1092
+ return activeHost.build
1093
1093
  }
1094
1094
 
1095
1095
  export function setBuildCompatExtensions(overrides: Partial<BuildCompatExtensions>): void {
1096
- Object.assign(activeHost.build.compat, overrides);
1096
+ Object.assign(activeHost.build.compat, overrides)
1097
1097
  }
1098
1098
 
1099
1099
  export function registerBuildSteps(...steps: BuildStep[]): void {
1100
- activeHost.build.steps.push(...steps);
1100
+ activeHost.build.steps.push(...steps)
1101
1101
  }
1102
1102
 
1103
1103
  export function registerBuildCompleteHooks(...hooks: BuildCompleteHook[]): void {
1104
- activeHost.build.completeHooks.push(...hooks);
1104
+ activeHost.build.completeHooks.push(...hooks)
1105
1105
  }
1106
1106
 
1107
1107
  /**
@@ -1113,36 +1113,39 @@ export function registerBuildCompleteHooks(...hooks: BuildCompleteHook[]): void
1113
1113
  export function registerBuildParallelPhases(...phases: BuildParallelPhase[]): void {
1114
1114
  for (const phase of phases) {
1115
1115
  phase.run.catch((error: unknown) => {
1116
- parallelPhaseErrors.set(phase, error);
1117
- });
1116
+ parallelPhaseErrors.set(phase, error)
1117
+ })
1118
1118
  }
1119
- activeHost.build.parallelPhases.push(...phases);
1119
+ activeHost.build.parallelPhases.push(...phases)
1120
1120
  }
1121
1121
 
1122
- const parallelPhaseErrors = new WeakMap<BuildParallelPhase, unknown>();
1122
+ const parallelPhaseErrors = new WeakMap<BuildParallelPhase, unknown>()
1123
1123
 
1124
1124
  /** Drop the previous build's phases (one process can run several builds). */
1125
1125
  export function clearBuildParallelPhases(): void {
1126
- activeHost.build.parallelPhases.length = 0;
1126
+ activeHost.build.parallelPhases.length = 0
1127
1127
  }
1128
1128
 
1129
1129
  /** The first registered phase that has ALREADY failed, if any. */
1130
1130
  export function buildParallelPhaseError(): unknown {
1131
1131
  for (const phase of activeHost.build.parallelPhases) {
1132
- if (parallelPhaseErrors.has(phase)) return parallelPhaseErrors.get(phase);
1132
+ if (parallelPhaseErrors.has(phase)) return parallelPhaseErrors.get(phase)
1133
1133
  }
1134
- return undefined;
1134
+ return undefined
1135
1135
  }
1136
1136
 
1137
1137
  export function registerInitHooks(
1138
1138
  ...hooks: ((config: ResolvedConfig, context: InitHookContext) => void)[]
1139
1139
  ): void {
1140
- activeHost.build.initHooks.push(...hooks);
1140
+ activeHost.build.initHooks.push(...hooks)
1141
1141
  }
1142
1142
 
1143
1143
  /** Run every registered init hook (core calls at build + start startup). */
1144
- export function runInitHooks(config: ResolvedConfig, context: InitHookContext = { build: false }): void {
1145
- for (const hook of activeHost.build.initHooks) hook(config, context);
1144
+ export function runInitHooks(
1145
+ config: ResolvedConfig,
1146
+ context: InitHookContext = { build: false },
1147
+ ): void {
1148
+ for (const hook of activeHost.build.initHooks) hook(config, context)
1146
1149
  }
1147
1150
 
1148
1151
  // Routing extensions - compat registers extra convention filenames (with their boundary semantics)
@@ -1156,8 +1159,8 @@ export function runInitHooks(config: ResolvedConfig, context: InitHookContext =
1156
1159
  * scanner treats like error/not-found (collected into a route's special files).
1157
1160
  */
1158
1161
  export interface RouteConvention {
1159
- name: string;
1160
- boundary: boolean;
1162
+ name: string
1163
+ boundary: boolean
1161
1164
  }
1162
1165
 
1163
1166
  /**
@@ -1166,28 +1169,28 @@ export interface RouteConvention {
1166
1169
  * import detectors (next/headers, next/navigation request hooks, next/server
1167
1170
  * connection()). Core runs these in addition to its own generic checks.
1168
1171
  */
1169
- export type UsageDetector = (source: string) => boolean;
1172
+ export type UsageDetector = (source: string) => boolean
1170
1173
 
1171
1174
  /** A route module and its rewritten source, supplied across the full import graph. */
1172
1175
  export interface RouteDependencySource {
1173
- file: string;
1174
- source: string;
1176
+ file: string
1177
+ source: string
1175
1178
  }
1176
1179
 
1177
1180
  /** Generic route facts an extension can classify from a transitive module graph. */
1178
1181
  export interface RouteDependencyContext {
1179
- kind: 'page' | 'handler';
1180
- files: readonly RouteDependencySource[];
1182
+ kind: 'page' | 'handler'
1183
+ files: readonly RouteDependencySource[]
1181
1184
  }
1182
1185
 
1183
1186
  /** Extension-owned classification. Labels are opaque to core. */
1184
1187
  export interface RouteDependencyClassification {
1185
- usesRequest?: boolean;
1188
+ usesRequest?: boolean
1186
1189
  }
1187
1190
 
1188
1191
  export type RouteDependencyClassifier = (
1189
1192
  context: RouteDependencyContext,
1190
- ) => RouteDependencyClassification | undefined;
1193
+ ) => RouteDependencyClassification | undefined
1191
1194
 
1192
1195
  /**
1193
1196
  * A source predicate that requires a client entry, paired with the REASON it fired. Reasons are the
@@ -1195,19 +1198,19 @@ export type RouteDependencyClassifier = (
1195
1198
  * `<Link>` needs none of the action machinery - so every detector says which fact it observed.
1196
1199
  */
1197
1200
  export interface ClientEntryDetector {
1198
- reason: ClientEntryReason;
1199
- detect: UsageDetector;
1201
+ reason: ClientEntryReason
1202
+ detect: UsageDetector
1200
1203
  }
1201
1204
 
1202
1205
  export interface RoutingExtensions {
1203
1206
  /** Extra convention filenames compat wants discovered (forbidden/unauthorized/...). */
1204
- conventions: RouteConvention[];
1207
+ conventions: RouteConvention[]
1205
1208
  /** Predicates that mark a page/layout source as request-dependent. */
1206
- usageDetection: UsageDetector[];
1209
+ usageDetection: UsageDetector[]
1207
1210
  /** Classifiers that inspect a route's complete module graph. */
1208
- dependencyClassification: RouteDependencyClassifier[];
1211
+ dependencyClassification: RouteDependencyClassifier[]
1209
1212
  /** Reason-tagged predicates that require a client entry for a server-only page. */
1210
- clientEntryDetection: ClientEntryDetector[];
1213
+ clientEntryDetection: ClientEntryDetector[]
1211
1214
  /**
1212
1215
  * Extra file extensions (without the leading dot) the route scanner should
1213
1216
  * treat as page/convention files, ADDITIVE to core's built-in
@@ -1216,7 +1219,7 @@ export interface RoutingExtensions {
1216
1219
  * registration at bootstrap (before scanRoutes) is honored. Order-preserving,
1217
1220
  * de-duplicated against the base list.
1218
1221
  */
1219
- pageExtensions: string[];
1222
+ pageExtensions: string[]
1220
1223
  /**
1221
1224
  * Why every page route must ship the client router entry, even a purely
1222
1225
  * server-rendered one with no client references. Next always emits its
@@ -1224,7 +1227,7 @@ export interface RoutingExtensions {
1224
1227
  * on every document) and registers `compat-parity` here; a pure-core app
1225
1228
  * keeps the lean "no client code, no bundle" default with an empty set.
1226
1229
  */
1227
- alwaysClientEntryReasons: Set<ClientEntryReason>;
1230
+ alwaysClientEntryReasons: Set<ClientEntryReason>
1228
1231
  }
1229
1232
 
1230
1233
  function createRoutingExtensions(): RoutingExtensions {
@@ -1235,32 +1238,34 @@ function createRoutingExtensions(): RoutingExtensions {
1235
1238
  clientEntryDetection: [],
1236
1239
  pageExtensions: [],
1237
1240
  alwaysClientEntryReasons: new Set(),
1238
- };
1241
+ }
1239
1242
  }
1240
1243
 
1241
1244
  export function getRoutingExtensions(): RoutingExtensions {
1242
- return activeHost.routing;
1245
+ return activeHost.routing
1243
1246
  }
1244
1247
 
1245
1248
  /** Register extra route convention filenames (compat: forbidden/unauthorized). */
1246
1249
  export function registerRouteConventions(...conventions: RouteConvention[]): void {
1247
- activeHost.routing.conventions.push(...conventions);
1250
+ activeHost.routing.conventions.push(...conventions)
1248
1251
  }
1249
1252
 
1250
1253
  /** Register request-dependency usage detectors (compat: next/* import patterns). */
1251
1254
  export function registerUsageDetectors(...detectors: UsageDetector[]): void {
1252
- activeHost.routing.usageDetection.push(...detectors);
1255
+ activeHost.routing.usageDetection.push(...detectors)
1253
1256
  }
1254
1257
 
1255
1258
  /** Register transitive route-dependency classifiers. */
1256
- export function registerRouteDependencyClassifiers(...classifiers: RouteDependencyClassifier[]): void {
1257
- activeHost.routing.dependencyClassification.push(...classifiers);
1259
+ export function registerRouteDependencyClassifiers(
1260
+ ...classifiers: RouteDependencyClassifier[]
1261
+ ): void {
1262
+ activeHost.routing.dependencyClassification.push(...classifiers)
1258
1263
  }
1259
1264
 
1260
1265
  /** Register reason-tagged client-entry detectors (compat: server-action forms, next/form). */
1261
1266
  export function registerClientEntryDetectors(...detectors: ClientEntryDetector[]): void {
1262
- activeHost.routing.clientEntryDetection.push(...detectors);
1263
- clientEntryReasonCache.clear();
1267
+ activeHost.routing.clientEntryDetection.push(...detectors)
1268
+ clientEntryReasonCache.clear()
1264
1269
  }
1265
1270
 
1266
1271
  /**
@@ -1278,82 +1283,82 @@ export function registerClientEntryDetectors(...detectors: ClientEntryDetector[]
1278
1283
  // Listeners stay module-global: a consumer latches the set once (the server
1279
1284
  // load plugin's per-root filter regex) and must keep hearing about it across a
1280
1285
  // host swap, which changes the set exactly like a registration does.
1281
- const loadableExtensionListeners: (() => void)[] = [];
1286
+ const loadableExtensionListeners: (() => void)[] = []
1282
1287
 
1283
1288
  export function onLoadableExtensionsChanged(listener: () => void): void {
1284
- loadableExtensionListeners.push(listener);
1289
+ loadableExtensionListeners.push(listener)
1285
1290
  }
1286
1291
 
1287
1292
  export function registerLoadableExtensions(...extensions: string[]): void {
1288
- const loadable = activeHost.loadable;
1289
- const fresh = [...new Set(extensions)].filter(ext => !loadable.includes(ext));
1290
- if (fresh.length === 0) return;
1291
- loadable.push(...fresh);
1292
- for (const listener of loadableExtensionListeners) listener();
1293
+ const loadable = activeHost.loadable
1294
+ const fresh = [...new Set(extensions)].filter(ext => !loadable.includes(ext))
1295
+ if (fresh.length === 0) return
1296
+ loadable.push(...fresh)
1297
+ for (const listener of loadableExtensionListeners) listener()
1293
1298
  }
1294
1299
 
1295
1300
  /** Page extensions plus import-only loadable extensions, deduped. */
1296
1301
  export function extraLoadableExtensions(): string[] {
1297
- return [...new Set([...activeHost.routing.pageExtensions, ...activeHost.loadable])];
1302
+ return [...new Set([...activeHost.routing.pageExtensions, ...activeHost.loadable])]
1298
1303
  }
1299
1304
 
1300
1305
  export function registerPageExtensions(...extensions: string[]): void {
1301
- const { pageExtensions } = activeHost.routing;
1302
- const fresh = [...new Set(extensions)].filter(ext => !pageExtensions.includes(ext));
1303
- if (fresh.length === 0) return;
1304
- pageExtensions.push(...fresh);
1305
- for (const listener of loadableExtensionListeners) listener();
1306
+ const { pageExtensions } = activeHost.routing
1307
+ const fresh = [...new Set(extensions)].filter(ext => !pageExtensions.includes(ext))
1308
+ if (fresh.length === 0) return
1309
+ pageExtensions.push(...fresh)
1310
+ for (const listener of loadableExtensionListeners) listener()
1306
1311
  }
1307
1312
 
1308
1313
  /** Record a reason every page route must ship the client router entry. */
1309
1314
  export function registerAlwaysClientEntryReason(reason: ClientEntryReason): void {
1310
- activeHost.routing.alwaysClientEntryReasons.add(reason);
1315
+ activeHost.routing.alwaysClientEntryReasons.add(reason)
1311
1316
  }
1312
1317
 
1313
1318
  /** Why every page ships the router entry; empty for a pure-core app. */
1314
1319
  export function alwaysClientEntryReasons(): ClientEntryReason[] {
1315
- return [...activeHost.routing.alwaysClientEntryReasons];
1320
+ return [...activeHost.routing.alwaysClientEntryReasons]
1316
1321
  }
1317
1322
 
1318
1323
  /** Extra page-file extensions compat registered, in registration order. */
1319
1324
  export function extraPageExtensions(): string[] {
1320
- return activeHost.routing.pageExtensions;
1325
+ return activeHost.routing.pageExtensions
1321
1326
  }
1322
1327
 
1323
1328
  /** The extra boundary-convention names core routing must discover as special files. */
1324
1329
  export function extraBoundaryConventionNames(): string[] {
1325
- return activeHost.routing.conventions.filter(c => c.boundary).map(c => c.name);
1330
+ return activeHost.routing.conventions.filter(c => c.boundary).map(c => c.name)
1326
1331
  }
1327
1332
 
1328
1333
  /** True when any registered usage detector marks `source` as request-dependent. */
1329
1334
  export function sourceUsesRegisteredRequestApi(source: string): boolean {
1330
- return activeHost.routing.usageDetection.some(detect => detect(source));
1335
+ return activeHost.routing.usageDetection.some(detect => detect(source))
1331
1336
  }
1332
1337
 
1333
1338
  /** Merge extension classifications for a route's complete module graph. */
1334
1339
  export function classifyRouteDependencies(
1335
1340
  context: RouteDependencyContext,
1336
1341
  ): RouteDependencyClassification {
1337
- const classification: RouteDependencyClassification = {};
1342
+ const classification: RouteDependencyClassification = {}
1338
1343
  for (const classify of activeHost.routing.dependencyClassification) {
1339
- const result = classify(context);
1340
- if (!result) continue;
1341
- if (result.usesRequest) classification.usesRequest = true;
1344
+ const result = classify(context)
1345
+ if (!result) continue
1346
+ if (result.usesRequest) classification.usesRequest = true
1342
1347
  }
1343
- return classification;
1348
+ return classification
1344
1349
  }
1345
1350
 
1346
1351
  /** Every reason a registered detector requires a client entry for this source. */
1347
1352
  export function sourceClientEntryReasons(source: string): ClientEntryReason[] {
1348
- const key = `${source.length}\0${Bun.hash(source).toString(36)}`;
1349
- const cached = clientEntryReasonCache.get(key);
1350
- if (cached) return cached;
1351
- const reasons: ClientEntryReason[] = [];
1353
+ const key = `${source.length}\0${Bun.hash(source).toString(36)}`
1354
+ const cached = clientEntryReasonCache.get(key)
1355
+ if (cached) return cached
1356
+ const reasons: ClientEntryReason[] = []
1352
1357
  for (const { reason, detect } of activeHost.routing.clientEntryDetection) {
1353
- if (!reasons.includes(reason) && detect(source)) reasons.push(reason);
1358
+ if (!reasons.includes(reason) && detect(source)) reasons.push(reason)
1354
1359
  }
1355
- clientEntryReasonCache.set(key, reasons);
1356
- return reasons;
1360
+ clientEntryReasonCache.set(key, reasons)
1361
+ return reasons
1357
1362
  }
1358
1363
 
1359
1364
  // ---------------------------------------------------------------------------
@@ -1362,22 +1367,22 @@ export function sourceClientEntryReasons(source: string): ClientEntryReason[] {
1362
1367
 
1363
1368
  export interface ProxyExtensions {
1364
1369
  /** File basenames core should consider as request proxy entrypoints. */
1365
- names: readonly string[];
1370
+ names: readonly string[]
1366
1371
  /** Optional validation hook for framework-specific proxy diagnostics. */
1367
- validateFiles: (config: ResolvedConfig) => Promise<void>;
1372
+ validateFiles: (config: ResolvedConfig) => Promise<void>
1368
1373
  /** Pick the handler export from a loaded proxy module. */
1369
- handlerExport: (module: Record<string, unknown>) => unknown;
1374
+ handlerExport: (module: Record<string, unknown>) => unknown
1370
1375
  /** Preserve the original proxy URL and Flight headers for advanced routing. */
1371
- skipUrlNormalize: () => boolean;
1376
+ skipUrlNormalize: () => boolean
1372
1377
  /** Framework locale derived from the proxy request URL. */
1373
- locale: (url: URL) => string;
1378
+ locale: (url: URL) => string
1374
1379
  /** Notify compat before an external proxy rewrite is fetched. */
1375
- onExternalRewrite: (request: Request) => void;
1380
+ onExternalRewrite: (request: Request) => void
1376
1381
  /**
1377
1382
  * Max request-body bytes buffered on a proxied request before truncation
1378
1383
  * (compat maps experimental.proxyClientMaxBodySize; Next's default is 10MB).
1379
1384
  */
1380
- clientMaxBodySize: () => number;
1385
+ clientMaxBodySize: () => number
1381
1386
  }
1382
1387
 
1383
1388
  function createProxyExtensions(): ProxyExtensions {
@@ -1389,15 +1394,15 @@ function createProxyExtensions(): ProxyExtensions {
1389
1394
  locale: () => '',
1390
1395
  onExternalRewrite: request => void request,
1391
1396
  clientMaxBodySize: () => 10 * 1024 * 1024,
1392
- };
1397
+ }
1393
1398
  }
1394
1399
 
1395
1400
  export function getProxyExtensions(): ProxyExtensions {
1396
- return activeHost.proxy;
1401
+ return activeHost.proxy
1397
1402
  }
1398
1403
 
1399
1404
  export function setProxyExtensions(overrides: Partial<ProxyExtensions>): void {
1400
- Object.assign(activeHost.proxy, overrides);
1405
+ Object.assign(activeHost.proxy, overrides)
1401
1406
  }
1402
1407
 
1403
1408
  // Bundler extensions - populated by compat/cache/use-cache-transform, compat/actions/rewrite and
@@ -1409,17 +1414,17 @@ export function setProxyExtensions(overrides: Partial<ProxyExtensions>): void {
1409
1414
  * compat transforms accept a root for id derivation, so it is threaded through.
1410
1415
  */
1411
1416
  export interface ServerSourceTransform {
1412
- (source: string, file: string, root?: string): string;
1417
+ (source: string, file: string, root?: string): string
1413
1418
  /**
1414
1419
  * Cheap trigger tokens (`includes`, or a `test` for the few shapes whitespace makes non-literal). The
1415
1420
  * transform is skipped when the source matches none of them, so it must be a SUPERSET of the transform's
1416
1421
  * own exact gate - an empty array means "configured off, never fires". Attach with `withSniff`. Absent
1417
1422
  * means ungated: the transform always runs and disables the chain gate.
1418
1423
  */
1419
- sniff?: readonly SniffToken[];
1424
+ sniff?: readonly SniffToken[]
1420
1425
  }
1421
1426
 
1422
- export type SniffToken = string | RegExp;
1427
+ export type SniffToken = string | RegExp
1423
1428
 
1424
1429
  /**
1425
1430
  * A client-source transform that must await IO (compat: worker bundling emits a
@@ -1428,60 +1433,64 @@ export type SniffToken = string | RegExp;
1428
1433
  * sees the original source.
1429
1434
  */
1430
1435
  export interface AsyncSourceTransform {
1431
- (source: string, file: string, root?: string): Promise<string>;
1432
- sniff?: readonly SniffToken[];
1436
+ (source: string, file: string, root?: string): Promise<string>
1437
+ sniff?: readonly SniffToken[]
1433
1438
  }
1434
1439
 
1435
1440
  export interface BundlerExtensions {
1436
1441
  /** Ordered source transforms that must run before generic server transforms. */
1437
- serverSourcePreTransforms: ServerSourceTransform[];
1442
+ serverSourcePreTransforms: ServerSourceTransform[]
1438
1443
  /** Ordered server-source transforms (compat: use-cache + inline-action tags). */
1439
- serverSourceTransforms: ServerSourceTransform[];
1444
+ serverSourceTransforms: ServerSourceTransform[]
1440
1445
  /** Ordered client-source transforms (compat: next/font + next/root-params). */
1441
- clientSourceTransforms: ServerSourceTransform[];
1446
+ clientSourceTransforms: ServerSourceTransform[]
1442
1447
  /** Awaitable client-source transforms run before `clientSourceTransforms`. */
1443
- clientSourceAsyncPreTransforms: AsyncSourceTransform[];
1448
+ clientSourceAsyncPreTransforms: AsyncSourceTransform[]
1444
1449
  /**
1445
1450
  * Transforms applied to already-BUNDLED server output (vendor bundles). Only the passes whose trigger
1446
1451
  * survives bundling belong here - a package can ship a `'use cache'` function, but its imports and aliases
1447
1452
  * were already resolved by the bundler and its `define` constants inlined by esbuild.
1448
1453
  */
1449
- bundledSourceTransforms: ServerSourceTransform[];
1454
+ bundledSourceTransforms: ServerSourceTransform[]
1450
1455
  /** esbuild plugins appended to every client build (compat: action client stub). */
1451
- clientEsbuildPlugins: (config: ResolvedConfig) => Plugin[];
1456
+ clientEsbuildPlugins: (config: ResolvedConfig) => Plugin[]
1452
1457
  /** esbuild plugins appended to every server build (compat: action client stub). */
1453
- serverEsbuildPlugins: (config: ResolvedConfig, options?: ServerEsbuildPluginOptions) => Plugin[];
1458
+ serverEsbuildPlugins: (config: ResolvedConfig, options?: ServerEsbuildPluginOptions) => Plugin[]
1454
1459
  /**
1455
1460
  * Entry-point rewrite consulted where a server bundle's entry is already
1456
1461
  * resolved (compat: the CJS default-interop marker, so its plugin never
1457
1462
  * needs a catch-all onResolve). undefined = use the specifier as-is.
1458
1463
  */
1459
- serverBundleEntry: (specifier: string, resolveDir: string, resolved?: string) => string | undefined;
1464
+ serverBundleEntry: (
1465
+ specifier: string,
1466
+ resolveDir: string,
1467
+ resolved?: string,
1468
+ ) => string | undefined
1460
1469
  /**
1461
1470
  * esbuild `define` constants for every server compile (compat: compiler.define + compiler.defineServer).
1462
1471
  * Lexical by construction - unlike a textual pass it never rewrites inside string literals or comments.
1463
1472
  */
1464
- serverDefines: () => Record<string, string>;
1473
+ serverDefines: () => Record<string, string>
1465
1474
  /** Same, for the client graph (compat: compiler.define; defineServer -> undefined). */
1466
- clientDefines: () => Record<string, string>;
1475
+ clientDefines: () => Record<string, string>
1467
1476
  /**
1468
1477
  * Files injected into every client entry graph for their side effects
1469
1478
  * (compat: core-js polyfills under experimental.swcEnvOptions).
1470
1479
  */
1471
- clientInjects: () => string[];
1480
+ clientInjects: () => string[]
1472
1481
  /** Resolve compat-owned package edges while scanning route dependencies. */
1473
- resolveRouteDependency: (root: string, fromFile: string, specifier: string) => string | undefined;
1482
+ resolveRouteDependency: (root: string, fromFile: string, specifier: string) => string | undefined
1474
1483
  /**
1475
1484
  * Extra `pure` targets (e.g. `console.log`) for the client esbuild `pure`
1476
1485
  * option, so calls with unused results are dropped (compat: compiler.removeConsole).
1477
1486
  */
1478
- clientPureFunctions: (config: ResolvedConfig) => string[];
1487
+ clientPureFunctions: (config: ResolvedConfig) => string[]
1479
1488
  /**
1480
1489
  * Standalone static chunks written verbatim into the client `chunks/` dir,
1481
1490
  * independent of the esbuild entry graph (compat: the no-module polyfills
1482
1491
  * chunk). Pure-core apps emit none.
1483
1492
  */
1484
- staticClientChunks: (config: ResolvedConfig) => { name: string; contents: string }[];
1493
+ staticClientChunks: (config: ResolvedConfig) => { name: string; contents: string }[]
1485
1494
  }
1486
1495
 
1487
1496
  function createBundlerExtensions(): BundlerExtensions {
@@ -1500,11 +1509,11 @@ function createBundlerExtensions(): BundlerExtensions {
1500
1509
  resolveRouteDependency: () => undefined,
1501
1510
  clientPureFunctions: () => [],
1502
1511
  staticClientChunks: () => [],
1503
- };
1512
+ }
1504
1513
  }
1505
1514
 
1506
1515
  export function getBundlerExtensions(): BundlerExtensions {
1507
- return activeHost.bundler;
1516
+ return activeHost.bundler
1508
1517
  }
1509
1518
 
1510
1519
  /**
@@ -1512,32 +1521,32 @@ export function getBundlerExtensions(): BundlerExtensions {
1512
1521
  * the options; unconfigured apps get `{}` and esbuild sees no `define` at all.
1513
1522
  */
1514
1523
  export function serverDefineOptions(): { define?: Record<string, string> } {
1515
- const define = activeHost.bundler.serverDefines();
1516
- return Object.keys(define).length > 0 ? { define } : {};
1524
+ const define = activeHost.bundler.serverDefines()
1525
+ return Object.keys(define).length > 0 ? { define } : {}
1517
1526
  }
1518
1527
 
1519
1528
  export function registerServerSourceTransforms(...transforms: ServerSourceTransform[]): void {
1520
- activeHost.bundler.serverSourceTransforms.push(...transforms);
1521
- activeHost.serverSniff = undefined;
1529
+ activeHost.bundler.serverSourceTransforms.push(...transforms)
1530
+ activeHost.serverSniff = undefined
1522
1531
  }
1523
1532
 
1524
1533
  export function registerServerSourcePreTransforms(...transforms: ServerSourceTransform[]): void {
1525
- activeHost.bundler.serverSourcePreTransforms.push(...transforms);
1526
- activeHost.serverSniff = undefined;
1534
+ activeHost.bundler.serverSourcePreTransforms.push(...transforms)
1535
+ activeHost.serverSniff = undefined
1527
1536
  }
1528
1537
 
1529
1538
  export function registerClientSourceTransforms(...transforms: ServerSourceTransform[]): void {
1530
- activeHost.bundler.clientSourceTransforms.push(...transforms);
1539
+ activeHost.bundler.clientSourceTransforms.push(...transforms)
1531
1540
  }
1532
1541
 
1533
1542
  export function registerClientSourceAsyncPreTransforms(
1534
1543
  ...transforms: AsyncSourceTransform[]
1535
1544
  ): void {
1536
- activeHost.bundler.clientSourceAsyncPreTransforms.push(...transforms);
1545
+ activeHost.bundler.clientSourceAsyncPreTransforms.push(...transforms)
1537
1546
  }
1538
1547
 
1539
1548
  export function registerBundledSourceTransforms(...transforms: ServerSourceTransform[]): void {
1540
- activeHost.bundler.bundledSourceTransforms.push(...transforms);
1549
+ activeHost.bundler.bundledSourceTransforms.push(...transforms)
1541
1550
  }
1542
1551
 
1543
1552
  /**
@@ -1552,14 +1561,14 @@ export function withSniff<T extends ServerSourceTransform | AsyncSourceTransform
1552
1561
  return Object.assign(
1553
1562
  (source: string, file: string, root?: string) => transform(source, file, root),
1554
1563
  { sniff },
1555
- ) as T;
1564
+ ) as T
1556
1565
  }
1557
1566
 
1558
1567
  function sniffHit(source: string, sniff: readonly SniffToken[]): boolean {
1559
1568
  for (const token of sniff) {
1560
- if (typeof token === 'string' ? source.includes(token) : token.test(source)) return true;
1569
+ if (typeof token === 'string' ? source.includes(token) : token.test(source)) return true
1561
1570
  }
1562
- return false;
1571
+ return false
1563
1572
  }
1564
1573
 
1565
1574
  /**
@@ -1570,28 +1579,28 @@ function sniffHit(source: string, sniff: readonly SniffToken[]): boolean {
1570
1579
  * on the host, so a swap starts from the new host's own chain.
1571
1580
  */
1572
1581
  function serverSourceSniff() {
1573
- const host = activeHost;
1574
- if (host.serverSniff) return host.serverSniff;
1575
- const tokens = new Set<string>();
1582
+ const host = activeHost
1583
+ if (host.serverSniff) return host.serverSniff
1584
+ const tokens = new Set<string>()
1576
1585
  for (const transform of [
1577
1586
  ...host.bundler.serverSourcePreTransforms,
1578
1587
  ...host.bundler.serverSourceTransforms,
1579
1588
  ]) {
1580
- if (!transform.sniff) return (host.serverSniff = { pattern: undefined });
1589
+ if (!transform.sniff) return (host.serverSniff = { pattern: undefined })
1581
1590
  for (const token of transform.sniff) {
1582
- tokens.add(`(?:${typeof token === 'string' ? escapeRegex(token) : token.source})`);
1591
+ tokens.add(`(?:${typeof token === 'string' ? escapeRegex(token) : token.source})`)
1583
1592
  }
1584
1593
  }
1585
1594
  // One alternation scan measured cheaper than N `includes` over the same
1586
1595
  // bytes. With no tokens at all (every transform configured off) the chain can
1587
1596
  // never fire, and `new RegExp('')` would match everything.
1588
- return (host.serverSniff = { pattern: new RegExp(tokens.size ? [...tokens].join('|') : '(?!)') });
1597
+ return (host.serverSniff = { pattern: new RegExp(tokens.size ? [...tokens].join('|') : '(?!)') })
1589
1598
  }
1590
1599
 
1591
1600
  /** Whether any registered server-source transform can possibly change `source`. */
1592
1601
  export function sourceNeedsServerTransforms(source: string): boolean {
1593
- const { pattern } = serverSourceSniff();
1594
- return !pattern || pattern.test(source);
1602
+ const { pattern } = serverSourceSniff()
1603
+ return !pattern || pattern.test(source)
1595
1604
  }
1596
1605
 
1597
1606
  function applyTransforms(
@@ -1600,14 +1609,14 @@ function applyTransforms(
1600
1609
  file: string,
1601
1610
  root?: string,
1602
1611
  ): string {
1603
- let next = source;
1612
+ let next = source
1604
1613
  for (const transform of transforms) {
1605
1614
  // Gate on the running source, not the original: an earlier transform can
1606
1615
  // inject a later one's trigger (e.g. next/font emits next/root-params).
1607
- if (transform.sniff && !sniffHit(next, transform.sniff)) continue;
1608
- next = transform(next, file, root);
1616
+ if (transform.sniff && !sniffHit(next, transform.sniff)) continue
1617
+ next = transform(next, file, root)
1609
1618
  }
1610
- return next;
1619
+ return next
1611
1620
  }
1612
1621
 
1613
1622
  export function setBundlerExtensions(
@@ -1622,26 +1631,30 @@ export function setBundlerExtensions(
1622
1631
  >
1623
1632
  >,
1624
1633
  ): void {
1625
- Object.assign(activeHost.bundler, overrides);
1634
+ Object.assign(activeHost.bundler, overrides)
1626
1635
  }
1627
1636
 
1628
1637
  /** Apply every registered pre server-source transform in order. */
1629
- export function applyServerSourcePreTransforms(source: string, file: string, root?: string): string {
1630
- return applyTransforms(activeHost.bundler.serverSourcePreTransforms, source, file, root);
1638
+ export function applyServerSourcePreTransforms(
1639
+ source: string,
1640
+ file: string,
1641
+ root?: string,
1642
+ ): string {
1643
+ return applyTransforms(activeHost.bundler.serverSourcePreTransforms, source, file, root)
1631
1644
  }
1632
1645
 
1633
1646
  /** Apply every registered server-source transform in order. */
1634
1647
  export function applyServerSourceTransforms(source: string, file: string, root?: string): string {
1635
- return applyTransforms(activeHost.bundler.serverSourceTransforms, source, file, root);
1648
+ return applyTransforms(activeHost.bundler.serverSourceTransforms, source, file, root)
1636
1649
  }
1637
1650
 
1638
1651
  export function applyClientSourceTransforms(source: string, file: string, root?: string): string {
1639
- return applyTransforms(activeHost.bundler.clientSourceTransforms, source, file, root);
1652
+ return applyTransforms(activeHost.bundler.clientSourceTransforms, source, file, root)
1640
1653
  }
1641
1654
 
1642
1655
  /** Whether any awaitable client pre-transform is registered at all. */
1643
1656
  export function hasClientSourceAsyncPreTransforms(): boolean {
1644
- return activeHost.bundler.clientSourceAsyncPreTransforms.length > 0;
1657
+ return activeHost.bundler.clientSourceAsyncPreTransforms.length > 0
1645
1658
  }
1646
1659
 
1647
1660
  export async function applyClientSourceAsyncPreTransforms(
@@ -1649,17 +1662,17 @@ export async function applyClientSourceAsyncPreTransforms(
1649
1662
  file: string,
1650
1663
  root?: string,
1651
1664
  ): Promise<string> {
1652
- let next = source;
1665
+ let next = source
1653
1666
  for (const transform of activeHost.bundler.clientSourceAsyncPreTransforms) {
1654
- if (transform.sniff && !sniffHit(next, transform.sniff)) continue;
1655
- next = await transform(next, file, root);
1667
+ if (transform.sniff && !sniffHit(next, transform.sniff)) continue
1668
+ next = await transform(next, file, root)
1656
1669
  }
1657
- return next;
1670
+ return next
1658
1671
  }
1659
1672
 
1660
1673
  /** Apply every registered bundled-output transform in order. */
1661
1674
  export function applyBundledSourceTransforms(source: string, file: string): string {
1662
- return applyTransforms(activeHost.bundler.bundledSourceTransforms, source, file);
1675
+ return applyTransforms(activeHost.bundler.bundledSourceTransforms, source, file)
1663
1676
  }
1664
1677
 
1665
1678
  // ---------------------------------------------------------------------------
@@ -1668,16 +1681,16 @@ export function applyBundledSourceTransforms(source: string, file: string): stri
1668
1681
  // ---------------------------------------------------------------------------
1669
1682
 
1670
1683
  export interface ImportAliasExtensions {
1671
- aliases: (config: ResolvedConfig, target: CompatAliasTarget) => Record<string, string>;
1672
- clientSsrAliases: (config: ResolvedConfig) => Record<string, string>;
1673
- missingImportError: (config: ResolvedConfig, specifier: string) => string | undefined;
1684
+ aliases: (config: ResolvedConfig, target: CompatAliasTarget) => Record<string, string>
1685
+ clientSsrAliases: (config: ResolvedConfig) => Record<string, string>
1686
+ missingImportError: (config: ResolvedConfig, specifier: string) => string | undefined
1674
1687
  /**
1675
1688
  * Extra alias overrides layered on top of `aliases` for modules compiled under the true `react-server`
1676
1689
  * layer (currently proxy/middleware). Distinct from the base server target because pages/api keeps the
1677
1690
  * full-hooks `react` shim for backward compatibility while proxy/middleware must not expose client hooks
1678
1691
  * at all.
1679
1692
  */
1680
- reactServerLayerAliases: (config: ResolvedConfig) => Record<string, string>;
1693
+ reactServerLayerAliases: (config: ResolvedConfig) => Record<string, string>
1681
1694
  }
1682
1695
 
1683
1696
  function createImportAliasExtensions(): ImportAliasExtensions {
@@ -1686,15 +1699,15 @@ function createImportAliasExtensions(): ImportAliasExtensions {
1686
1699
  clientSsrAliases: () => ({}),
1687
1700
  missingImportError: () => undefined,
1688
1701
  reactServerLayerAliases: () => ({}),
1689
- };
1702
+ }
1690
1703
  }
1691
1704
 
1692
1705
  export function getImportAliasExtensions(): ImportAliasExtensions {
1693
- return activeHost.importAlias;
1706
+ return activeHost.importAlias
1694
1707
  }
1695
1708
 
1696
1709
  export function setImportAliasExtensions(overrides: Partial<ImportAliasExtensions>): void {
1697
- Object.assign(activeHost.importAlias, overrides);
1710
+ Object.assign(activeHost.importAlias, overrides)
1698
1711
  }
1699
1712
 
1700
1713
  // ---------------------------------------------------------------------------
@@ -1703,48 +1716,48 @@ export function setImportAliasExtensions(overrides: Partial<ImportAliasExtension
1703
1716
  // ---------------------------------------------------------------------------
1704
1717
 
1705
1718
  export interface ProxyResponseProtocol {
1706
- nextHeader: string;
1707
- rewriteHeader: string;
1719
+ nextHeader: string
1720
+ rewriteHeader: string
1708
1721
  }
1709
1722
 
1710
1723
  function createProxyResponseProtocol(): ProxyResponseProtocol {
1711
1724
  return {
1712
1725
  nextHeader: 'x-pnext-middleware-next',
1713
1726
  rewriteHeader: 'x-pnext-middleware-rewrite',
1714
- };
1727
+ }
1715
1728
  }
1716
1729
 
1717
1730
  export function getProxyResponseProtocol(): ProxyResponseProtocol {
1718
- return activeHost.proxyResponse;
1731
+ return activeHost.proxyResponse
1719
1732
  }
1720
1733
 
1721
1734
  export function setProxyResponseProtocol(overrides: Partial<ProxyResponseProtocol>): void {
1722
- Object.assign(activeHost.proxyResponse, overrides);
1735
+ Object.assign(activeHost.proxyResponse, overrides)
1723
1736
  }
1724
1737
 
1725
1738
  export interface RouterProtocolExtensions {
1726
- prefetchRequestHeaders: () => string[];
1739
+ prefetchRequestHeaders: () => string[]
1727
1740
  /**
1728
1741
  * True when this request should receive only the route's static shell - Suspense/loading fallbacks in
1729
1742
  * place, streamed dynamic continuation cut (Next's partial prefetch: a `next-router-prefetch: 1` request
1730
1743
  * never runs dynamic data). Core consults it in renderPageResponse; the classification policy is compat's.
1731
1744
  */
1732
- shellOnlyRequest: (request: Request, route: RouteManifestEntry) => boolean;
1745
+ shellOnlyRequest: (request: Request, route: RouteManifestEntry) => boolean
1733
1746
  }
1734
1747
 
1735
1748
  function createRouterProtocolExtensions(): RouterProtocolExtensions {
1736
1749
  return {
1737
1750
  prefetchRequestHeaders: () => [],
1738
1751
  shellOnlyRequest: () => false,
1739
- };
1752
+ }
1740
1753
  }
1741
1754
 
1742
1755
  export function getRouterProtocolExtensions(): RouterProtocolExtensions {
1743
- return activeHost.routerProtocol;
1756
+ return activeHost.routerProtocol
1744
1757
  }
1745
1758
 
1746
1759
  export function setRouterProtocolExtensions(overrides: Partial<RouterProtocolExtensions>): void {
1747
- Object.assign(activeHost.routerProtocol, overrides);
1760
+ Object.assign(activeHost.routerProtocol, overrides)
1748
1761
  }
1749
1762
 
1750
1763
  // Asset extensions - compat registers framework-specific handling for imported static assets (next/image
@@ -1760,27 +1773,27 @@ export function setRouterProtocolExtensions(overrides: Partial<RouterProtocolExt
1760
1773
  * let core apply its generic default.
1761
1774
  */
1762
1775
  export interface StaticAssetModuleContext {
1763
- sourcePath: string;
1764
- bytes: Uint8Array;
1765
- emit: (relativePath: string, bytes: Uint8Array) => string;
1776
+ sourcePath: string
1777
+ bytes: Uint8Array
1778
+ emit: (relativePath: string, bytes: Uint8Array) => string
1766
1779
  }
1767
1780
 
1768
1781
  export interface StaticAssetPathContext {
1769
- sourcePath: string;
1770
- hash: string;
1771
- base: string;
1772
- ext: string;
1782
+ sourcePath: string
1783
+ hash: string
1784
+ base: string
1785
+ ext: string
1773
1786
  }
1774
1787
 
1775
1788
  export interface AssetExtensions {
1776
1789
  /** URL path prefixes for emitted assets stored under `<out>/public`. */
1777
- staticAssetPublicPrefixes: () => string[];
1790
+ staticAssetPublicPrefixes: () => string[]
1778
1791
 
1779
1792
  /**
1780
1793
  * POSIX relative public path for core's generic imported-asset module. Compat
1781
1794
  * registers Next's `/_next/static/media` layout.
1782
1795
  */
1783
- staticAssetRelativePath: (context: StaticAssetPathContext) => string;
1796
+ staticAssetRelativePath: (context: StaticAssetPathContext) => string
1784
1797
 
1785
1798
  /**
1786
1799
  * Produce the ESM module text for an imported static asset, or undefined to fall back to core's generic
@@ -1790,7 +1803,7 @@ export interface AssetExtensions {
1790
1803
  */
1791
1804
  staticAssetModule: (
1792
1805
  context: StaticAssetModuleContext,
1793
- ) => string | undefined | Promise<string | undefined>;
1806
+ ) => string | undefined | Promise<string | undefined>
1794
1807
 
1795
1808
  /**
1796
1809
  * Whether a configured `turbopack.rules` loader chain claims this file. When
@@ -1799,7 +1812,7 @@ export interface AssetExtensions {
1799
1812
  * instead (e.g. a `*.svg` loader rule preempting the default image pipeline).
1800
1813
  * Compat registers `hasWebpackLoaderRuleFor`; pure-core apps keep the default.
1801
1814
  */
1802
- hasLoaderRuleFor: (filePath: string) => boolean;
1815
+ hasLoaderRuleFor: (filePath: string) => boolean
1803
1816
 
1804
1817
  /**
1805
1818
  * Run the `turbopack.rules` loader chain configured for `specifier` (which may carry a query) as imported
@@ -1811,7 +1824,7 @@ export interface AssetExtensions {
1811
1824
  loaderRuleModule: (
1812
1825
  specifier: string,
1813
1826
  importer: string,
1814
- ) => string | undefined | Promise<string | undefined>;
1827
+ ) => string | undefined | Promise<string | undefined>
1815
1828
  }
1816
1829
 
1817
1830
  function createAssetExtensions(): AssetExtensions {
@@ -1821,15 +1834,15 @@ function createAssetExtensions(): AssetExtensions {
1821
1834
  staticAssetModule: () => undefined,
1822
1835
  hasLoaderRuleFor: () => false,
1823
1836
  loaderRuleModule: () => undefined,
1824
- };
1837
+ }
1825
1838
  }
1826
1839
 
1827
1840
  export function getAssetExtensions(): AssetExtensions {
1828
- return activeHost.asset;
1841
+ return activeHost.asset
1829
1842
  }
1830
1843
 
1831
1844
  export function setAssetExtensions(overrides: Partial<AssetExtensions>): void {
1832
- Object.assign(activeHost.asset, overrides);
1845
+ Object.assign(activeHost.asset, overrides)
1833
1846
  }
1834
1847
 
1835
1848
  // CSS extras (CORE - no-op defaults; compat populates via register/css-extras).
@@ -1845,35 +1858,35 @@ export function setAssetExtensions(overrides: Partial<AssetExtensions>): void {
1845
1858
 
1846
1859
  export interface CssExtensions {
1847
1860
  /** Extra CSS-like file extensions, including the dot. */
1848
- extraCssExtensions: () => string[];
1861
+ extraCssExtensions: () => string[]
1849
1862
  /** Resolve a bare CSS dependency that normal route scanning leaves external. */
1850
- resolveCssDependency: (root: string, fromFile: string, specifier: string) => string | undefined;
1863
+ resolveCssDependency: (root: string, fromFile: string, specifier: string) => string | undefined
1851
1864
  /** Keep root not-found CSS with its fallback response instead of every matched route. */
1852
- deferRootNotFoundCss: () => boolean;
1865
+ deferRootNotFoundCss: () => boolean
1853
1866
  /** Replace built stylesheet links with document-head markup when compat requires it. */
1854
1867
  inlineStylesheets: (
1855
1868
  config: ResolvedConfig,
1856
1869
  options: { assetNames: string[]; dev: boolean; nonce?: string; prependCss?: string },
1857
- ) => string[] | undefined;
1870
+ ) => string[] | undefined
1858
1871
  /** esbuild plugins for the CSS-chunk builds (compat: sass/scss loader). */
1859
- cssChunkPlugins: () => Plugin[];
1872
+ cssChunkPlugins: () => Plugin[]
1860
1873
  /**
1861
1874
  * The scoped class-name map for a CSS-module file this registry handles
1862
1875
  * (`*.module.{scss,sass}`); undefined to defer to core (`*.module.css`).
1863
1876
  */
1864
- resolveCssModule: (file: string) => Record<string, string> | undefined;
1877
+ resolveCssModule: (file: string) => Record<string, string> | undefined
1865
1878
  /**
1866
1879
  * The ESM module text a client bundle should evaluate for a compat CSS-module
1867
1880
  * import (`export default <map>`); undefined to defer to core.
1868
1881
  */
1869
- loadCssModuleForClient: (file: string) => string | undefined;
1882
+ loadCssModuleForClient: (file: string) => string | undefined
1870
1883
  /**
1871
1884
  * Partition each route's ordered `cssImports` into chunk slices (Next's CSS
1872
1885
  * chunking). Returns `routeId -> ordered segments`, each segment an ordered
1873
1886
  * slice of that route's imports; routes absent from the map (or with a single
1874
1887
  * segment) keep core's single-chunk behaviour.
1875
1888
  */
1876
- planRouteCssChunks: (routes: { id: string; cssImports: string[] }[]) => Map<string, string[][]>;
1889
+ planRouteCssChunks: (routes: { id: string; cssImports: string[] }[]) => Map<string, string[][]>
1877
1890
  }
1878
1891
 
1879
1892
  const cssExtensions: CssExtensions = {
@@ -1885,14 +1898,14 @@ const cssExtensions: CssExtensions = {
1885
1898
  resolveCssModule: () => undefined,
1886
1899
  loadCssModuleForClient: () => undefined,
1887
1900
  planRouteCssChunks: () => new Map(),
1888
- };
1901
+ }
1889
1902
 
1890
- restoreWithExtensionHost(cssExtensions);
1903
+ restoreWithExtensionHost(cssExtensions)
1891
1904
 
1892
1905
  export function getCssExtensions(): CssExtensions {
1893
- return cssExtensions;
1906
+ return cssExtensions
1894
1907
  }
1895
1908
 
1896
1909
  export function setCssExtensions(overrides: Partial<CssExtensions>): void {
1897
- Object.assign(cssExtensions, overrides);
1910
+ Object.assign(cssExtensions, overrides)
1898
1911
  }