@pracht/vite-plugin 0.7.6 → 0.9.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 +31 -9
- package/dist/index.d.mts +42 -0
- package/dist/index.mjs +597 -101
- package/dist/pages-router-KcCRkhnf.mjs +588 -0
- package/dist/pages-router.d.mts +5 -1
- package/dist/pages-router.mjs +1 -1
- package/package.json +7 -5
- package/dist/pages-router-CStJY2Zp.mjs +0 -254
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
|
-
##
|
|
59
|
+
## Additional Route Extensions
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
|
|
@@ -86,3 +100,11 @@ Target-specific Vite plugins (e.g. `@cloudflare/vite-plugin`) are pulled in by
|
|
|
86
100
|
the adapter package you install (`@pracht/adapter-cloudflare`,
|
|
87
101
|
`@pracht/adapter-vercel`, etc.). The default path uses `@pracht/adapter-node`,
|
|
88
102
|
which ships as a dependency of this package.
|
|
103
|
+
|
|
104
|
+
Custom adapters can expose two separate plugin hooks on `PrachtAdapter`:
|
|
105
|
+
|
|
106
|
+
- `vitePlugins()` for the platform's normal development and build integration.
|
|
107
|
+
- `graphVitePlugins()` for metadata-only CLI servers. This optional hook must
|
|
108
|
+
not start runtimes, listeners, persistent workers, or debuggers; use it only
|
|
109
|
+
for safe resolvers or platform-module stubs. When omitted, graph commands
|
|
110
|
+
load no adapter-contributed plugins.
|
package/dist/index.d.mts
CHANGED
|
@@ -70,6 +70,13 @@ interface PrachtAdapter {
|
|
|
70
70
|
* Returned plugins are appended to the plugin array returned by `pracht()`.
|
|
71
71
|
*/
|
|
72
72
|
vitePlugins?(): Plugin[];
|
|
73
|
+
/**
|
|
74
|
+
* Vite plugins that can safely run in the CLI's graph-only server. These
|
|
75
|
+
* plugins may provide runtime-module stubs or other metadata-only support,
|
|
76
|
+
* but must not start deployment runtimes, listeners, or persistent workers.
|
|
77
|
+
* When omitted, graph commands load no adapter-contributed plugins.
|
|
78
|
+
*/
|
|
79
|
+
graphVitePlugins?(): Plugin[];
|
|
73
80
|
/**
|
|
74
81
|
* If true, the adapter owns dev-server request handling and the vite-plugin
|
|
75
82
|
* will not install its own SSR middleware. Used when the adapter contributes
|
|
@@ -84,6 +91,18 @@ interface PrachtAdapter {
|
|
|
84
91
|
* into the server output.
|
|
85
92
|
*/
|
|
86
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;
|
|
87
106
|
}
|
|
88
107
|
//#endregion
|
|
89
108
|
//#region src/plugin-options.d.ts
|
|
@@ -103,6 +122,19 @@ interface PrachtLlmsTxtOptions {
|
|
|
103
122
|
origin?: string;
|
|
104
123
|
/** Sections to emit. Defaults to ["pages", "api", "capabilities"]. */
|
|
105
124
|
include?: LlmsTxtSection[];
|
|
125
|
+
/**
|
|
126
|
+
* Route/API path patterns to leave out, using the same segment globs as
|
|
127
|
+
* `defineApp({ constraints })` (`*` = one segment, trailing `**` = the
|
|
128
|
+
* rest). llms.txt invites agents to fetch every URL it lists, so exclude
|
|
129
|
+
* anything an anonymous agent cannot use — pages behind an auth middleware,
|
|
130
|
+
* internal tooling, deliberate error routes. Capabilities are matched by
|
|
131
|
+
* their dispatch path (`/api/capabilities/**`).
|
|
132
|
+
*
|
|
133
|
+
* ```ts
|
|
134
|
+
* llmsTxt: { exclude: ["/dashboard", "/admin/**"] }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
exclude?: string[];
|
|
106
138
|
}
|
|
107
139
|
interface PrachtPluginOptions {
|
|
108
140
|
appFile?: string;
|
|
@@ -111,6 +143,14 @@ interface PrachtPluginOptions {
|
|
|
111
143
|
middlewareDir?: string;
|
|
112
144
|
apiDir?: string;
|
|
113
145
|
serverDir?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Additional dot-prefixed route and shell module extensions to discover,
|
|
148
|
+
* such as `[".vue"]`. Register the Vite plugin that transforms the format
|
|
149
|
+
* separately; Pracht only discovers the modules and applies its route
|
|
150
|
+
* client/server handling. Defaults to no additional extensions. `.tsrx`
|
|
151
|
+
* remains discovered without configuration for backward compatibility.
|
|
152
|
+
*/
|
|
153
|
+
additionalExtensions?: readonly string[];
|
|
114
154
|
/**
|
|
115
155
|
* Directory containing island components hydrated on
|
|
116
156
|
* `hydration: "islands"` routes. Defaults to "/src/islands".
|
|
@@ -174,6 +214,8 @@ declare function createPrachtIslandsClientModuleSource(options?: PrachtPluginOpt
|
|
|
174
214
|
declare function createPrachtServerModuleSource(options?: PrachtPluginOptions, buildOptions?: {
|
|
175
215
|
root?: string;
|
|
176
216
|
isBuild?: boolean;
|
|
217
|
+
base?: string;
|
|
218
|
+
configuredBase?: string;
|
|
177
219
|
}): string;
|
|
178
220
|
declare function createPrachtRegistryModuleSource(options?: PrachtPluginOptions): string;
|
|
179
221
|
//#endregion
|