@ripple-ts/vite-plugin 0.2.213 → 0.2.214
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/CHANGELOG.md +12 -0
- package/package.json +14 -3
- package/src/bin/preview.js +43 -0
- package/src/constants.js +2 -0
- package/src/index.js +493 -192
- package/src/load-config.js +172 -0
- package/src/server/production.js +119 -93
- package/src/server/render-route.js +1 -1
- package/src/server/virtual-entry.js +215 -0
- package/types/index.d.ts +117 -1
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
1
|
+
import type { Plugin, BuildEnvironmentOptions, ViteDevServer } from 'vite';
|
|
2
|
+
import type { RuntimePrimitives } from '@ripple-ts/adapter';
|
|
2
3
|
|
|
3
4
|
declare module '@ripple-ts/vite-plugin' {
|
|
4
5
|
// ============================================================================
|
|
@@ -7,6 +8,16 @@ declare module '@ripple-ts/vite-plugin' {
|
|
|
7
8
|
|
|
8
9
|
export function ripple(options?: RipplePluginOptions): Plugin[];
|
|
9
10
|
export function defineConfig(options: RippleConfigOptions): RippleConfigOptions;
|
|
11
|
+
export function resolveRippleConfig(
|
|
12
|
+
raw: RippleConfigOptions,
|
|
13
|
+
options?: { requireAdapter?: boolean },
|
|
14
|
+
): ResolvedRippleConfig;
|
|
15
|
+
export function getRippleConfigPath(projectRoot: string): string;
|
|
16
|
+
export function rippleConfigExists(projectRoot: string): boolean;
|
|
17
|
+
export function loadRippleConfig(
|
|
18
|
+
projectRoot: string,
|
|
19
|
+
options?: { vite?: ViteDevServer; requireAdapter?: boolean },
|
|
20
|
+
): Promise<ResolvedRippleConfig>;
|
|
10
21
|
|
|
11
22
|
// ============================================================================
|
|
12
23
|
// Route classes
|
|
@@ -90,10 +101,23 @@ declare module '@ripple-ts/vite-plugin' {
|
|
|
90
101
|
|
|
91
102
|
export interface RippleConfigOptions {
|
|
92
103
|
build?: {
|
|
104
|
+
/** Output directory for the production build. @default 'dist' */
|
|
105
|
+
outDir?: string;
|
|
93
106
|
minify?: boolean;
|
|
107
|
+
target?: BuildEnvironmentOptions['target'];
|
|
94
108
|
};
|
|
95
109
|
adapter?: {
|
|
96
110
|
serve: AdapterServeFunction;
|
|
111
|
+
/**
|
|
112
|
+
* Platform-specific runtime primitives provided by the adapter.
|
|
113
|
+
*
|
|
114
|
+
* These allow the server runtime to operate without depending
|
|
115
|
+
* on Node.js-specific APIs like `node:crypto` or `node:async_hooks`.
|
|
116
|
+
*
|
|
117
|
+
* Required for production builds. In development, the vite plugin
|
|
118
|
+
* falls back to Node.js defaults if not provided.
|
|
119
|
+
*/
|
|
120
|
+
runtime: RuntimePrimitives;
|
|
97
121
|
};
|
|
98
122
|
router: {
|
|
99
123
|
routes: Route[];
|
|
@@ -118,8 +142,100 @@ declare module '@ripple-ts/vite-plugin' {
|
|
|
118
142
|
};
|
|
119
143
|
}
|
|
120
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Resolved configuration with all defaults applied.
|
|
147
|
+
* Returned by `resolveRippleConfig` and `loadRippleConfig`.
|
|
148
|
+
* Consumers should use this type instead of applying ad-hoc defaults.
|
|
149
|
+
*/
|
|
150
|
+
export interface ResolvedRippleConfig {
|
|
151
|
+
build: {
|
|
152
|
+
/** @default 'dist' */
|
|
153
|
+
outDir: string;
|
|
154
|
+
minify?: boolean;
|
|
155
|
+
target?: BuildEnvironmentOptions['target'];
|
|
156
|
+
};
|
|
157
|
+
adapter?: {
|
|
158
|
+
serve: AdapterServeFunction;
|
|
159
|
+
runtime: RuntimePrimitives;
|
|
160
|
+
};
|
|
161
|
+
router: {
|
|
162
|
+
routes: Route[];
|
|
163
|
+
};
|
|
164
|
+
/** @default [] */
|
|
165
|
+
middlewares: Middleware[];
|
|
166
|
+
platform: {
|
|
167
|
+
/** @default {} */
|
|
168
|
+
env: Record<string, string>;
|
|
169
|
+
};
|
|
170
|
+
server: {
|
|
171
|
+
/** @default false */
|
|
172
|
+
trustProxy: boolean;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
121
176
|
export type AdapterServeFunction = (
|
|
122
177
|
handler: (request: Request, platform?: unknown) => Response | Promise<Response>,
|
|
123
178
|
options?: Record<string, unknown>,
|
|
124
179
|
) => { listen: (port?: number) => unknown; close: () => void };
|
|
125
180
|
}
|
|
181
|
+
|
|
182
|
+
declare module '@ripple-ts/vite-plugin/production' {
|
|
183
|
+
import type {
|
|
184
|
+
Route,
|
|
185
|
+
Middleware,
|
|
186
|
+
RuntimePrimitives,
|
|
187
|
+
ResolvedRippleConfig,
|
|
188
|
+
RippleConfigOptions,
|
|
189
|
+
} from '@ripple-ts/vite-plugin';
|
|
190
|
+
|
|
191
|
+
export function resolveRippleConfig(
|
|
192
|
+
raw: RippleConfigOptions,
|
|
193
|
+
options?: { requireAdapter?: boolean },
|
|
194
|
+
): ResolvedRippleConfig;
|
|
195
|
+
|
|
196
|
+
export interface ClientAssetEntry {
|
|
197
|
+
/** Path to the built JS file (relative to client output dir) */
|
|
198
|
+
js: string;
|
|
199
|
+
/** Paths to the built CSS files (relative to client output dir) */
|
|
200
|
+
css: string[];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface ServerManifest {
|
|
204
|
+
routes: Route[];
|
|
205
|
+
components: Record<string, Function>;
|
|
206
|
+
layouts: Record<string, Function>;
|
|
207
|
+
middlewares: Middleware[];
|
|
208
|
+
/** Map of entry path → _$_server_$_ object for RPC support */
|
|
209
|
+
rpcModules?: Record<string, Record<string, Function>>;
|
|
210
|
+
/** Trust X-Forwarded-* headers when deriving origin for RPC fetch */
|
|
211
|
+
trustProxy?: boolean;
|
|
212
|
+
/** Platform-specific runtime primitives from the adapter */
|
|
213
|
+
runtime: RuntimePrimitives;
|
|
214
|
+
/**
|
|
215
|
+
* Map of route entry paths to their built client asset paths.
|
|
216
|
+
* Used to emit `<link rel="stylesheet">` and `<link rel="modulepreload">`
|
|
217
|
+
* tags in the production HTML. Populated from Vite's client manifest
|
|
218
|
+
* during the build. The special key `__hydrate_js` holds the hydrate
|
|
219
|
+
* runtime entry.
|
|
220
|
+
*/
|
|
221
|
+
clientAssets?: Record<string, ClientAssetEntry>;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface RenderResult {
|
|
225
|
+
head: string;
|
|
226
|
+
body: string;
|
|
227
|
+
css: Set<string>;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface HandlerOptions {
|
|
231
|
+
render: (component: Function) => Promise<RenderResult>;
|
|
232
|
+
getCss: (css: Set<string>) => string;
|
|
233
|
+
htmlTemplate: string;
|
|
234
|
+
executeServerFunction: (fn: Function, body: string) => Promise<string>;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function createHandler(
|
|
238
|
+
manifest: ServerManifest,
|
|
239
|
+
options: HandlerOptions,
|
|
240
|
+
): (request: Request) => Promise<Response>;
|
|
241
|
+
}
|