@timber-js/app 0.2.0-alpha.6 → 0.2.0-alpha.61
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.
- package/LICENSE +8 -0
- package/dist/_chunks/{als-registry-B7DbZ2hS.js → als-registry-Ba7URUIn.js} +1 -1
- package/dist/_chunks/als-registry-Ba7URUIn.js.map +1 -0
- package/dist/_chunks/chunk-DYhsFzuS.js +33 -0
- package/dist/_chunks/{debug-gwlJkDuf.js → debug-ECi_61pb.js} +2 -2
- package/dist/_chunks/debug-ECi_61pb.js.map +1 -0
- package/dist/_chunks/define-CT98cU9c.js +121 -0
- package/dist/_chunks/define-CT98cU9c.js.map +1 -0
- package/dist/_chunks/define-TK8C1M3x.js +279 -0
- package/dist/_chunks/define-TK8C1M3x.js.map +1 -0
- package/dist/_chunks/define-cookie-BWr_52kY.js +93 -0
- package/dist/_chunks/define-cookie-BWr_52kY.js.map +1 -0
- package/dist/_chunks/error-boundary-DpZJBCqh.js +211 -0
- package/dist/_chunks/error-boundary-DpZJBCqh.js.map +1 -0
- package/dist/_chunks/{format-DviM89f0.js → format-cX7wzEp2.js} +2 -2
- package/dist/_chunks/{format-DviM89f0.js.map → format-cX7wzEp2.js.map} +1 -1
- package/dist/_chunks/{interception-BOoWmLUA.js → interception-Cey5DCGr.js} +129 -77
- package/dist/_chunks/interception-Cey5DCGr.js.map +1 -0
- package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js → metadata-routes-BU684ls2.js} +1 -1
- package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js.map → metadata-routes-BU684ls2.js.map} +1 -1
- package/dist/_chunks/{request-context-DIkVh_jG.js → request-context-rju2rbga.js} +97 -69
- package/dist/_chunks/request-context-rju2rbga.js.map +1 -0
- package/dist/_chunks/segment-context-CyaM1mrD.js +72 -0
- package/dist/_chunks/segment-context-CyaM1mrD.js.map +1 -0
- package/dist/_chunks/stale-reload-BSSym1MJ.js +64 -0
- package/dist/_chunks/stale-reload-BSSym1MJ.js.map +1 -0
- package/dist/_chunks/{tracing-Cwn7697K.js → tracing-VYETCQsg.js} +17 -3
- package/dist/_chunks/{tracing-Cwn7697K.js.map → tracing-VYETCQsg.js.map} +1 -1
- package/dist/_chunks/{use-query-states-D5KaffOK.js → use-query-states-wEXY2JQB.js} +1 -1
- package/dist/_chunks/use-query-states-wEXY2JQB.js.map +1 -0
- package/dist/_chunks/wrappers-BaG1bnM3.js +63 -0
- package/dist/_chunks/wrappers-BaG1bnM3.js.map +1 -0
- package/dist/adapters/compress-module.d.ts.map +1 -1
- package/dist/adapters/nitro.d.ts +17 -1
- package/dist/adapters/nitro.d.ts.map +1 -1
- package/dist/adapters/nitro.js +56 -13
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/cache/fast-hash.d.ts +22 -0
- package/dist/cache/fast-hash.d.ts.map +1 -0
- package/dist/cache/index.d.ts +5 -2
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +90 -20
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/register-cached-function.d.ts.map +1 -1
- package/dist/cache/singleflight.d.ts +18 -1
- package/dist/cache/singleflight.d.ts.map +1 -1
- package/dist/cache/timber-cache.d.ts +1 -1
- package/dist/cache/timber-cache.d.ts.map +1 -1
- package/dist/client/error-boundary.d.ts +10 -1
- package/dist/client/error-boundary.d.ts.map +1 -1
- package/dist/client/error-boundary.js +1 -125
- package/dist/client/error-reconstituter.d.ts +54 -0
- package/dist/client/error-reconstituter.d.ts.map +1 -0
- package/dist/client/form.d.ts +2 -2
- package/dist/client/form.d.ts.map +1 -1
- package/dist/client/index.d.ts +3 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +433 -252
- package/dist/client/index.js.map +1 -1
- package/dist/client/link-pending-store.d.ts +78 -0
- package/dist/client/link-pending-store.d.ts.map +1 -0
- package/dist/client/link.d.ts +23 -9
- package/dist/client/link.d.ts.map +1 -1
- package/dist/client/navigation-context.d.ts +2 -2
- package/dist/client/navigation-context.d.ts.map +1 -1
- package/dist/client/router.d.ts +25 -3
- package/dist/client/router.d.ts.map +1 -1
- package/dist/client/rsc-fetch.d.ts +36 -2
- package/dist/client/rsc-fetch.d.ts.map +1 -1
- package/dist/client/segment-cache.d.ts +1 -1
- package/dist/client/segment-cache.d.ts.map +1 -1
- package/dist/client/segment-context.d.ts +1 -1
- package/dist/client/segment-context.d.ts.map +1 -1
- package/dist/client/segment-merger.d.ts.map +1 -1
- package/dist/client/segment-outlet.d.ts +63 -0
- package/dist/client/segment-outlet.d.ts.map +1 -0
- package/dist/client/stale-reload.d.ts +15 -0
- package/dist/client/stale-reload.d.ts.map +1 -1
- package/dist/client/top-loader.d.ts +1 -1
- package/dist/client/top-loader.d.ts.map +1 -1
- package/dist/client/transition-root.d.ts +1 -1
- package/dist/client/transition-root.d.ts.map +1 -1
- package/dist/client/use-params.d.ts +3 -3
- package/dist/client/use-params.d.ts.map +1 -1
- package/dist/client/use-query-states.d.ts +1 -1
- package/dist/client/use-query-states.d.ts.map +1 -1
- package/dist/codec.d.ts +21 -0
- package/dist/codec.d.ts.map +1 -0
- package/dist/cookies/define-cookie.d.ts +34 -13
- package/dist/cookies/define-cookie.d.ts.map +1 -1
- package/dist/cookies/index.js +1 -83
- package/dist/fonts/css.d.ts +1 -0
- package/dist/fonts/css.d.ts.map +1 -1
- package/dist/index.d.ts +127 -35
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +665 -242
- package/dist/index.js.map +1 -1
- package/dist/params/define.d.ts +100 -0
- package/dist/params/define.d.ts.map +1 -0
- package/dist/params/index.d.ts +8 -0
- package/dist/params/index.d.ts.map +1 -0
- package/dist/params/index.js +4 -0
- package/dist/plugins/adapter-build.d.ts +1 -1
- package/dist/plugins/adapter-build.d.ts.map +1 -1
- package/dist/plugins/build-manifest.d.ts +2 -2
- package/dist/plugins/build-manifest.d.ts.map +1 -1
- package/dist/plugins/build-report.d.ts +3 -3
- package/dist/plugins/build-report.d.ts.map +1 -1
- package/dist/plugins/client-chunks.d.ts +32 -0
- package/dist/plugins/client-chunks.d.ts.map +1 -0
- package/dist/plugins/content.d.ts +1 -1
- package/dist/plugins/content.d.ts.map +1 -1
- package/dist/plugins/dev-browser-logs.d.ts +84 -0
- package/dist/plugins/dev-browser-logs.d.ts.map +1 -0
- package/dist/plugins/dev-error-overlay.d.ts +26 -1
- package/dist/plugins/dev-error-overlay.d.ts.map +1 -1
- package/dist/plugins/dev-logs.d.ts +1 -1
- package/dist/plugins/dev-logs.d.ts.map +1 -1
- package/dist/plugins/dev-server.d.ts +1 -1
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/entries.d.ts +1 -1
- package/dist/plugins/entries.d.ts.map +1 -1
- package/dist/plugins/fonts.d.ts +9 -2
- package/dist/plugins/fonts.d.ts.map +1 -1
- package/dist/plugins/mdx.d.ts +1 -1
- package/dist/plugins/mdx.d.ts.map +1 -1
- package/dist/plugins/routing.d.ts +1 -1
- package/dist/plugins/routing.d.ts.map +1 -1
- package/dist/plugins/server-bundle.d.ts.map +1 -1
- package/dist/plugins/shims.d.ts +6 -5
- package/dist/plugins/shims.d.ts.map +1 -1
- package/dist/plugins/static-build.d.ts +1 -1
- package/dist/plugins/static-build.d.ts.map +1 -1
- package/dist/routing/codegen.d.ts +2 -2
- package/dist/routing/codegen.d.ts.map +1 -1
- package/dist/routing/index.js +1 -1
- package/dist/routing/scanner.d.ts.map +1 -1
- package/dist/routing/status-file-lint.d.ts +2 -1
- package/dist/routing/status-file-lint.d.ts.map +1 -1
- package/dist/routing/types.d.ts +16 -4
- package/dist/routing/types.d.ts.map +1 -1
- package/dist/rsc-runtime/rsc.d.ts +1 -1
- package/dist/rsc-runtime/rsc.d.ts.map +1 -1
- package/dist/rsc-runtime/ssr.d.ts +12 -0
- package/dist/rsc-runtime/ssr.d.ts.map +1 -1
- package/dist/search-params/codecs.d.ts +1 -1
- package/dist/search-params/define.d.ts +159 -0
- package/dist/search-params/define.d.ts.map +1 -0
- package/dist/search-params/index.d.ts +4 -5
- package/dist/search-params/index.d.ts.map +1 -1
- package/dist/search-params/index.js +4 -474
- package/dist/search-params/registry.d.ts +1 -1
- package/dist/search-params/wrappers.d.ts +53 -0
- package/dist/search-params/wrappers.d.ts.map +1 -0
- package/dist/server/access-gate.d.ts +4 -0
- package/dist/server/access-gate.d.ts.map +1 -1
- package/dist/server/action-client.d.ts.map +1 -1
- package/dist/server/action-encryption.d.ts +76 -0
- package/dist/server/action-encryption.d.ts.map +1 -0
- package/dist/server/action-handler.d.ts.map +1 -1
- package/dist/server/actions.d.ts +1 -1
- package/dist/server/actions.d.ts.map +1 -1
- package/dist/server/als-registry.d.ts +25 -4
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/build-manifest.d.ts +2 -2
- package/dist/server/build-manifest.d.ts.map +1 -1
- package/dist/server/debug.d.ts +1 -1
- package/dist/server/default-logger.d.ts +22 -0
- package/dist/server/default-logger.d.ts.map +1 -0
- package/dist/server/deny-renderer.d.ts.map +1 -1
- package/dist/server/early-hints.d.ts +13 -5
- package/dist/server/early-hints.d.ts.map +1 -1
- package/dist/server/error-boundary-wrapper.d.ts +4 -0
- package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
- package/dist/server/fallback-error.d.ts +4 -3
- package/dist/server/fallback-error.d.ts.map +1 -1
- package/dist/server/flight-injection-state.d.ts +66 -0
- package/dist/server/flight-injection-state.d.ts.map +1 -0
- package/dist/server/flight-scripts.d.ts +42 -0
- package/dist/server/flight-scripts.d.ts.map +1 -0
- package/dist/server/flush.d.ts.map +1 -1
- package/dist/server/form-data.d.ts +29 -0
- package/dist/server/form-data.d.ts.map +1 -1
- package/dist/server/html-injectors.d.ts +51 -11
- package/dist/server/html-injectors.d.ts.map +1 -1
- package/dist/server/index.d.ts +4 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1977 -1648
- package/dist/server/index.js.map +1 -1
- package/dist/server/logger.d.ts +25 -7
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/node-stream-transforms.d.ts +113 -0
- package/dist/server/node-stream-transforms.d.ts.map +1 -0
- package/dist/server/pipeline-interception.d.ts +1 -1
- package/dist/server/pipeline-interception.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +20 -6
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/primitives.d.ts +30 -3
- package/dist/server/primitives.d.ts.map +1 -1
- package/dist/server/render-timeout.d.ts +51 -0
- package/dist/server/render-timeout.d.ts.map +1 -0
- package/dist/server/request-context.d.ts +65 -38
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts +7 -0
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/route-handler.d.ts.map +1 -1
- package/dist/server/route-matcher.d.ts +9 -2
- package/dist/server/route-matcher.d.ts.map +1 -1
- package/dist/server/rsc-entry/api-handler.d.ts +2 -2
- package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
- package/dist/server/rsc-entry/error-renderer.d.ts +26 -13
- package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
- package/dist/server/rsc-entry/helpers.d.ts +48 -5
- package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts +8 -3
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-payload.d.ts +3 -3
- package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts +10 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/rsc-entry/ssr-bridge.d.ts +1 -1
- package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
- package/dist/server/rsc-entry/ssr-renderer.d.ts +19 -4
- package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
- package/dist/server/slot-resolver.d.ts +1 -1
- package/dist/server/slot-resolver.d.ts.map +1 -1
- package/dist/server/ssr-entry.d.ts +22 -0
- package/dist/server/ssr-entry.d.ts.map +1 -1
- package/dist/server/ssr-render.d.ts +39 -21
- package/dist/server/ssr-render.d.ts.map +1 -1
- package/dist/server/ssr-wrappers.d.ts +50 -0
- package/dist/server/ssr-wrappers.d.ts.map +1 -0
- package/dist/server/status-code-resolver.d.ts +1 -1
- package/dist/server/status-code-resolver.d.ts.map +1 -1
- package/dist/server/stream-utils.d.ts +36 -0
- package/dist/server/stream-utils.d.ts.map +1 -0
- package/dist/server/tracing.d.ts +10 -0
- package/dist/server/tracing.d.ts.map +1 -1
- package/dist/server/tree-builder.d.ts +20 -13
- package/dist/server/tree-builder.d.ts.map +1 -1
- package/dist/server/types.d.ts +1 -3
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/version-skew.d.ts +61 -0
- package/dist/server/version-skew.d.ts.map +1 -0
- package/dist/server/waituntil-bridge.d.ts.map +1 -1
- package/dist/shared/merge-search-params.d.ts +22 -0
- package/dist/shared/merge-search-params.d.ts.map +1 -0
- package/dist/shims/font-google.d.ts +1 -1
- package/dist/shims/font-google.d.ts.map +1 -1
- package/dist/shims/navigation-client.d.ts +1 -1
- package/dist/shims/navigation-client.d.ts.map +1 -1
- package/dist/shims/navigation.d.ts +1 -1
- package/dist/shims/navigation.d.ts.map +1 -1
- package/dist/utils/state-machine.d.ts +80 -0
- package/dist/utils/state-machine.d.ts.map +1 -0
- package/package.json +17 -17
- package/src/adapters/compress-module.ts +24 -4
- package/src/adapters/nitro.ts +58 -9
- package/src/cache/fast-hash.ts +34 -0
- package/src/cache/index.ts +5 -2
- package/src/cache/register-cached-function.ts +7 -3
- package/src/cache/singleflight.ts +62 -4
- package/src/cache/timber-cache.ts +40 -29
- package/src/cli.ts +0 -0
- package/src/client/browser-entry.ts +151 -99
- package/src/client/error-boundary.tsx +18 -1
- package/src/client/error-reconstituter.tsx +65 -0
- package/src/client/form.tsx +2 -2
- package/src/client/index.ts +10 -1
- package/src/client/link-pending-store.ts +136 -0
- package/src/client/link.tsx +137 -22
- package/src/client/navigation-context.ts +6 -5
- package/src/client/router.ts +117 -60
- package/src/client/rsc-fetch.ts +90 -2
- package/src/client/segment-cache.ts +1 -1
- package/src/client/segment-context.ts +6 -1
- package/src/client/segment-merger.ts +2 -8
- package/src/client/segment-outlet.tsx +86 -0
- package/src/client/stale-reload.ts +73 -6
- package/src/client/top-loader.tsx +10 -9
- package/src/client/transition-root.tsx +20 -2
- package/src/client/use-params.ts +4 -4
- package/src/client/use-query-states.ts +2 -2
- package/src/codec.ts +21 -0
- package/src/cookies/define-cookie.ts +71 -20
- package/src/fonts/css.ts +2 -1
- package/src/index.ts +297 -85
- package/src/params/define.ts +327 -0
- package/src/params/index.ts +28 -0
- package/src/plugins/adapter-build.ts +8 -2
- package/src/plugins/build-manifest.ts +13 -2
- package/src/plugins/build-report.ts +3 -3
- package/src/plugins/cache-transform.ts +1 -1
- package/src/plugins/client-chunks.ts +65 -0
- package/src/plugins/content.ts +1 -1
- package/src/plugins/dev-browser-logs.ts +284 -0
- package/src/plugins/dev-error-overlay.ts +70 -1
- package/src/plugins/dev-logs.ts +1 -1
- package/src/plugins/dev-server.ts +41 -7
- package/src/plugins/entries.ts +6 -8
- package/src/plugins/fonts.ts +102 -55
- package/src/plugins/mdx.ts +1 -1
- package/src/plugins/routing.ts +57 -17
- package/src/plugins/server-action-exports.ts +1 -1
- package/src/plugins/server-bundle.ts +32 -1
- package/src/plugins/shims.ts +69 -31
- package/src/plugins/static-build.ts +10 -6
- package/src/routing/codegen.ts +109 -88
- package/src/routing/scanner.ts +86 -7
- package/src/routing/status-file-lint.ts +3 -2
- package/src/routing/types.ts +17 -4
- package/src/rsc-runtime/rsc.ts +2 -0
- package/src/rsc-runtime/ssr.ts +50 -0
- package/src/rsc-runtime/vendor-types.d.ts +7 -0
- package/src/search-params/codecs.ts +1 -1
- package/src/search-params/define.ts +518 -0
- package/src/search-params/index.ts +12 -18
- package/src/search-params/registry.ts +1 -1
- package/src/search-params/wrappers.ts +85 -0
- package/src/server/access-gate.tsx +40 -9
- package/src/server/action-client.ts +8 -2
- package/src/server/action-encryption.ts +144 -0
- package/src/server/action-handler.ts +20 -3
- package/src/server/actions.ts +1 -1
- package/src/server/als-registry.ts +25 -4
- package/src/server/build-manifest.ts +10 -4
- package/src/server/compress.ts +25 -7
- package/src/server/debug.ts +1 -1
- package/src/server/default-logger.ts +99 -0
- package/src/server/deny-renderer.ts +5 -3
- package/src/server/early-hints.ts +36 -15
- package/src/server/error-boundary-wrapper.ts +58 -15
- package/src/server/fallback-error.ts +29 -14
- package/src/server/flight-injection-state.ts +113 -0
- package/src/server/flight-scripts.ts +62 -0
- package/src/server/flush.ts +2 -1
- package/src/server/form-data.ts +76 -0
- package/src/server/html-injectors.ts +277 -117
- package/src/server/index.ts +9 -4
- package/src/server/logger.ts +44 -36
- package/src/server/node-stream-transforms.ts +509 -0
- package/src/server/pipeline-interception.ts +1 -1
- package/src/server/pipeline.ts +148 -41
- package/src/server/primitives.ts +47 -5
- package/src/server/render-timeout.ts +108 -0
- package/src/server/request-context.ts +125 -119
- package/src/server/route-element-builder.ts +107 -115
- package/src/server/route-handler.ts +2 -1
- package/src/server/route-matcher.ts +9 -2
- package/src/server/rsc-entry/api-handler.ts +8 -8
- package/src/server/rsc-entry/error-renderer.ts +286 -81
- package/src/server/rsc-entry/helpers.ts +134 -5
- package/src/server/rsc-entry/index.ts +177 -76
- package/src/server/rsc-entry/rsc-payload.ts +91 -18
- package/src/server/rsc-entry/rsc-stream.ts +74 -18
- package/src/server/rsc-entry/ssr-bridge.ts +2 -2
- package/src/server/rsc-entry/ssr-renderer.ts +152 -34
- package/src/server/slot-resolver.ts +231 -220
- package/src/server/ssr-entry.ts +211 -32
- package/src/server/ssr-render.ts +289 -67
- package/src/server/ssr-wrappers.tsx +139 -0
- package/src/server/status-code-resolver.ts +1 -1
- package/src/server/stream-utils.ts +213 -0
- package/src/server/tracing.ts +23 -0
- package/src/server/tree-builder.ts +92 -58
- package/src/server/types.ts +1 -3
- package/src/server/version-skew.ts +104 -0
- package/src/server/waituntil-bridge.ts +4 -1
- package/src/shared/merge-search-params.ts +55 -0
- package/src/shims/font-google.ts +1 -1
- package/src/shims/navigation-client.ts +1 -1
- package/src/shims/navigation.ts +2 -1
- package/src/utils/state-machine.ts +111 -0
- package/dist/_chunks/als-registry-B7DbZ2hS.js.map +0 -1
- package/dist/_chunks/debug-gwlJkDuf.js.map +0 -1
- package/dist/_chunks/interception-BOoWmLUA.js.map +0 -1
- package/dist/_chunks/request-context-DIkVh_jG.js.map +0 -1
- package/dist/_chunks/ssr-data-MjmprTmO.js +0 -88
- package/dist/_chunks/ssr-data-MjmprTmO.js.map +0 -1
- package/dist/_chunks/use-cookie-DX-l1_5E.js +0 -91
- package/dist/_chunks/use-cookie-DX-l1_5E.js.map +0 -1
- package/dist/_chunks/use-query-states-D5KaffOK.js.map +0 -1
- package/dist/client/error-boundary.js.map +0 -1
- package/dist/client/link-status-provider.d.ts +0 -11
- package/dist/client/link-status-provider.d.ts.map +0 -1
- package/dist/cookies/index.js.map +0 -1
- package/dist/plugins/dynamic-transform.d.ts +0 -72
- package/dist/plugins/dynamic-transform.d.ts.map +0 -1
- package/dist/search-params/analyze.d.ts +0 -54
- package/dist/search-params/analyze.d.ts.map +0 -1
- package/dist/search-params/builtin-codecs.d.ts +0 -105
- package/dist/search-params/builtin-codecs.d.ts.map +0 -1
- package/dist/search-params/create.d.ts +0 -106
- package/dist/search-params/create.d.ts.map +0 -1
- package/dist/search-params/index.js.map +0 -1
- package/dist/server/prerender.d.ts +0 -77
- package/dist/server/prerender.d.ts.map +0 -1
- package/dist/server/response-cache.d.ts +0 -53
- package/dist/server/response-cache.d.ts.map +0 -1
- package/src/client/link-status-provider.tsx +0 -30
- package/src/plugins/dynamic-transform.ts +0 -161
- package/src/search-params/analyze.ts +0 -192
- package/src/search-params/builtin-codecs.ts +0 -228
- package/src/search-params/create.ts +0 -321
- package/src/server/prerender.ts +0 -139
- package/src/server/response-cache.ts +0 -277
package/src/index.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Plugin, PluginOption } from 'vite';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
5
4
|
import { createRequire } from 'node:module';
|
|
6
|
-
import react from '@vitejs/plugin-react';
|
|
5
|
+
import react, { reactCompilerPreset } from '@vitejs/plugin-react';
|
|
7
6
|
import { cacheTransformPlugin } from './plugins/cache-transform';
|
|
8
7
|
import { timberContent } from './plugins/content';
|
|
9
8
|
import { timberDevServer } from './plugins/dev-server';
|
|
@@ -13,12 +12,13 @@ import { timberRouting } from './plugins/routing';
|
|
|
13
12
|
import { timberShims } from './plugins/shims';
|
|
14
13
|
import { timberFonts } from './plugins/fonts';
|
|
15
14
|
import { timberStaticBuild } from './plugins/static-build';
|
|
16
|
-
import { timberDynamicTransform } from './plugins/dynamic-transform';
|
|
17
15
|
import { timberServerActionExports } from './plugins/server-action-exports';
|
|
18
16
|
import { timberBuildManifest } from './plugins/build-manifest';
|
|
19
17
|
import { timberDevLogs } from './plugins/dev-logs';
|
|
18
|
+
import { timberDevBrowserLogs } from './plugins/dev-browser-logs';
|
|
20
19
|
import { timberReactProd } from './plugins/react-prod';
|
|
21
20
|
import { timberChunks } from './plugins/chunks';
|
|
21
|
+
import { clientChunkGroup } from './plugins/client-chunks';
|
|
22
22
|
import { timberServerBundle } from './plugins/server-bundle';
|
|
23
23
|
import { timberAdapterBuild } from './plugins/adapter-build';
|
|
24
24
|
import { timberBuildReport } from './plugins/build-report';
|
|
@@ -26,6 +26,7 @@ import type { RouteTree } from './routing/types';
|
|
|
26
26
|
import type { BuildManifest } from './server/build-manifest';
|
|
27
27
|
import type { StartupTimer } from './utils/startup-timer';
|
|
28
28
|
import { createStartupTimer, createNoopTimer } from './utils/startup-timer';
|
|
29
|
+
import { resolveEncryptionKeyExpression, shouldEnableEncryption } from './server/action-encryption';
|
|
29
30
|
|
|
30
31
|
/** Configuration for client-side JavaScript output. */
|
|
31
32
|
export interface ClientJavascriptConfig {
|
|
@@ -90,23 +91,54 @@ export interface TimberUserConfig {
|
|
|
90
91
|
* See design/17-logging.md §"slowRequestMs".
|
|
91
92
|
*/
|
|
92
93
|
slowRequestMs?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Render timeout in milliseconds. If an SSR render or RSC stream read
|
|
96
|
+
* does not complete within this duration, the render is aborted and
|
|
97
|
+
* the connection is closed. Protects against hung fetches and Suspense
|
|
98
|
+
* components that never resolve.
|
|
99
|
+
*
|
|
100
|
+
* Set to 0 to disable (not recommended in production).
|
|
101
|
+
* Default: 30000 (30 seconds).
|
|
102
|
+
*
|
|
103
|
+
* See design/02-rendering-pipeline.md §"Streaming Constraints".
|
|
104
|
+
*/
|
|
105
|
+
renderTimeoutMs?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Forward browser console output to the server terminal in dev mode.
|
|
108
|
+
*
|
|
109
|
+
* Sets the minimum log level to forward:
|
|
110
|
+
* - `'error'` — only `console.error`
|
|
111
|
+
* - `'warn'` — `console.error` + `console.warn` (default)
|
|
112
|
+
* - `'info'` — `console.error` + `console.warn` + `console.info`
|
|
113
|
+
* - `'none'` — disabled
|
|
114
|
+
*
|
|
115
|
+
* Does not intercept `console.log` or `console.debug` (too noisy).
|
|
116
|
+
* No effect in production builds.
|
|
117
|
+
*
|
|
118
|
+
* See TIM-513.
|
|
119
|
+
*/
|
|
120
|
+
devBrowserLogs?: 'error' | 'warn' | 'info' | 'none';
|
|
93
121
|
/** Dev-mode options. These have no effect in production builds. */
|
|
94
122
|
dev?: {
|
|
95
123
|
/** Threshold in ms to highlight slow phases in dev logging output. Default: 200. */
|
|
96
124
|
slowPhaseMs?: number;
|
|
97
125
|
};
|
|
98
126
|
/**
|
|
99
|
-
*
|
|
127
|
+
* Control Server-Timing header output.
|
|
128
|
+
*
|
|
129
|
+
* - `'detailed'` — per-phase breakdown (proxy, middleware, render). Useful
|
|
130
|
+
* for APM / network monitoring. Exposes phase names to clients.
|
|
131
|
+
* - `'total'` — single `total;dur=N` entry. Safe to expose, gives
|
|
132
|
+
* browser DevTools useful timing without internal details.
|
|
133
|
+
* - `false` — no Server-Timing header at all.
|
|
134
|
+
*
|
|
135
|
+
* Default: `'detailed'` in dev, `'total'` in production.
|
|
100
136
|
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
137
|
+
* This is separate from `debug` / `TIMBER_DEBUG` — it's an intentional
|
|
138
|
+
* decision to expose timing data to clients, not a side effect of debug
|
|
139
|
+
* logging.
|
|
103
140
|
*/
|
|
104
|
-
|
|
105
|
-
/** Single signing secret. Shorthand for `secrets: [secret]`. */
|
|
106
|
-
secret?: string;
|
|
107
|
-
/** Array of signing secrets for key rotation. Index 0 signs; all verify. */
|
|
108
|
-
secrets?: string[];
|
|
109
|
-
};
|
|
141
|
+
serverTiming?: 'detailed' | 'total' | false;
|
|
110
142
|
/**
|
|
111
143
|
* Override the app directory location. By default, timber auto-detects
|
|
112
144
|
* `app/` at the project root, falling back to `src/app/`.
|
|
@@ -132,6 +164,46 @@ export interface TimberUserConfig {
|
|
|
132
164
|
*
|
|
133
165
|
* See LOCAL-336 for design decisions.
|
|
134
166
|
*/
|
|
167
|
+
/**
|
|
168
|
+
* Server action bound args encryption configuration.
|
|
169
|
+
*
|
|
170
|
+
* The RSC plugin encrypts closure variables captured by 'use server' functions
|
|
171
|
+
* using AES-256-GCM so they are opaque and tamper-proof in the Flight payload.
|
|
172
|
+
* Encryption is always enabled in production.
|
|
173
|
+
*
|
|
174
|
+
* The encryption key is auto-generated at build time and embedded in the server bundle,
|
|
175
|
+
* so all instances running the same build share the same key automatically.
|
|
176
|
+
* For rolling/blue-green deployments where multiple builds coexist, set
|
|
177
|
+
* `TIMBER_ACTIONS_ENCRYPTION_KEY` env var to share a key across builds.
|
|
178
|
+
*
|
|
179
|
+
* See design/08-forms-and-actions.md §"Security"
|
|
180
|
+
*/
|
|
181
|
+
actionEncryption?: {
|
|
182
|
+
/**
|
|
183
|
+
* Disable encryption in dev mode for easier debugging of bound args.
|
|
184
|
+
* Has no effect in production — encryption is always enabled.
|
|
185
|
+
* Default: false (encryption is on in dev too).
|
|
186
|
+
*/
|
|
187
|
+
disableInDev?: boolean;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Enable the React Compiler (babel-plugin-react-compiler) for automatic
|
|
191
|
+
* memoization of components and hooks at build time.
|
|
192
|
+
*
|
|
193
|
+
* - `true` — enable with default options
|
|
194
|
+
* - `{ compilationMode, target }` — enable with custom options
|
|
195
|
+
* - `compilationMode: 'annotation'` — only compile files with `'use memo'`
|
|
196
|
+
* - `target: '18'` — target React 18 (uses react-compiler-runtime package)
|
|
197
|
+
* - `false` or omitted — disabled (default)
|
|
198
|
+
*
|
|
199
|
+
* Uses `@vitejs/plugin-react`'s built-in `reactCompilerPreset`, which:
|
|
200
|
+
* - Applies Babel only for the compiler pass (OXC handles JSX)
|
|
201
|
+
* - Automatically scopes to client environment only
|
|
202
|
+
* - Uses `react/compiler-runtime` built into React 19
|
|
203
|
+
*
|
|
204
|
+
* Requires `babel-plugin-react-compiler` as a peer dependency.
|
|
205
|
+
*/
|
|
206
|
+
reactCompiler?: boolean | { compilationMode?: string; target?: string };
|
|
135
207
|
topLoader?: {
|
|
136
208
|
/** Whether the top-loader is enabled. Default: true. */
|
|
137
209
|
enabled?: boolean;
|
|
@@ -146,34 +218,6 @@ export interface TimberUserConfig {
|
|
|
146
218
|
/** CSS z-index. Default: 1600. */
|
|
147
219
|
zIndex?: number;
|
|
148
220
|
};
|
|
149
|
-
/**
|
|
150
|
-
* Response-level caching and deduplication.
|
|
151
|
-
*
|
|
152
|
-
* When enabled, concurrent requests to the same URL share a single render
|
|
153
|
-
* (singleflight), and recently rendered responses are reused from a short-TTL
|
|
154
|
-
* LRU cache without re-executing the RSC-to-SSR pipeline.
|
|
155
|
-
*
|
|
156
|
-
* Set to `false` to disable entirely. Default: enabled with sensible defaults.
|
|
157
|
-
*
|
|
158
|
-
* See design/31-benchmarking.md for performance context.
|
|
159
|
-
*/
|
|
160
|
-
responseCache?:
|
|
161
|
-
| false
|
|
162
|
-
| {
|
|
163
|
-
/** Maximum number of entries in the LRU cache. Default: 150. */
|
|
164
|
-
maxSize?: number;
|
|
165
|
-
/** TTL for cached entries in milliseconds. Default: 5000 (5s). */
|
|
166
|
-
ttlMs?: number;
|
|
167
|
-
/**
|
|
168
|
-
* When true (default), requests with Cookie or Authorization headers
|
|
169
|
-
* bypass the cache entirely. This prevents sharing user-specific
|
|
170
|
-
* responses across requests.
|
|
171
|
-
*
|
|
172
|
-
* Set to false to cache all responses regardless of auth state.
|
|
173
|
-
* Only do this if your pages are truly public and don't vary by user.
|
|
174
|
-
*/
|
|
175
|
-
publicOnly?: boolean;
|
|
176
|
-
};
|
|
177
221
|
}
|
|
178
222
|
|
|
179
223
|
/**
|
|
@@ -221,6 +265,8 @@ export interface PluginContext {
|
|
|
221
265
|
dev: boolean;
|
|
222
266
|
/** CSS build manifest (populated by adapter after client build, null in dev) */
|
|
223
267
|
buildManifest: BuildManifest | null;
|
|
268
|
+
/** Per-build deployment ID for version skew detection (null in dev) */
|
|
269
|
+
deploymentId: string | null;
|
|
224
270
|
/** Startup timer for profiling cold start phases (active in dev, no-op in prod) */
|
|
225
271
|
timer: StartupTimer;
|
|
226
272
|
}
|
|
@@ -256,7 +302,10 @@ export function resolveAppDir(root: string, configAppDir?: string): string {
|
|
|
256
302
|
|
|
257
303
|
function createPluginContext(config?: TimberUserConfig, root?: string): PluginContext {
|
|
258
304
|
const projectRoot = root ?? process.cwd();
|
|
259
|
-
|
|
305
|
+
// Don't apply defaults here — they would override file-based config
|
|
306
|
+
// during mergeFileConfig (inline spreads over file). Defaults are
|
|
307
|
+
// applied after merge in timber(). See TIM-451.
|
|
308
|
+
const resolvedConfig: TimberUserConfig = { ...config };
|
|
260
309
|
// Timer starts as active — swapped to noop in configResolved for production builds
|
|
261
310
|
return {
|
|
262
311
|
config: resolvedConfig,
|
|
@@ -266,6 +315,7 @@ function createPluginContext(config?: TimberUserConfig, root?: string): PluginCo
|
|
|
266
315
|
root: projectRoot,
|
|
267
316
|
dev: false,
|
|
268
317
|
buildManifest: null,
|
|
318
|
+
deploymentId: null,
|
|
269
319
|
timer: createStartupTimer(),
|
|
270
320
|
};
|
|
271
321
|
}
|
|
@@ -273,14 +323,18 @@ function createPluginContext(config?: TimberUserConfig, root?: string): PluginCo
|
|
|
273
323
|
/**
|
|
274
324
|
* Load timber.config.ts (or .js, .mjs) from the project root.
|
|
275
325
|
* Returns the config object or null if no config file is found.
|
|
326
|
+
*
|
|
327
|
+
* Uses require() which works for ESM modules on Node 22.12+.
|
|
328
|
+
* This keeps timber() synchronous — no async config loading needed.
|
|
276
329
|
*/
|
|
277
|
-
|
|
330
|
+
export function loadTimberConfigFile(root: string): TimberUserConfig | null {
|
|
278
331
|
const configNames = ['timber.config.ts', 'timber.config.js', 'timber.config.mjs'];
|
|
332
|
+
const req = createRequire(join(root, 'package.json'));
|
|
279
333
|
|
|
280
334
|
for (const name of configNames) {
|
|
281
335
|
const configPath = join(root, name);
|
|
282
336
|
if (existsSync(configPath)) {
|
|
283
|
-
const mod =
|
|
337
|
+
const mod = req(configPath);
|
|
284
338
|
return (mod.default ?? mod) as TimberUserConfig;
|
|
285
339
|
}
|
|
286
340
|
}
|
|
@@ -300,7 +354,6 @@ export function warnConfigConflicts(
|
|
|
300
354
|
): string[] {
|
|
301
355
|
const conflicts: string[] = [];
|
|
302
356
|
for (const key of Object.keys(fileConfig) as (keyof TimberUserConfig)[]) {
|
|
303
|
-
if (key === 'output') continue;
|
|
304
357
|
if (key in inline && inline[key] !== undefined) {
|
|
305
358
|
conflicts.push(key);
|
|
306
359
|
}
|
|
@@ -339,28 +392,155 @@ function mergeFileConfig(ctx: PluginContext, fileConfig: TimberUserConfig): void
|
|
|
339
392
|
};
|
|
340
393
|
}
|
|
341
394
|
|
|
395
|
+
/**
|
|
396
|
+
* Resolve the React Compiler plugin via @rolldown/plugin-babel.
|
|
397
|
+
*
|
|
398
|
+
* Uses the `reactCompilerPreset` from @vitejs/plugin-react, which:
|
|
399
|
+
* - Uses Babel ONLY for the compiler pass (OXC handles JSX)
|
|
400
|
+
* - Automatically scopes to client environment via applyToEnvironmentHook
|
|
401
|
+
* - Uses react/compiler-runtime built into React 19
|
|
402
|
+
*
|
|
403
|
+
* @rolldown/plugin-babel and babel-plugin-react-compiler are optional peer deps.
|
|
404
|
+
* If either is missing, require() fails with a clear error message.
|
|
405
|
+
*/
|
|
406
|
+
function resolveReactCompilerPlugin(
|
|
407
|
+
config: true | { compilationMode?: string; target?: string },
|
|
408
|
+
req: NodeRequire
|
|
409
|
+
): PluginOption {
|
|
410
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
411
|
+
let babel: any;
|
|
412
|
+
try {
|
|
413
|
+
babel = req('@rolldown/plugin-babel');
|
|
414
|
+
} catch {
|
|
415
|
+
throw new Error(
|
|
416
|
+
'[timber] reactCompiler requires @rolldown/plugin-babel. ' +
|
|
417
|
+
'Install it: pnpm add -D @rolldown/plugin-babel babel-plugin-react-compiler'
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
const options = typeof config === 'object' ? config : {};
|
|
421
|
+
const babelPlugin = babel.default ?? babel;
|
|
422
|
+
return babelPlugin({
|
|
423
|
+
presets: [reactCompilerPreset(options as Parameters<typeof reactCompilerPreset>[0])],
|
|
424
|
+
}) as PluginOption;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Build the options object for @vitejs/plugin-rsc.
|
|
429
|
+
*
|
|
430
|
+
* Uses a getter for `enableActionEncryption` so the RSC plugin reads
|
|
431
|
+
* the value lazily — after ctx.dev is set in configResolved. This lets
|
|
432
|
+
* `actionEncryption.disableInDev` work correctly even though the RSC
|
|
433
|
+
* plugin is created before Vite resolves the command.
|
|
434
|
+
*/
|
|
435
|
+
function createRscOptions(
|
|
436
|
+
ctx: PluginContext,
|
|
437
|
+
encryptionKeyExpr: string | undefined
|
|
438
|
+
): Record<string, unknown> {
|
|
439
|
+
const options: Record<string, unknown> = {
|
|
440
|
+
serverHandler: false,
|
|
441
|
+
customClientEntry: true,
|
|
442
|
+
entries: {
|
|
443
|
+
rsc: 'virtual:timber-rsc-entry',
|
|
444
|
+
ssr: 'virtual:timber-ssr-entry',
|
|
445
|
+
client: 'virtual:timber-browser-entry',
|
|
446
|
+
},
|
|
447
|
+
// Group client references by layout boundary to balance route-scoped code
|
|
448
|
+
// splitting with HTTP request count. A constant group name ('client-refs')
|
|
449
|
+
// would collapse all routes into one chunk — any page downloads every
|
|
450
|
+
// client component. Per-serverChunk grouping creates many sub-500B files.
|
|
451
|
+
// Layout-boundary grouping is the middle ground: components under the same
|
|
452
|
+
// layout segment share a chunk. See design/27-chunking-strategy.md, TIM-440, TIM-499.
|
|
453
|
+
clientChunks: (meta: { id: string; normalizedId: string; serverChunk: string }) =>
|
|
454
|
+
clientChunkGroup(meta, ctx.appDir),
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
// Bound args encryption — AES-256-GCM authenticated encryption for
|
|
458
|
+
// closure variables in 'use server' functions. Always on in production,
|
|
459
|
+
// configurable in dev. See design/08-forms-and-actions.md §"Bound Args Encryption".
|
|
460
|
+
//
|
|
461
|
+
// Uses a getter so the RSC plugin reads the value lazily in its transform
|
|
462
|
+
// hooks, after ctx.dev is set in configResolved. This lets disableInDev
|
|
463
|
+
// work correctly — ctx.dev is false at construction time but true during
|
|
464
|
+
// dev server transforms.
|
|
465
|
+
Object.defineProperty(options, 'enableActionEncryption', {
|
|
466
|
+
get() {
|
|
467
|
+
return shouldEnableEncryption(ctx.dev, ctx.config.actionEncryption);
|
|
468
|
+
},
|
|
469
|
+
enumerable: true,
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
// When TIMBER_ACTIONS_ENCRYPTION_KEY is set, pass it as a runtime expression
|
|
473
|
+
// so the RSC plugin uses it instead of auto-generating a per-build key.
|
|
474
|
+
if (encryptionKeyExpr) {
|
|
475
|
+
options.defineEncryptionKey = encryptionKeyExpr;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
return options;
|
|
479
|
+
}
|
|
480
|
+
|
|
342
481
|
function timberCache(_ctx: PluginContext): Plugin {
|
|
343
482
|
return cacheTransformPlugin();
|
|
344
483
|
}
|
|
345
484
|
|
|
485
|
+
/**
|
|
486
|
+
* Create the timber Vite plugin array.
|
|
487
|
+
*
|
|
488
|
+
* Loads timber.config.ts and all dependencies synchronously before
|
|
489
|
+
* constructing the plugin array. This ensures ALL plugins — including
|
|
490
|
+
* the RSC plugin and React Compiler — see the fully merged config
|
|
491
|
+
* (inline + file-based). No async, no deferred config, no stale reads.
|
|
492
|
+
*
|
|
493
|
+
* Requires Node >= 22.12 for synchronous require() of ESM modules
|
|
494
|
+
* (@vitejs/plugin-rsc is ESM-only).
|
|
495
|
+
*
|
|
496
|
+
* Previous versions used async loading and deferred config merging,
|
|
497
|
+
* causing file-based config for reactCompiler, actionEncryption, and
|
|
498
|
+
* output mode to be silently ignored. See TIM-451.
|
|
499
|
+
*/
|
|
346
500
|
export function timber(config?: TimberUserConfig): PluginOption[] {
|
|
347
501
|
const ctx = createPluginContext(config);
|
|
348
|
-
|
|
349
|
-
//
|
|
350
|
-
//
|
|
502
|
+
|
|
503
|
+
// Resolve dependencies from the consumer's project (process.cwd()),
|
|
504
|
+
// not from timber's own node_modules. This is critical for pnpm link:
|
|
505
|
+
// when linked, timber's node_modules has a separate vite instance, and
|
|
506
|
+
// the RSC plugin must use the same vite instance as the dev server.
|
|
507
|
+
const consumerRequire = createRequire(join(process.cwd(), 'package.json'));
|
|
508
|
+
|
|
509
|
+
// ── Step 1: Load @vitejs/plugin-rsc ─────────────────────────────────
|
|
510
|
+
// Synchronous require() works for ESM modules on Node 22.12+.
|
|
511
|
+
ctx.timer.start('rsc-plugin-import');
|
|
512
|
+
const rscMod = consumerRequire('@vitejs/plugin-rsc');
|
|
513
|
+
const vitePluginRsc = rscMod.default ?? rscMod;
|
|
514
|
+
ctx.timer.end('rsc-plugin-import');
|
|
515
|
+
|
|
516
|
+
// ── Step 2: Compute config-dependent options ────────────────────────
|
|
517
|
+
// encryptionKeyExpr is env-based and doesn't depend on file config.
|
|
518
|
+
const encryptionKeyExpr = resolveEncryptionKeyExpression();
|
|
519
|
+
|
|
520
|
+
// ── Step 3: Build rootSync plugin ───────────────────────────────────
|
|
521
|
+
// rootSync loads timber.config.ts and resolves the Vite root.
|
|
522
|
+
// Config file loading happens in the `config` hook so it uses Vite's
|
|
523
|
+
// resolved root (from userConfig.root) instead of process.cwd().
|
|
524
|
+
// This is critical when running from a workspace root with
|
|
525
|
+
// `vite --config subdir/vite.config.ts` or a custom `root` option.
|
|
526
|
+
// See TIM-498.
|
|
351
527
|
const rootSync: Plugin = {
|
|
352
528
|
name: 'timber-root-sync',
|
|
353
|
-
|
|
354
|
-
// Load timber.config.ts
|
|
355
|
-
//
|
|
356
|
-
//
|
|
357
|
-
|
|
529
|
+
config(userConfig, { command }) {
|
|
530
|
+
// ── Load timber.config.ts from the correct root ───────────────
|
|
531
|
+
// Vite's `config` hook fires before `configResolved`. The user's
|
|
532
|
+
// `root` option (if set) tells us where the project lives.
|
|
533
|
+
// `resolve()` mirrors Vite's own root resolution logic.
|
|
534
|
+
const viteRoot = resolve(userConfig.root ?? process.cwd());
|
|
358
535
|
ctx.timer.start('config-load');
|
|
359
|
-
const fileConfig =
|
|
536
|
+
const fileConfig = loadTimberConfigFile(viteRoot);
|
|
360
537
|
if (fileConfig) {
|
|
361
538
|
mergeFileConfig(ctx, fileConfig);
|
|
362
539
|
ctx.clientJavascript = resolveClientJavascript(ctx.config);
|
|
363
540
|
}
|
|
541
|
+
// Apply defaults AFTER merge so file-based config isn't overridden
|
|
542
|
+
// by defaults that were baked into the inline config object.
|
|
543
|
+
ctx.config.output ??= 'server';
|
|
364
544
|
ctx.timer.end('config-load');
|
|
365
545
|
|
|
366
546
|
// Force production JSX transform for builds.
|
|
@@ -399,17 +579,49 @@ export function timber(config?: TimberUserConfig): PluginOption[] {
|
|
|
399
579
|
}
|
|
400
580
|
},
|
|
401
581
|
};
|
|
582
|
+
|
|
583
|
+
// ── Step 4: Resolve optional plugins ────────────────────────────────
|
|
584
|
+
// React Compiler — controlled by reactCompiler in config (inline or file).
|
|
585
|
+
// If set in inline config, resolve immediately. If it comes from
|
|
586
|
+
// timber.config.ts, it's picked up in rootSync's config hook and
|
|
587
|
+
// resolved lazily via the timber-react-compiler wrapper plugin.
|
|
588
|
+
const reactCompilerPlugins: PluginOption[] = [];
|
|
589
|
+
if (config?.reactCompiler) {
|
|
590
|
+
// Inline config — resolve eagerly (preserves sync throw on missing dep)
|
|
591
|
+
reactCompilerPlugins.push(resolveReactCompilerPlugin(config.reactCompiler, consumerRequire));
|
|
592
|
+
}
|
|
593
|
+
// Lazy wrapper for file-based reactCompiler config (timber.config.ts).
|
|
594
|
+
// After rootSync loads the file config in its `config` hook, this plugin's
|
|
595
|
+
// `configResolved` hook checks if reactCompiler was added by the file and
|
|
596
|
+
// not already resolved from inline config. If so, it resolves and copies
|
|
597
|
+
// the babel plugin's hooks onto itself so Vite invokes them.
|
|
598
|
+
const lazyReactCompiler: Plugin = {
|
|
599
|
+
name: 'timber-react-compiler',
|
|
600
|
+
configResolved() {
|
|
601
|
+
// Skip if already resolved from inline config or not configured
|
|
602
|
+
if (config?.reactCompiler || !ctx.config.reactCompiler) return;
|
|
603
|
+
// File config set reactCompiler — resolve and copy hooks
|
|
604
|
+
const resolved = resolveReactCompilerPlugin(
|
|
605
|
+
ctx.config.reactCompiler,
|
|
606
|
+
consumerRequire
|
|
607
|
+
) as Plugin;
|
|
608
|
+
// Copy transform/resolveId/etc hooks from the babel plugin
|
|
609
|
+
for (const key of Object.keys(resolved) as (keyof Plugin)[]) {
|
|
610
|
+
if (key !== 'name') {
|
|
611
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
612
|
+
(lazyReactCompiler as any)[key] = resolved[key];
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
},
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
// ── Step 6: Assemble plugin array ───────────────────────────────────
|
|
402
619
|
// @vitejs/plugin-rsc handles:
|
|
403
620
|
// - RSC/SSR/client environment setup
|
|
404
621
|
// - "use client" directive → client reference proxy transformation
|
|
405
622
|
// - "use server" directive → server reference transformation
|
|
406
623
|
// - Client reference tracking and module map generation
|
|
407
624
|
//
|
|
408
|
-
// Loaded via dynamic import() because @vitejs/plugin-rsc is ESM-only.
|
|
409
|
-
// Vite's config loader uses esbuild to transpile to CJS, which breaks
|
|
410
|
-
// static imports of ESM-only packages. The dynamic import() is preserved
|
|
411
|
-
// by esbuild and runs natively in ESM at runtime.
|
|
412
|
-
//
|
|
413
625
|
// serverHandler: false — timber has its own dev server (timber-dev-server)
|
|
414
626
|
// entries — tells the RSC plugin about timber's virtual entry modules so
|
|
415
627
|
// it correctly wires up the browser entry (needed for React Fast Refresh
|
|
@@ -422,30 +634,6 @@ export function timber(config?: TimberUserConfig): PluginOption[] {
|
|
|
422
634
|
// We do NOT set customBuildApp — the RSC plugin's orchestration is correct
|
|
423
635
|
// and handles bundle ordering, asset manifest generation, and environment
|
|
424
636
|
// imports manifest. See @vitejs/plugin-rsc's buildApp implementation.
|
|
425
|
-
// Resolve @vitejs/plugin-rsc from the consumer's project (process.cwd()),
|
|
426
|
-
// not from timber's own node_modules. This is critical for pnpm link:
|
|
427
|
-
// when linked, timber's node_modules has a separate vite instance, and
|
|
428
|
-
// the RSC plugin must use the same vite instance as the dev server.
|
|
429
|
-
const consumerRequire = createRequire(join(process.cwd(), 'package.json'));
|
|
430
|
-
const rscPluginPath = consumerRequire.resolve('@vitejs/plugin-rsc');
|
|
431
|
-
ctx.timer.start('rsc-plugin-import');
|
|
432
|
-
const rscPluginsPromise = import(pathToFileURL(rscPluginPath).href).then(
|
|
433
|
-
({ default: vitePluginRsc }) => {
|
|
434
|
-
ctx.timer.end('rsc-plugin-import');
|
|
435
|
-
return vitePluginRsc({
|
|
436
|
-
serverHandler: false,
|
|
437
|
-
customClientEntry: true,
|
|
438
|
-
entries: {
|
|
439
|
-
rsc: 'virtual:timber-rsc-entry',
|
|
440
|
-
ssr: 'virtual:timber-ssr-entry',
|
|
441
|
-
client: 'virtual:timber-browser-entry',
|
|
442
|
-
},
|
|
443
|
-
// No custom clientChunks — Rolldown handles natural code splitting.
|
|
444
|
-
// See design/27-chunking-strategy.md and LOCAL-337.
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
);
|
|
448
|
-
|
|
449
637
|
return [
|
|
450
638
|
rootSync,
|
|
451
639
|
timberReactProd(),
|
|
@@ -454,15 +642,16 @@ export function timber(config?: TimberUserConfig): PluginOption[] {
|
|
|
454
642
|
// following Vinext's convention — the RSC plugin's virtual browser entry
|
|
455
643
|
// coordinates with plugin-react via __vite_plugin_react_preamble_installed__.
|
|
456
644
|
react(),
|
|
645
|
+
...reactCompilerPlugins,
|
|
646
|
+
lazyReactCompiler,
|
|
457
647
|
timberServerActionExports(),
|
|
458
|
-
|
|
648
|
+
vitePluginRsc(createRscOptions(ctx, encryptionKeyExpr)),
|
|
459
649
|
timberShims(ctx),
|
|
460
650
|
timberRouting(ctx),
|
|
461
651
|
timberEntries(ctx),
|
|
462
652
|
timberBuildManifest(ctx),
|
|
463
653
|
timberCache(ctx),
|
|
464
654
|
timberStaticBuild(ctx),
|
|
465
|
-
timberDynamicTransform(ctx),
|
|
466
655
|
timberFonts(ctx),
|
|
467
656
|
timberMdx(ctx),
|
|
468
657
|
timberContent(ctx),
|
|
@@ -471,6 +660,7 @@ export function timber(config?: TimberUserConfig): PluginOption[] {
|
|
|
471
660
|
timberBuildReport(ctx), // Post-build: route table with bundle sizes
|
|
472
661
|
timberAdapterBuild(ctx), // Post-build: invoke adapter.buildOutput()
|
|
473
662
|
timberDevLogs(ctx), // Dev-only: forward server console.* to browser console
|
|
663
|
+
timberDevBrowserLogs(ctx), // Dev-only: forward browser console.* to server terminal
|
|
474
664
|
timberDevServer(ctx), // Must be last — configureServer post-hook runs after all watchers
|
|
475
665
|
];
|
|
476
666
|
}
|
|
@@ -488,4 +678,26 @@ export function timber(config?: TimberUserConfig): PluginOption[] {
|
|
|
488
678
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
489
679
|
export interface Routes {}
|
|
490
680
|
|
|
681
|
+
/**
|
|
682
|
+
* Type-safe helper for timber.config.ts files.
|
|
683
|
+
*
|
|
684
|
+
* A pass-through identity function that provides autocomplete and
|
|
685
|
+
* type checking for timber configuration. No runtime validation —
|
|
686
|
+
* purely a DX convenience (same pattern as Vite's defineConfig).
|
|
687
|
+
*
|
|
688
|
+
* @example
|
|
689
|
+
* ```ts
|
|
690
|
+
* // timber.config.ts
|
|
691
|
+
* import { defineConfig } from '@timber-js/app';
|
|
692
|
+
*
|
|
693
|
+
* export default defineConfig({
|
|
694
|
+
* output: 'server',
|
|
695
|
+
* pageExtensions: ['tsx', 'ts', 'mdx'],
|
|
696
|
+
* });
|
|
697
|
+
* ```
|
|
698
|
+
*/
|
|
699
|
+
export function defineConfig(config: TimberUserConfig): TimberUserConfig {
|
|
700
|
+
return config;
|
|
701
|
+
}
|
|
702
|
+
|
|
491
703
|
export default timber;
|