@hono/vite-build 1.11.0 → 1.11.1
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/dist/adapter/bun/{index.d.ts → index.d.mts} +6 -6
- package/dist/adapter/bun/index.mjs +47 -0
- package/dist/adapter/cloudflare-pages/{index.d.ts → index.d.mts} +5 -5
- package/dist/adapter/cloudflare-pages/index.mjs +41 -0
- package/dist/adapter/cloudflare-workers/{index.d.ts → index.d.mts} +6 -5
- package/dist/adapter/cloudflare-workers/index.mjs +33 -0
- package/dist/adapter/deno/index.d.mts +10 -0
- package/dist/adapter/deno/index.mjs +21 -0
- package/dist/adapter/netlify-functions/{index.d.ts → index.d.mts} +5 -5
- package/dist/adapter/netlify-functions/index.mjs +16 -0
- package/dist/adapter/node/index.d.mts +19 -0
- package/dist/adapter/node/index.mjs +37 -0
- package/dist/adapter/vercel/index.d.mts +22 -0
- package/dist/adapter/vercel/index.mjs +170 -0
- package/dist/adapter/vercel/types.d.mts +276 -0
- package/dist/adapter/vercel/types.mjs +1 -0
- package/dist/base.d.mts +30 -0
- package/dist/base.mjs +99 -0
- package/dist/entry/index.d.mts +27 -0
- package/dist/entry/index.mjs +63 -0
- package/dist/entry/{serve-static.d.ts → serve-static.d.mts} +5 -4
- package/dist/entry/serve-static.mjs +8 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +5 -0
- package/package.json +21 -53
- package/dist/adapter/bun/index.js +0 -55
- package/dist/adapter/cloudflare-pages/index.js +0 -53
- package/dist/adapter/cloudflare-workers/index.js +0 -37
- package/dist/adapter/deno/index.d.ts +0 -10
- package/dist/adapter/deno/index.js +0 -28
- package/dist/adapter/netlify-functions/index.js +0 -18
- package/dist/adapter/node/index.d.ts +0 -19
- package/dist/adapter/node/index.js +0 -50
- package/dist/adapter/vercel/index.d.ts +0 -22
- package/dist/adapter/vercel/index.js +0 -213
- package/dist/adapter/vercel/types.d.ts +0 -368
- package/dist/adapter/vercel/types.js +0 -0
- package/dist/base.d.ts +0 -29
- package/dist/base.js +0 -112
- package/dist/entry/index.d.ts +0 -26
- package/dist/entry/index.js +0 -69
- package/dist/entry/serve-static.js +0 -11
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -6
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Main configuration type for Vercel Build Output API v3.
|
|
3
|
-
* This type represents the root configuration object that should be output in the `.vercel/output/config.json` file.
|
|
4
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration
|
|
5
|
-
*/
|
|
6
|
-
type VercelBuildConfigV3 = {
|
|
7
|
-
/** Version identifier for the Build Output API. Must be 3. */
|
|
8
|
-
version?: 3;
|
|
9
|
-
/**
|
|
10
|
-
* Array of routing rules to handle incoming requests.
|
|
11
|
-
* Routes are evaluated in order, where the first matching route will be applied.
|
|
12
|
-
*/
|
|
13
|
-
routes?: Route[];
|
|
14
|
-
/**
|
|
15
|
-
* Configuration for Vercel's Image Optimization feature.
|
|
16
|
-
* Defines how images should be optimized, cached, and served.
|
|
17
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#images
|
|
18
|
-
*/
|
|
19
|
-
images?: ImagesConfig;
|
|
20
|
-
/**
|
|
21
|
-
* Custom domain wildcard configurations for internationalization.
|
|
22
|
-
* Maps domain names to values that can be referenced by the routes configuration.
|
|
23
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#wildcard
|
|
24
|
-
*/
|
|
25
|
-
wildcard?: WildCard[];
|
|
26
|
-
/**
|
|
27
|
-
* File-specific overrides for static files in the `.vercel/output/static` directory.
|
|
28
|
-
* Allows overriding Content-Type headers and URL paths for static files.
|
|
29
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#overrides
|
|
30
|
-
*/
|
|
31
|
-
overrides?: Record<string, Override>;
|
|
32
|
-
/**
|
|
33
|
-
* Array of file paths or glob patterns to be cached between builds.
|
|
34
|
-
* Only relevant when Vercel is building from source code.
|
|
35
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#cache
|
|
36
|
-
*/
|
|
37
|
-
cache?: string[];
|
|
38
|
-
/**
|
|
39
|
-
* Scheduled tasks configuration for production deployments.
|
|
40
|
-
* Defines API routes that should be invoked on a schedule.
|
|
41
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#crons
|
|
42
|
-
*/
|
|
43
|
-
crons?: Cron[];
|
|
44
|
-
/**
|
|
45
|
-
* Framework metadata for display purposes only.
|
|
46
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#framework
|
|
47
|
-
*/
|
|
48
|
-
framework?: Framework;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Route configuration that can either be a Source route or a Handler route.
|
|
52
|
-
* Source routes match incoming requests, while Handler routes define special behaviors.
|
|
53
|
-
*/
|
|
54
|
-
type Route = Source | Handler;
|
|
55
|
-
/**
|
|
56
|
-
* Source route configuration for matching and handling incoming requests.
|
|
57
|
-
* Provides detailed control over request matching and response handling.
|
|
58
|
-
*/
|
|
59
|
-
type Source = {
|
|
60
|
-
/** Regular expression pattern to match incoming request paths */
|
|
61
|
-
src: string;
|
|
62
|
-
/** Path to rewrite or redirect the matched request to */
|
|
63
|
-
dest?: string;
|
|
64
|
-
/** Custom HTTP headers to add to the response */
|
|
65
|
-
headers?: Record<string, string>;
|
|
66
|
-
/** Array of HTTP methods this route should match */
|
|
67
|
-
methods?: string[];
|
|
68
|
-
/** When true, matching will continue even after this route matches */
|
|
69
|
-
continue?: boolean;
|
|
70
|
-
/** When true, the src pattern will be matched case-sensitively */
|
|
71
|
-
caseSensitive?: boolean;
|
|
72
|
-
/** Additional validation flag for route matching */
|
|
73
|
-
check?: boolean;
|
|
74
|
-
/** HTTP status code to return (e.g., 308 for redirects) */
|
|
75
|
-
status?: number;
|
|
76
|
-
/** Conditions that must be present in the request for the route to match */
|
|
77
|
-
has?: HasField;
|
|
78
|
-
/** Conditions that must be absent from the request for the route to match */
|
|
79
|
-
missing?: HasField;
|
|
80
|
-
/** Configuration for locale-based routing and redirects */
|
|
81
|
-
locale?: Locale;
|
|
82
|
-
/** Raw source patterns used by middleware */
|
|
83
|
-
middlewareRawSrc?: string[];
|
|
84
|
-
/** Path to the middleware implementation file */
|
|
85
|
-
middlewarePath?: string;
|
|
86
|
-
/** Mitigation action to apply to the route */
|
|
87
|
-
mitigate?: Mitigate;
|
|
88
|
-
/** List of transforms to apply to the route */
|
|
89
|
-
transforms?: Transform[];
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Locale configuration for internationalization routing.
|
|
93
|
-
* Used to configure language-specific redirects and preferences.
|
|
94
|
-
*/
|
|
95
|
-
type Locale = {
|
|
96
|
-
/** Mapping of locale codes to their redirect destinations */
|
|
97
|
-
redirect?: Record<string, string>;
|
|
98
|
-
/** Name of the cookie used to store the user's locale preference */
|
|
99
|
-
cookie?: string;
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Matchable value for complex route condition matching.
|
|
103
|
-
* Allows matching against values using various comparison operators.
|
|
104
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#source-route-matchablevalue
|
|
105
|
-
*/
|
|
106
|
-
type MatchableValue = {
|
|
107
|
-
/** Value must equal this value */
|
|
108
|
-
eq?: string | number;
|
|
109
|
-
/** Value must not equal this value */
|
|
110
|
-
neq?: string;
|
|
111
|
-
/** Value must be included in this array */
|
|
112
|
-
inc?: string[];
|
|
113
|
-
/** Value must not be included in this array */
|
|
114
|
-
ninc?: string[];
|
|
115
|
-
/** Value must start with this prefix */
|
|
116
|
-
pre?: string;
|
|
117
|
-
/** Value must end with this suffix */
|
|
118
|
-
suf?: string;
|
|
119
|
-
/** Value must match this regular expression */
|
|
120
|
-
re?: string;
|
|
121
|
-
/** Value must be greater than this number */
|
|
122
|
-
gt?: number;
|
|
123
|
-
/** Value must be greater than or equal to this number */
|
|
124
|
-
gte?: number;
|
|
125
|
-
/** Value must be less than this number */
|
|
126
|
-
lt?: number;
|
|
127
|
-
/** Value must be less than or equal to this number */
|
|
128
|
-
lte?: number;
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* Condition fields for route matching based on request properties.
|
|
132
|
-
* Used in `has` and `missing` arrays on Source routes.
|
|
133
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#source-route-hasfield
|
|
134
|
-
*/
|
|
135
|
-
type HasField = Array<{
|
|
136
|
-
/** Identifies this as a host matching condition */
|
|
137
|
-
type: 'host';
|
|
138
|
-
/** Pattern to match against the Host header */
|
|
139
|
-
value: string | MatchableValue;
|
|
140
|
-
} | {
|
|
141
|
-
/** Identifies the condition type: header, cookie, or query parameter */
|
|
142
|
-
type: 'header' | 'cookie' | 'query';
|
|
143
|
-
/** Name of the header, cookie, or query parameter to match */
|
|
144
|
-
key: string;
|
|
145
|
-
/** Optional value the field should match */
|
|
146
|
-
value?: string | MatchableValue;
|
|
147
|
-
}>;
|
|
148
|
-
/**
|
|
149
|
-
* Special handler phases for request processing.
|
|
150
|
-
* Defines when and how requests should be processed in the routing pipeline.
|
|
151
|
-
*/
|
|
152
|
-
type HandleValue = 'rewrite' | 'filesystem' | 'resource' | 'miss' | 'hit' | 'error';
|
|
153
|
-
/**
|
|
154
|
-
* Handler route configuration for special request processing phases.
|
|
155
|
-
* Used to define behavior at specific points in the request lifecycle.
|
|
156
|
-
*/
|
|
157
|
-
type Handler = {
|
|
158
|
-
/** The type of handler to process the request */
|
|
159
|
-
handle: HandleValue;
|
|
160
|
-
/** Optional pattern to match against the request path */
|
|
161
|
-
src?: string;
|
|
162
|
-
/** Optional path to handle the request with */
|
|
163
|
-
dest?: string;
|
|
164
|
-
/** HTTP status code to return in the response */
|
|
165
|
-
status?: number;
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* Mitigation action to apply to a route.
|
|
169
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#source-route-mitigate
|
|
170
|
-
*/
|
|
171
|
-
type Mitigate = {
|
|
172
|
-
/** The mitigation action to apply */
|
|
173
|
-
action: 'challenge' | 'deny';
|
|
174
|
-
};
|
|
175
|
-
/**
|
|
176
|
-
* Transform to apply to request or response properties on a route.
|
|
177
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#source-route-transform
|
|
178
|
-
*/
|
|
179
|
-
type Transform = {
|
|
180
|
-
/** The target of the transform: request headers, request query, or response headers */
|
|
181
|
-
type: 'request.headers' | 'request.query' | 'response.headers';
|
|
182
|
-
/** The operation to perform */
|
|
183
|
-
op: 'append' | 'set' | 'delete';
|
|
184
|
-
/** The target key for the transform (regex matching not supported) */
|
|
185
|
-
target: {
|
|
186
|
-
key: string | Omit<MatchableValue, 're'>;
|
|
187
|
-
};
|
|
188
|
-
/** Arguments for the transform operation */
|
|
189
|
-
args?: string | string[];
|
|
190
|
-
};
|
|
191
|
-
/**
|
|
192
|
-
* Supported image formats for the Image Optimization API.
|
|
193
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#images
|
|
194
|
-
*/
|
|
195
|
-
type ImageFormat = 'image/avif' | 'image/webp';
|
|
196
|
-
/**
|
|
197
|
-
* Configuration for remote image sources in Image Optimization.
|
|
198
|
-
* Defines patterns for matching and processing external images.
|
|
199
|
-
*/
|
|
200
|
-
type RemotePattern = {
|
|
201
|
-
/** Protocol allowed for remote images (http or https) */
|
|
202
|
-
protocol?: 'http' | 'https';
|
|
203
|
-
/** Hostname pattern that remote images must match */
|
|
204
|
-
hostname: string;
|
|
205
|
-
/** Optional port number for remote image URLs */
|
|
206
|
-
port?: string;
|
|
207
|
-
/** Path pattern that remote image URLs must match */
|
|
208
|
-
pathname?: string;
|
|
209
|
-
/** Search query pattern that remote image URLs must match */
|
|
210
|
-
search?: string;
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* Configuration for local image patterns in Image Optimization.
|
|
214
|
-
* Defines patterns for matching and processing local images.
|
|
215
|
-
*/
|
|
216
|
-
type LocalPattern = {
|
|
217
|
-
/** Path pattern that local images must match */
|
|
218
|
-
pathname?: string;
|
|
219
|
-
/** Search query pattern that local image URLs must match */
|
|
220
|
-
search?: string;
|
|
221
|
-
};
|
|
222
|
-
/**
|
|
223
|
-
* Configuration for Vercel's Image Optimization feature.
|
|
224
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#images
|
|
225
|
-
*/
|
|
226
|
-
type ImagesConfig = {
|
|
227
|
-
/** Array of allowed image widths for resizing */
|
|
228
|
-
sizes: number[];
|
|
229
|
-
/** Array of allowed domains for remote images */
|
|
230
|
-
domains: string[];
|
|
231
|
-
/** Patterns for matching remote image sources */
|
|
232
|
-
remotePatterns?: RemotePattern[];
|
|
233
|
-
/** Patterns for matching local image sources */
|
|
234
|
-
localPatterns?: LocalPattern[];
|
|
235
|
-
/** Array of allowed quality values for image optimization */
|
|
236
|
-
qualities?: number[];
|
|
237
|
-
/** Minimum time (in seconds) to cache optimized images */
|
|
238
|
-
minimumCacheTTL?: number;
|
|
239
|
-
/** Array of supported output formats for optimization */
|
|
240
|
-
formats?: ImageFormat[];
|
|
241
|
-
/** Whether to allow processing of SVG images (use with caution) */
|
|
242
|
-
dangerouslyAllowSVG?: boolean;
|
|
243
|
-
/** Content Security Policy for optimized images */
|
|
244
|
-
contentSecurityPolicy?: string;
|
|
245
|
-
/** Content-Disposition header type for image responses */
|
|
246
|
-
contentDispositionType?: string;
|
|
247
|
-
};
|
|
248
|
-
/**
|
|
249
|
-
* Configuration for custom domain wildcards.
|
|
250
|
-
* Used for internationalization and dynamic routing based on domains.
|
|
251
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#wildcard
|
|
252
|
-
*/
|
|
253
|
-
type WildCard = {
|
|
254
|
-
/** Domain name to match for this wildcard configuration */
|
|
255
|
-
domain: string;
|
|
256
|
-
/** Value to use when this wildcard matches (available as $wildcard in routes) */
|
|
257
|
-
value: string;
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* Configuration for path or content-type overrides of static files.
|
|
261
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#overrides
|
|
262
|
-
*/
|
|
263
|
-
type Override = {
|
|
264
|
-
/** URL path where the static file will be accessible */
|
|
265
|
-
path?: string;
|
|
266
|
-
/** Content-Type header value for the static file */
|
|
267
|
-
contentType?: string;
|
|
268
|
-
};
|
|
269
|
-
/**
|
|
270
|
-
* Configuration for scheduled tasks (Cron Jobs).
|
|
271
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#crons
|
|
272
|
-
*/
|
|
273
|
-
type Cron = {
|
|
274
|
-
/** Path to the API route that handles the cron job */
|
|
275
|
-
path: string;
|
|
276
|
-
/** Cron schedule expression (e.g., "0 0 * * *" for daily at midnight) */
|
|
277
|
-
schedule: string;
|
|
278
|
-
};
|
|
279
|
-
/**
|
|
280
|
-
* Framework metadata for display purposes.
|
|
281
|
-
* @see https://vercel.com/docs/build-output-api/v3/configuration#framework
|
|
282
|
-
*/
|
|
283
|
-
type Framework = {
|
|
284
|
-
/** Framework version string */
|
|
285
|
-
version: string;
|
|
286
|
-
};
|
|
287
|
-
/**
|
|
288
|
-
* Base configuration for a serverless function in Vercel.
|
|
289
|
-
* This type represents the `.vc-config.json` configuration within a `.func` directory.
|
|
290
|
-
* @see https://vercel.com/docs/build-output-api/v3/primitives#serverless-function-configuration
|
|
291
|
-
*/
|
|
292
|
-
type VercelServerlessFunctionConfig = {
|
|
293
|
-
/** Indicates the initial file where code will be executed for the Serverless Function */
|
|
294
|
-
handler: string;
|
|
295
|
-
/** Specifies which "runtime" will be used to execute the Serverless Function */
|
|
296
|
-
runtime: string;
|
|
297
|
-
/** The amount of memory (RAM in MB) allocated to the function */
|
|
298
|
-
memory?: number;
|
|
299
|
-
/** The maximum duration of the function in seconds */
|
|
300
|
-
maxDuration?: number;
|
|
301
|
-
/** Map of additional environment variables available to the function */
|
|
302
|
-
environment?: Record<string, string>;
|
|
303
|
-
/** The regions the function is available in */
|
|
304
|
-
regions?: string[];
|
|
305
|
-
/** Instruction set architecture the function supports */
|
|
306
|
-
architecture?: 'x86_64' | 'arm64';
|
|
307
|
-
/** Whether the custom runtime supports Lambda runtime wrappers */
|
|
308
|
-
supportsWrapper?: boolean;
|
|
309
|
-
/** Whether the function supports response streaming */
|
|
310
|
-
supportsResponseStreaming?: boolean;
|
|
311
|
-
};
|
|
312
|
-
/**
|
|
313
|
-
* Node.js-specific serverless function configuration.
|
|
314
|
-
* Extends the base serverless function config with Node.js launcher options.
|
|
315
|
-
* @see https://vercel.com/docs/build-output-api/v3/primitives#nodejs-config
|
|
316
|
-
*/
|
|
317
|
-
type VercelNodejsServerlessFunctionConfig = VercelServerlessFunctionConfig & {
|
|
318
|
-
/** Specifies which "launcher" will be used to execute the Serverless Function */
|
|
319
|
-
launcherType: 'Nodejs';
|
|
320
|
-
/** Enables request and response helpers methods */
|
|
321
|
-
shouldAddHelpers?: boolean;
|
|
322
|
-
/** Enables source map generation */
|
|
323
|
-
shouldAddSourcemapSupport?: boolean;
|
|
324
|
-
/** AWS Handler Value for when the serverless function uses AWS Lambda syntax */
|
|
325
|
-
awsLambdaHandler?: string;
|
|
326
|
-
};
|
|
327
|
-
/**
|
|
328
|
-
* Configuration for an Edge Function in Vercel.
|
|
329
|
-
* This type represents the `.vc-config.json` configuration for Edge Functions.
|
|
330
|
-
* @see https://vercel.com/docs/build-output-api/v3/primitives#edge-function-configuration
|
|
331
|
-
*/
|
|
332
|
-
type VercelEdgeFunctionConfig = {
|
|
333
|
-
/** Must be 'edge' to indicate this is an Edge Function */
|
|
334
|
-
runtime: 'edge';
|
|
335
|
-
/** Initial file where code will be executed for the Edge Function */
|
|
336
|
-
entrypoint: string;
|
|
337
|
-
/** List of environment variable names available to the Edge Function */
|
|
338
|
-
envVarsInUse?: string[];
|
|
339
|
-
/** Regions the edge function will be available in (defaults to 'all') */
|
|
340
|
-
regions?: 'all' | string | string[];
|
|
341
|
-
};
|
|
342
|
-
/**
|
|
343
|
-
* Configuration for a Prerender Function in Vercel (ISR).
|
|
344
|
-
* This type represents the `.prerender-config.json` configuration file.
|
|
345
|
-
* @see https://vercel.com/docs/build-output-api/v3/primitives#prerender-configuration-file
|
|
346
|
-
*/
|
|
347
|
-
type VercelPrerenderFunctionConfig = {
|
|
348
|
-
/** Cache expiration time in seconds, or false to never expire */
|
|
349
|
-
expiration: number | false;
|
|
350
|
-
/** Group number for co-revalidating prerender assets together */
|
|
351
|
-
group?: number;
|
|
352
|
-
/** Random token for Draft Mode bypass cookie (`__prerender_bypass`) */
|
|
353
|
-
bypassToken?: string;
|
|
354
|
-
/** Name of the optional fallback file relative to the configuration file */
|
|
355
|
-
fallback?: string;
|
|
356
|
-
/** Query string parameter names that will be cached independently */
|
|
357
|
-
allowQuery?: string[];
|
|
358
|
-
/** When true, the query string will be present on the request argument */
|
|
359
|
-
passQuery?: boolean;
|
|
360
|
-
/** Initial headers to include with the build-time prerendered response */
|
|
361
|
-
initialHeaders?: Record<string, string>;
|
|
362
|
-
/** Initial HTTP status code for the build-time prerendered response (default 200) */
|
|
363
|
-
initialStatus?: number;
|
|
364
|
-
/** When true, expose the response body regardless of status code including errors */
|
|
365
|
-
exposeErrBody?: boolean;
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
export { VercelBuildConfigV3, VercelEdgeFunctionConfig, VercelNodejsServerlessFunctionConfig, VercelPrerenderFunctionConfig, VercelServerlessFunctionConfig };
|
|
File without changes
|
package/dist/base.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { UserConfig, ConfigEnv, Plugin } from 'vite';
|
|
2
|
-
import { GetEntryContentOptions } from './entry/index.js';
|
|
3
|
-
|
|
4
|
-
type BuildOptions = {
|
|
5
|
-
/**
|
|
6
|
-
* @default ['src/index.ts', './src/index.tsx', './app/server.ts']
|
|
7
|
-
*/
|
|
8
|
-
entry?: string | string[];
|
|
9
|
-
/**
|
|
10
|
-
* @default './dist'
|
|
11
|
-
*/
|
|
12
|
-
output?: string;
|
|
13
|
-
outputDir?: string;
|
|
14
|
-
external?: string[];
|
|
15
|
-
/**
|
|
16
|
-
* @default true
|
|
17
|
-
*/
|
|
18
|
-
minify?: boolean;
|
|
19
|
-
emptyOutDir?: boolean;
|
|
20
|
-
apply?: ((this: void, config: UserConfig, env: ConfigEnv) => boolean) | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* @default 'webworker'
|
|
23
|
-
*/
|
|
24
|
-
ssrTarget?: 'node' | 'webworker';
|
|
25
|
-
} & Omit<GetEntryContentOptions, 'entry'>;
|
|
26
|
-
declare const defaultOptions: Required<Omit<BuildOptions, 'entryContentAfterHooks' | 'entryContentBeforeHooks' | 'entryContentDefaultExportHook'>>;
|
|
27
|
-
declare const buildPlugin: (options: BuildOptions) => Plugin;
|
|
28
|
-
|
|
29
|
-
export { BuildOptions, buildPlugin as default, defaultOptions };
|
package/dist/base.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { builtinModules } from "module";
|
|
2
|
-
import { readdirSync } from "node:fs";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
import { getEntryContent } from "./entry/index.js";
|
|
5
|
-
const defaultOptions = {
|
|
6
|
-
entry: ["src/index.ts", "./src/index.tsx", "./app/server.ts"],
|
|
7
|
-
output: "index.js",
|
|
8
|
-
outputDir: "./dist",
|
|
9
|
-
external: [],
|
|
10
|
-
minify: true,
|
|
11
|
-
emptyOutDir: false,
|
|
12
|
-
apply: (_config, { command, mode }) => {
|
|
13
|
-
if (command === "build" && mode !== "client") {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
return false;
|
|
17
|
-
},
|
|
18
|
-
staticPaths: [],
|
|
19
|
-
preset: "hono",
|
|
20
|
-
ssrTarget: "webworker"
|
|
21
|
-
};
|
|
22
|
-
const buildPlugin = (options) => {
|
|
23
|
-
const virtualEntryId = "virtual:build-entry-module";
|
|
24
|
-
const resolvedVirtualEntryId = "\0" + virtualEntryId;
|
|
25
|
-
let config;
|
|
26
|
-
const output = options.output ?? defaultOptions.output;
|
|
27
|
-
const preset = options.preset ?? defaultOptions.preset;
|
|
28
|
-
return {
|
|
29
|
-
name: "@hono/vite-build",
|
|
30
|
-
configResolved: async (resolvedConfig) => {
|
|
31
|
-
config = resolvedConfig;
|
|
32
|
-
},
|
|
33
|
-
resolveId(id) {
|
|
34
|
-
if (id === virtualEntryId) {
|
|
35
|
-
return resolvedVirtualEntryId;
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
async load(id) {
|
|
39
|
-
if (id === resolvedVirtualEntryId) {
|
|
40
|
-
const staticPaths = options.staticPaths ?? [];
|
|
41
|
-
const direntPaths = [];
|
|
42
|
-
try {
|
|
43
|
-
const publicDirPaths = readdirSync(resolve(config.root, config.publicDir), {
|
|
44
|
-
withFileTypes: true
|
|
45
|
-
});
|
|
46
|
-
direntPaths.push(...publicDirPaths);
|
|
47
|
-
} catch {
|
|
48
|
-
}
|
|
49
|
-
try {
|
|
50
|
-
const buildOutDirPaths = readdirSync(resolve(config.root, config.build.outDir), {
|
|
51
|
-
withFileTypes: true
|
|
52
|
-
});
|
|
53
|
-
direntPaths.push(...buildOutDirPaths);
|
|
54
|
-
} catch {
|
|
55
|
-
}
|
|
56
|
-
const uniqueStaticPaths = /* @__PURE__ */ new Set();
|
|
57
|
-
direntPaths.forEach((p) => {
|
|
58
|
-
if (p.isDirectory()) {
|
|
59
|
-
uniqueStaticPaths.add(`/${p.name}/*`);
|
|
60
|
-
} else {
|
|
61
|
-
if (p.name === output) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
uniqueStaticPaths.add(`/${p.name}`);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
staticPaths.push(...Array.from(uniqueStaticPaths));
|
|
68
|
-
const entry = options.entry ?? defaultOptions.entry;
|
|
69
|
-
return await getEntryContent({
|
|
70
|
-
entry: Array.isArray(entry) ? entry : [entry],
|
|
71
|
-
entryContentBeforeHooks: options.entryContentBeforeHooks,
|
|
72
|
-
entryContentAfterHooks: options.entryContentAfterHooks,
|
|
73
|
-
entryContentDefaultExportHook: options.entryContentDefaultExportHook,
|
|
74
|
-
staticPaths,
|
|
75
|
-
preset
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
apply: options?.apply ?? defaultOptions.apply,
|
|
80
|
-
config: async () => {
|
|
81
|
-
return {
|
|
82
|
-
ssr: {
|
|
83
|
-
external: options?.external ?? defaultOptions.external,
|
|
84
|
-
noExternal: true,
|
|
85
|
-
target: options?.ssrTarget ?? defaultOptions.ssrTarget
|
|
86
|
-
},
|
|
87
|
-
build: {
|
|
88
|
-
outDir: options?.outputDir ?? defaultOptions.outputDir,
|
|
89
|
-
emptyOutDir: options?.emptyOutDir ?? defaultOptions.emptyOutDir,
|
|
90
|
-
minify: options?.minify ?? defaultOptions.minify,
|
|
91
|
-
ssr: true,
|
|
92
|
-
rollupOptions: {
|
|
93
|
-
external: [
|
|
94
|
-
...builtinModules,
|
|
95
|
-
/^node:/,
|
|
96
|
-
...options?.external ?? defaultOptions.external
|
|
97
|
-
],
|
|
98
|
-
input: virtualEntryId,
|
|
99
|
-
output: {
|
|
100
|
-
entryFileNames: output
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
var base_default = buildPlugin;
|
|
109
|
-
export {
|
|
110
|
-
base_default as default,
|
|
111
|
-
defaultOptions
|
|
112
|
-
};
|
package/dist/entry/index.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
type EntryContentHookOptions = {
|
|
2
|
-
staticPaths: string[];
|
|
3
|
-
};
|
|
4
|
-
type EntryContentHook = (appName: string, options?: EntryContentHookOptions) => string | Promise<string>;
|
|
5
|
-
declare const presets: readonly ["hono", "hono/tiny", "hono/quick", "@hono/hono"];
|
|
6
|
-
type Preset = (typeof presets)[number];
|
|
7
|
-
type GetEntryContentOptions = {
|
|
8
|
-
entry: string[];
|
|
9
|
-
entryContentBeforeHooks?: EntryContentHook[];
|
|
10
|
-
entryContentAfterHooks?: EntryContentHook[];
|
|
11
|
-
/**
|
|
12
|
-
* Explicitly specify the default export for the app. Make sure your export
|
|
13
|
-
* incorporates the app passed as the `appName` argument.
|
|
14
|
-
*
|
|
15
|
-
* @default `export default ${appName}`
|
|
16
|
-
*/
|
|
17
|
-
entryContentDefaultExportHook?: EntryContentHook;
|
|
18
|
-
staticPaths?: string[];
|
|
19
|
-
/**
|
|
20
|
-
* @default `hono`
|
|
21
|
-
*/
|
|
22
|
-
preset?: Preset;
|
|
23
|
-
};
|
|
24
|
-
declare const getEntryContent: (options: GetEntryContentOptions) => Promise<string>;
|
|
25
|
-
|
|
26
|
-
export { EntryContentHook, EntryContentHookOptions, GetEntryContentOptions, Preset, getEntryContent };
|
package/dist/entry/index.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { normalize } from "node:path";
|
|
2
|
-
const presets = ["hono", "hono/tiny", "hono/quick", "@hono/hono"];
|
|
3
|
-
const normalizePaths = (paths) => {
|
|
4
|
-
return paths.map((p) => {
|
|
5
|
-
let normalizedPath = normalize(p).replace(/\\/g, "/");
|
|
6
|
-
if (normalizedPath.startsWith("./")) {
|
|
7
|
-
normalizedPath = normalizedPath.substring(2);
|
|
8
|
-
}
|
|
9
|
-
return "/" + normalizedPath;
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
const getEntryContent = async (options) => {
|
|
13
|
-
const preset = presets.includes(options.preset ?? "hono") ? options.preset ?? "hono" : (console.warn(
|
|
14
|
-
`Invalid preset: ${options.preset}. Must be one of: ${presets.join(", ")}. Using 'hono' as default.`
|
|
15
|
-
), "hono");
|
|
16
|
-
const staticPaths = options.staticPaths ?? [""];
|
|
17
|
-
const globStr = normalizePaths(options.entry).map((e) => `'${e}'`).join(",");
|
|
18
|
-
const hooksToString = async (appName, hooks) => {
|
|
19
|
-
if (hooks) {
|
|
20
|
-
const str = (await Promise.all(
|
|
21
|
-
hooks.map((hook) => {
|
|
22
|
-
return hook(appName, {
|
|
23
|
-
staticPaths
|
|
24
|
-
});
|
|
25
|
-
})
|
|
26
|
-
)).join("\n");
|
|
27
|
-
return str;
|
|
28
|
-
}
|
|
29
|
-
return "";
|
|
30
|
-
};
|
|
31
|
-
const appStr = `const modules = import.meta.glob([${globStr}], { import: 'default', eager: true })
|
|
32
|
-
let added = false
|
|
33
|
-
for (const [, app] of Object.entries(modules)) {
|
|
34
|
-
if (app) {
|
|
35
|
-
mainApp.all('*', (c) => {
|
|
36
|
-
let executionCtx
|
|
37
|
-
try {
|
|
38
|
-
executionCtx = c.executionCtx
|
|
39
|
-
} catch {}
|
|
40
|
-
return app.fetch(c.req.raw, c.env, executionCtx)
|
|
41
|
-
})
|
|
42
|
-
mainApp.notFound((c) => {
|
|
43
|
-
let executionCtx
|
|
44
|
-
try {
|
|
45
|
-
executionCtx = c.executionCtx
|
|
46
|
-
} catch {}
|
|
47
|
-
return app.fetch(c.req.raw, c.env, executionCtx)
|
|
48
|
-
})
|
|
49
|
-
added = true
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (!added) {
|
|
53
|
-
throw new Error("Can't import modules from [${globStr}]")
|
|
54
|
-
}`;
|
|
55
|
-
const defaultExportHook = options.entryContentDefaultExportHook ?? (() => "export default mainApp");
|
|
56
|
-
return `import { Hono } from '${preset}'
|
|
57
|
-
const mainApp = new Hono()
|
|
58
|
-
|
|
59
|
-
${await hooksToString("mainApp", options.entryContentBeforeHooks)}
|
|
60
|
-
|
|
61
|
-
${appStr}
|
|
62
|
-
|
|
63
|
-
${await hooksToString("mainApp", options.entryContentAfterHooks)}
|
|
64
|
-
|
|
65
|
-
${await hooksToString("mainApp", [defaultExportHook])}`;
|
|
66
|
-
};
|
|
67
|
-
export {
|
|
68
|
-
getEntryContent
|
|
69
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const serveStaticHook = (appName, options) => {
|
|
2
|
-
let code = "";
|
|
3
|
-
for (const path of options.filePaths ?? []) {
|
|
4
|
-
code += `${appName}.use('${path}', serveStatic({ root: '${options.root ?? "./"}' }))
|
|
5
|
-
`;
|
|
6
|
-
}
|
|
7
|
-
return code;
|
|
8
|
-
};
|
|
9
|
-
export {
|
|
10
|
-
serveStaticHook
|
|
11
|
-
};
|
package/dist/index.d.ts
DELETED