@pracht/vite-plugin 0.8.0 → 0.10.0

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/README.md CHANGED
@@ -56,12 +56,11 @@ pracht({
56
56
  Keep it opt-in for now: it is best suited to SSR-heavy pages with large static
57
57
  DOM subtrees and should be benchmarked against your app before enabling broadly.
58
58
 
59
- ## TSRX (`.tsrx`) Support
59
+ ## Additional Route Extensions
60
60
 
61
- `.tsrx` modules TSRX/Ripple-flavoured Preact components are supported out
62
- of the box. Bring your own
63
- [`@tsrx/vite-plugin-preact`](https://github.com/Ripple-TS/ripple) and add it to
64
- your `plugins` array alongside `pracht()`:
61
+ Use `additionalExtensions` when a Vite plugin compiles route or shell modules
62
+ with another file extension. For example, TSRX can use the explicit generic
63
+ configuration (while remaining implicitly supported for compatibility):
65
64
 
66
65
  ```ts
67
66
  // vite.config.ts
@@ -70,13 +69,28 @@ import { pracht } from "@pracht/vite-plugin";
70
69
  import { tsrxPreact } from "@tsrx/vite-plugin-preact";
71
70
 
72
71
  export default defineConfig({
73
- plugins: [tsrxPreact(), pracht()],
72
+ plugins: [tsrxPreact(), pracht({ additionalExtensions: [".tsrx"] })],
74
73
  });
75
74
  ```
76
75
 
77
- The pracht plugin globs `.tsrx` files alongside `.tsx` for routes and shells
78
- (both manifest- and pages-router modes), and its server-only export stripping
79
- pass treats them the same way no separate pracht option is required.
76
+ Extensions must be dot-prefixed. Pracht discovers configured extensions in
77
+ route and shell directories for both manifest and pages-router modes and strips
78
+ server-only route exports from client bundles. Vite-scannable component formats
79
+ join initial dependency scanning automatically; other format plugins must opt
80
+ their extension into Vite's dependency optimizer. The companion plugin remains
81
+ responsible for compiling the file format, and the app should provide any
82
+ ambient TypeScript module declaration that format requires. Keep the array
83
+ inline or in a directly referenced `const` for complete CLI verification;
84
+ dynamic expressions still build but produce a verification warning.
85
+
86
+ Configured formats are treated as potentially head-bearing even when their raw
87
+ source has no JavaScript `head()` export. The companion transform may synthesize
88
+ that export from frontmatter or other custom syntax, so loaderless client
89
+ navigation conservatively keeps its route-state request.
90
+
91
+ Existing `.tsrx` routes and shells remain discovered without
92
+ `additionalExtensions`, and Pracht keeps its ambient `.tsrx` declaration so a
93
+ compatible CLI patch cannot strand applications on the previous plugin minor.
80
94
 
81
95
  ## Peer Dependencies
82
96
 
package/dist/index.d.mts CHANGED
@@ -91,6 +91,18 @@ interface PrachtAdapter {
91
91
  * into the server output.
92
92
  */
93
93
  edge?: boolean;
94
+ /**
95
+ * If true, the adapter produces a pure static export with no server at
96
+ * runtime (e.g. `@pracht/adapter-static`). Production builds then define
97
+ * `__PRACHT_STATIC_TARGET__` as `true`, which switches the client router's
98
+ * route-state fetching from the live `x-pracht-route-state-request`
99
+ * endpoint to the serialized `/_pracht/state/…` files that `pracht build`
100
+ * emits. Dev servers keep the live endpoint (the flag only applies to
101
+ * builds). Custom static targets must also expose the static artifact hooks
102
+ * generated by `@pracht/adapter-static`; the CLI fails when a configured
103
+ * not-found or fallback artifact cannot be rendered.
104
+ */
105
+ staticTarget?: boolean;
94
106
  }
95
107
  //#endregion
96
108
  //#region src/plugin-options.d.ts
@@ -124,13 +136,41 @@ interface PrachtLlmsTxtOptions {
124
136
  */
125
137
  exclude?: string[];
126
138
  }
139
+ /**
140
+ * Optional client-router features, compiled out of the client bundle when
141
+ * disabled. Every one defaults to `true`. Turn a feature off only when the app
142
+ * really does not use it: the router silently stops honouring the
143
+ * corresponding route options and `<Link>` props.
144
+ */
145
+ interface PrachtClientOptions {
146
+ /**
147
+ * JS prefetching of route-state JSON and route/shell chunks, driven by
148
+ * `route({ prefetch })` and `<Link prefetch>`. Off also drops the separate
149
+ * prefetch chunk the router loads on every page, and makes the imperative
150
+ * `prefetch()` export a no-op.
151
+ */
152
+ prefetch?: boolean;
153
+ }
127
154
  interface PrachtPluginOptions {
155
+ /**
156
+ * Switch off client-router features the app does not use, so they are
157
+ * compiled out of the client bundle. See {@link PrachtClientOptions}.
158
+ */
159
+ client?: PrachtClientOptions;
128
160
  appFile?: string;
129
161
  routesDir?: string;
130
162
  shellsDir?: string;
131
163
  middlewareDir?: string;
132
164
  apiDir?: string;
133
165
  serverDir?: string;
166
+ /**
167
+ * Additional dot-prefixed route and shell module extensions to discover,
168
+ * such as `[".vue"]`. Register the Vite plugin that transforms the format
169
+ * separately; Pracht only discovers the modules and applies its route
170
+ * client/server handling. Defaults to no additional extensions. `.tsrx`
171
+ * remains discovered without configuration for backward compatibility.
172
+ */
173
+ additionalExtensions?: readonly string[];
134
174
  /**
135
175
  * Directory containing island components hydrated on
136
176
  * `hydration: "islands"` routes. Defaults to "/src/islands".
@@ -194,6 +234,8 @@ declare function createPrachtIslandsClientModuleSource(options?: PrachtPluginOpt
194
234
  declare function createPrachtServerModuleSource(options?: PrachtPluginOptions, buildOptions?: {
195
235
  root?: string;
196
236
  isBuild?: boolean;
237
+ base?: string;
238
+ configuredBase?: string;
197
239
  }): string;
198
240
  declare function createPrachtRegistryModuleSource(options?: PrachtPluginOptions): string;
199
241
  //#endregion
@@ -245,4 +287,4 @@ declare function createPrachtWebmcpModuleSource(options?: PrachtPluginOptions, b
245
287
  //#region src/index.d.ts
246
288
  declare function pracht(options?: PrachtPluginOptions): Plugin[];
247
289
  //#endregion
248
- export { type EnvLeakReference, type EnvSafetyOptions, type LlmsTxtSection, PRACHT_CAPABILITIES_MODULE_ID, PRACHT_CLIENT_MODULE_ID, PRACHT_ISLANDS_CLIENT_MODULE_ID, PRACHT_SERVER_MODULE_ID, PRACHT_WEBMCP_MODULE_ID, PUBLIC_ENV_PREFIX, type PrachtAdapter, type PrachtLlmsTxtOptions, type PrachtPluginOptions, type RenderMode, VITE_BUILTIN_ENV_VARS, createEnvSafetyPlugin, createPrachtCapabilitiesClientModuleSource, createPrachtClientModuleSource, createPrachtIslandsClientModuleSource, createPrachtRegistryModuleSource, createPrachtServerModuleSource, createPrachtWebmcpModuleSource, extractCapabilities, formatEnvLeakError, pracht, scanCodeForEnvLeaks };
290
+ export { type EnvLeakReference, type EnvSafetyOptions, type LlmsTxtSection, PRACHT_CAPABILITIES_MODULE_ID, PRACHT_CLIENT_MODULE_ID, PRACHT_ISLANDS_CLIENT_MODULE_ID, PRACHT_SERVER_MODULE_ID, PRACHT_WEBMCP_MODULE_ID, PUBLIC_ENV_PREFIX, type PrachtAdapter, type PrachtClientOptions, type PrachtLlmsTxtOptions, type PrachtPluginOptions, type RenderMode, VITE_BUILTIN_ENV_VARS, createEnvSafetyPlugin, createPrachtCapabilitiesClientModuleSource, createPrachtClientModuleSource, createPrachtIslandsClientModuleSource, createPrachtRegistryModuleSource, createPrachtServerModuleSource, createPrachtWebmcpModuleSource, extractCapabilities, formatEnvLeakError, pracht, scanCodeForEnvLeaks };