nitro 3.0.260429-beta → 3.0.260522-beta
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/THIRD-PARTY-LICENSES.md.gz +0 -0
- package/dist/_build/common.mjs +119 -21
- package/dist/_build/rolldown.mjs +6 -6
- package/dist/_build/rollup.mjs +11 -11
- package/dist/_build/vite.build.mjs +3 -3
- package/dist/_build/vite.dev.mjs +149 -0
- package/dist/_build/vite.env.mjs +177 -0
- package/dist/_chunks/nitro.mjs +239 -12
- package/dist/_chunks/nitro2.mjs +117 -90
- package/dist/_chunks/utils.mjs +4 -4
- package/dist/_common.mjs +1 -1
- package/dist/_dev.d.mts +1 -1
- package/dist/_dev.mjs +5 -5
- package/dist/_libs/c12+rc9.mjs +11 -10
- package/dist/_libs/c12+readdirp+chokidar.d.mts +7 -8
- package/dist/_libs/citty.mjs +1 -1
- package/dist/_libs/common.d.mts +37 -0
- package/dist/_libs/commondir+is-reference.mjs +3 -3
- package/dist/_libs/compatx.d.mts +1 -1
- package/dist/_libs/compatx.mjs +1 -1
- package/dist/_libs/estree+pluginutils.d.mts +1 -1
- package/dist/_libs/estree-walker.mjs +1 -1
- package/dist/_libs/hasown+resolve+deepmerge.mjs +15 -15
- package/dist/_libs/httpxy.d.mts +1 -1
- package/dist/_libs/httpxy.mjs +8 -4
- package/dist/_libs/jsonc-parser+workers-utils.d.mts +1579 -0
- package/dist/_libs/klona.mjs +1 -1
- package/dist/_libs/magic-string.d.mts +1 -1
- package/dist/_libs/mlly.d.mts +1 -1
- package/dist/_libs/nypm+tinyexec.mjs +92 -99
- package/dist/_libs/openapi-types.d.mts +730 -0
- package/dist/_libs/perfect-debounce.mjs +1 -1
- package/dist/_libs/pkg-types.d.mts +1 -1
- package/dist/_libs/plugin-alias.mjs +2 -2
- package/dist/_libs/plugin-inject.mjs +3 -3
- package/dist/_libs/plugin-json.mjs +2 -2
- package/dist/_libs/pluginutils.mjs +16 -5
- package/dist/_libs/readdirp+chokidar.mjs +2 -2
- package/dist/_libs/remapping.mjs +2 -2
- package/dist/_libs/resolve-uri+gen-mapping.mjs +2 -5
- package/dist/_libs/rou3.d.mts +1 -1
- package/dist/_libs/rou3.mjs +1 -1
- package/dist/_libs/std-env.d.mts +1 -1
- package/dist/_libs/tsconfck.mjs +1 -1
- package/dist/_libs/ultrahtml.mjs +1 -1
- package/dist/_libs/{unimport+unplugin+oxc-parser.mjs → unimport+unplugin.mjs} +18 -8
- package/dist/_libs/unplugin+unimport.d.mts +3 -3
- package/dist/_libs/unwasm.d.mts +1 -1
- package/dist/_presets.mjs +117 -91
- package/dist/builder.d.mts +1 -1
- package/dist/builder.mjs +3 -3
- package/dist/cli/_chunks/build.mjs +3 -3
- package/dist/cli/_chunks/common.mjs +1 -1
- package/dist/cli/_chunks/deploy.mjs +2 -2
- package/dist/cli/_chunks/dev.mjs +4 -4
- package/dist/cli/_chunks/docs.mjs +1 -1
- package/dist/cli/_chunks/list.mjs +2 -2
- package/dist/cli/_chunks/prepare.mjs +3 -3
- package/dist/cli/_chunks/preview.mjs +4 -4
- package/dist/cli/_chunks/run.mjs +2 -2
- package/dist/cli/_chunks/task.mjs +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/docs/1.deploy/2.providers/2.aws-amplify.md +3 -3
- package/dist/docs/1.deploy/2.providers/21.vercel.md +6 -0
- package/dist/docs/3.examples/27.vite-ssr-tsr-react.md +1 -1
- package/dist/presets/vercel/runtime/queue.dev.mjs +41 -0
- package/dist/runtime/internal/app.mjs +4 -111
- package/dist/runtime/virtual/app.d.mts +4 -0
- package/dist/runtime/virtual/app.mjs +32 -0
- package/dist/types/index.d.mts +21 -1756
- package/dist/vite.mjs +23 -337
- package/package.json +37 -39
- package/dist/THIRD-PARTY-LICENSES.md +0 -1676
- package/dist/_chunks/nitro3.mjs +0 -136
- package/dist/_chunks/nitro4.mjs +0 -127
package/dist/cli/index.mjs
CHANGED
|
@@ -31,7 +31,7 @@ export default defineConfig({
|
|
|
31
31
|
// catchAllStaticFallback: true,
|
|
32
32
|
// imageOptimization: { path: "/_image", cacheControl: "public, max-age=3600, immutable" },
|
|
33
33
|
// imageSettings: { ... },
|
|
34
|
-
// runtime: "
|
|
34
|
+
// runtime: "nodejs24.x", // default: "nodejs20.x" | "nodejs22.x" | "nodejs24.x"
|
|
35
35
|
}
|
|
36
36
|
})
|
|
37
37
|
```
|
|
@@ -48,7 +48,7 @@ frontend:
|
|
|
48
48
|
phases:
|
|
49
49
|
preBuild:
|
|
50
50
|
commands:
|
|
51
|
-
- nvm use
|
|
51
|
+
- nvm use 24 && node --version
|
|
52
52
|
- corepack enable && npx --yes nypm install
|
|
53
53
|
build:
|
|
54
54
|
commands:
|
|
@@ -66,7 +66,7 @@ applications:
|
|
|
66
66
|
phases:
|
|
67
67
|
preBuild:
|
|
68
68
|
commands:
|
|
69
|
-
- nvm use
|
|
69
|
+
- nvm use 24 && node --version
|
|
70
70
|
- corepack enable && npx --yes nypm install
|
|
71
71
|
build:
|
|
72
72
|
commands:
|
|
@@ -210,6 +210,12 @@ export default defineEventHandler(async (event) => {
|
|
|
210
210
|
});
|
|
211
211
|
```
|
|
212
212
|
|
|
213
|
+
### Local development
|
|
214
|
+
|
|
215
|
+
Queues work in `nitro dev` — `send()` delivers messages straight to your `vercel:queue` hook, so you can iterate without deploying. Pull your Vercel environment first with `vercel link` and `vercel env pull` so the SDK can authenticate.
|
|
216
|
+
|
|
217
|
+
If your hook throws, the message is retried locally. Retries honour `retryAfterSeconds` from each trigger when set.
|
|
218
|
+
|
|
213
219
|
## Custom build output configuration
|
|
214
220
|
|
|
215
221
|
You can provide additional [build output configuration](https://vercel.com/docs/build-output-api/v3) using `vercel.config` key inside `nitro.config`. It will be merged with built-in auto-generated config.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { send } from "@vercel/queue";
|
|
2
|
+
import { useRuntimeConfig } from "nitro/runtime-config";
|
|
3
|
+
import { registerVercelQueueConsumer } from "env-runner/runners/vercel/queue-dev";
|
|
4
|
+
const queueDevPlugin = (nitroApp) => {
|
|
5
|
+
const triggers = useRuntimeConfig().vercel?.queues?.triggers || [];
|
|
6
|
+
if (triggers.length === 0) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const unregisters = [];
|
|
10
|
+
const ready = Promise.all(triggers.map((trigger) => registerVercelQueueConsumer({
|
|
11
|
+
topic: trigger.topic,
|
|
12
|
+
retryAfterSeconds: trigger.retryAfterSeconds,
|
|
13
|
+
handler: async (message, metadata) => {
|
|
14
|
+
try {
|
|
15
|
+
await nitroApp.hooks.callHook("vercel:queue", {
|
|
16
|
+
message,
|
|
17
|
+
metadata,
|
|
18
|
+
send
|
|
19
|
+
});
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.error("[vercel:queue]", error);
|
|
22
|
+
nitroApp.captureError?.(error, { tags: ["vercel:queue"] });
|
|
23
|
+
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}).then((unregister) => {
|
|
28
|
+
unregisters.push(unregister);
|
|
29
|
+
}))).catch((error) => {
|
|
30
|
+
console.error("[vercel:queue] failed to register dev consumer:", error);
|
|
31
|
+
});
|
|
32
|
+
nitroApp.hooks.hook("close", async () => {
|
|
33
|
+
await ready;
|
|
34
|
+
for (const unregister of unregisters) {
|
|
35
|
+
try {
|
|
36
|
+
unregister();
|
|
37
|
+
} catch {}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
export default queueDevPlugin;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toRequest } from "h3";
|
|
2
2
|
import { HookableCore } from "hookable";
|
|
3
|
-
import { nitroAsyncContext } from "./context.mjs";
|
|
4
3
|
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import { findRoute, findRouteRules, globalMiddleware, findRoutedMiddleware } from "#nitro/virtual/routing";
|
|
8
|
-
import { hasRouteRules, hasRoutedMiddleware, hasGlobalMiddleware, hasRoutes, hasHooks, hasPlugins } from "#nitro/virtual/feature-flags";
|
|
4
|
+
import { findRouteRules } from "#nitro/virtual/routing";
|
|
5
|
+
import { createNitroApp, initNitroPlugins } from "#nitro/virtual/app";
|
|
9
6
|
const APP_ID = import.meta.prerender ? "prerender" : "default";
|
|
10
7
|
export function useNitroApp() {
|
|
11
8
|
let instance = useNitroApp._instance;
|
|
@@ -15,9 +12,7 @@ export function useNitroApp() {
|
|
|
15
12
|
instance = useNitroApp._instance = createNitroApp();
|
|
16
13
|
globalThis.__nitro__ = globalThis.__nitro__ || {};
|
|
17
14
|
globalThis.__nitro__[APP_ID] = instance;
|
|
18
|
-
|
|
19
|
-
initNitroPlugins(instance);
|
|
20
|
-
}
|
|
15
|
+
initNitroPlugins(instance);
|
|
21
16
|
return instance;
|
|
22
17
|
}
|
|
23
18
|
export function useNitroHooks() {
|
|
@@ -53,108 +48,6 @@ export function fetch(resource, init, context) {
|
|
|
53
48
|
resource = resource._request || resource;
|
|
54
49
|
return globalThis.fetch(resource, init);
|
|
55
50
|
}
|
|
56
|
-
function createNitroApp() {
|
|
57
|
-
const hooks = hasHooks ? new HookableCore() : undefined;
|
|
58
|
-
const captureError = (error, errorCtx) => {
|
|
59
|
-
const promise = hasHooks && hooks.callHook("error", error, errorCtx)?.catch?.((hookError) => {
|
|
60
|
-
console.error("Error while capturing another error", hookError);
|
|
61
|
-
});
|
|
62
|
-
if (errorCtx?.event) {
|
|
63
|
-
const errors = errorCtx.event.req.context?.nitro?.errors;
|
|
64
|
-
if (errors) {
|
|
65
|
-
errors.push({
|
|
66
|
-
error,
|
|
67
|
-
context: errorCtx
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
if (hasHooks && promise && typeof errorCtx.event.req.waitUntil === "function") {
|
|
71
|
-
errorCtx.event.req.waitUntil(promise);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
const h3App = createH3App({ onError(error, event) {
|
|
76
|
-
hasHooks && captureError(error, { event });
|
|
77
|
-
return errorHandler(error, event);
|
|
78
|
-
} });
|
|
79
|
-
if (hasHooks) {
|
|
80
|
-
h3App.config.onRequest = (event) => {
|
|
81
|
-
return hooks.callHook("request", event)?.catch?.((error) => {
|
|
82
|
-
captureError(error, {
|
|
83
|
-
event,
|
|
84
|
-
tags: ["request"]
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
h3App.config.onResponse = (res, event) => {
|
|
89
|
-
return hooks.callHook("response", res, event)?.catch?.((error) => {
|
|
90
|
-
captureError(error, {
|
|
91
|
-
event,
|
|
92
|
-
tags: ["response"]
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
let appHandler = (req) => {
|
|
98
|
-
req.context ||= {};
|
|
99
|
-
req.context.nitro = req.context.nitro || { errors: [] };
|
|
100
|
-
return h3App.fetch(req);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
if (import.meta._asyncContext) {
|
|
104
|
-
const originalHandler = appHandler;
|
|
105
|
-
appHandler = (req) => {
|
|
106
|
-
const asyncCtx = { request: req };
|
|
107
|
-
return nitroAsyncContext.callAsync(asyncCtx, () => originalHandler(req));
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
const app = {
|
|
111
|
-
fetch: appHandler,
|
|
112
|
-
h3: h3App,
|
|
113
|
-
hooks,
|
|
114
|
-
captureError
|
|
115
|
-
};
|
|
116
|
-
return app;
|
|
117
|
-
}
|
|
118
|
-
function initNitroPlugins(app) {
|
|
119
|
-
for (const plugin of plugins) {
|
|
120
|
-
try {
|
|
121
|
-
plugin(app);
|
|
122
|
-
} catch (error) {
|
|
123
|
-
app.captureError?.(error, { tags: ["plugin"] });
|
|
124
|
-
throw error;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return app;
|
|
128
|
-
}
|
|
129
|
-
function createH3App(config) {
|
|
130
|
-
|
|
131
|
-
const h3App = new H3Core(config);
|
|
132
|
-
|
|
133
|
-
hasRoutes && (h3App["~findRoute"] = (event) => findRoute(event.req.method, event.url.pathname));
|
|
134
|
-
hasGlobalMiddleware && h3App["~middleware"].push(...globalMiddleware);
|
|
135
|
-
if (hasRouteRules || hasRoutedMiddleware) {
|
|
136
|
-
h3App["~getMiddleware"] = (event, route) => {
|
|
137
|
-
const needsRouting = hasRouteRules || hasRoutedMiddleware;
|
|
138
|
-
const pathname = needsRouting ? event.url.pathname : undefined;
|
|
139
|
-
const method = needsRouting ? event.req.method : undefined;
|
|
140
|
-
const middleware = [];
|
|
141
|
-
if (hasRouteRules) {
|
|
142
|
-
const routeRules = getRouteRules(method, pathname);
|
|
143
|
-
event.context.routeRules = routeRules?.routeRules;
|
|
144
|
-
if (routeRules?.routeRuleMiddleware.length) {
|
|
145
|
-
middleware.push(...routeRules.routeRuleMiddleware);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
hasGlobalMiddleware && middleware.push(...h3App["~middleware"]);
|
|
149
|
-
hasRoutedMiddleware && middleware.push(...findRoutedMiddleware(method, pathname).map((r) => r.data));
|
|
150
|
-
if (hasRoutes && route?.data?.middleware?.length) {
|
|
151
|
-
middleware.push(...route.data.middleware);
|
|
152
|
-
}
|
|
153
|
-
return middleware;
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
return h3App;
|
|
157
|
-
}
|
|
158
51
|
export function getRouteRules(method, pathname) {
|
|
159
52
|
const m = findRouteRules(method, pathname);
|
|
160
53
|
if (!m?.length) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import "./_runtime_warn.mjs";
|
|
2
|
+
import { H3Core } from "h3";
|
|
3
|
+
import errorHandler from "#nitro/virtual/error-handler";
|
|
4
|
+
export function createNitroApp() {
|
|
5
|
+
const h3App = new H3Core({ onError(error, event) {
|
|
6
|
+
return errorHandler(error, event);
|
|
7
|
+
} });
|
|
8
|
+
const captureError = (error, errorCtx) => {
|
|
9
|
+
if (errorCtx?.event) {
|
|
10
|
+
const errors = errorCtx.event.req.context?.nitro?.errors;
|
|
11
|
+
if (errors) {
|
|
12
|
+
errors.push({
|
|
13
|
+
error,
|
|
14
|
+
context: errorCtx
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
fetch: (req) => {
|
|
21
|
+
req.context ||= {};
|
|
22
|
+
req.context.nitro = req.context.nitro || { errors: [] };
|
|
23
|
+
return h3App.fetch(req);
|
|
24
|
+
},
|
|
25
|
+
h3: h3App,
|
|
26
|
+
hooks: undefined,
|
|
27
|
+
captureError
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function initNitroPlugins(app) {
|
|
31
|
+
return app;
|
|
32
|
+
}
|