nitro 3.0.260415-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 +157 -45
- 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 +241 -14
- package/dist/_chunks/nitro2.mjs +117 -90
- package/dist/_chunks/utils.mjs +4 -4
- package/dist/_common.mjs +2 -2
- package/dist/_dev.d.mts +1 -1
- package/dist/_dev.mjs +7 -6
- package/dist/_libs/c12+rc9.mjs +24 -11
- 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 +62 -49
- package/dist/_libs/httpxy.d.mts +2 -4
- package/dist/_libs/httpxy.mjs +13 -9
- 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 +137 -113
- package/dist/_libs/openapi-types.d.mts +730 -0
- package/dist/_libs/perfect-debounce.mjs +1 -1
- package/dist/_libs/pkg-types.d.mts +8 -5
- package/dist/_libs/plugin-alias.mjs +2 -2
- package/dist/_libs/plugin-inject.mjs +4 -2
- package/dist/_libs/plugin-json.mjs +2 -2
- package/dist/_libs/pluginutils.mjs +18 -5
- package/dist/_libs/readdirp+chokidar.mjs +4 -3
- 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.mjs +61 -39
- package/dist/_libs/unplugin+unimport.d.mts +4 -4
- package/dist/_libs/unwasm.d.mts +1 -1
- package/dist/_presets.mjs +118 -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/0.docs/5.cache.md +53 -9
- 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/node_modules/ufo/dist/index.mjs +2 -2
- package/dist/node_modules/ufo/package.json +9 -9
- package/dist/presets/azure/runtime/azure-swa.mjs +2 -0
- package/dist/presets/vercel/runtime/queue.dev.mjs +41 -0
- package/dist/runtime/internal/app.mjs +4 -111
- package/dist/runtime/internal/route-rules.d.mts +1 -0
- package/dist/runtime/internal/route-rules.mjs +29 -1
- package/dist/runtime/internal/routes/scalar.mjs +1 -0
- package/dist/runtime/virtual/app.d.mts +4 -0
- package/dist/runtime/virtual/app.mjs +32 -0
- package/dist/types/index.d.mts +959 -1836
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +23 -331
- package/package.json +43 -44
- package/dist/THIRD-PARTY-LICENSES.md +0 -1646
- package/dist/_chunks/nitro3.mjs +0 -136
- package/dist/_chunks/nitro4.mjs +0 -127
- package/dist/_libs/_.mjs +0 -2
- package/dist/_libs/_2.mjs +0 -2
- package/dist/_libs/_3.mjs +0 -2
- package/dist/_libs/_4.mjs +0 -2
- package/dist/_libs/_5.mjs +0 -2
- package/dist/_libs/_6.mjs +0 -2
- package/dist/_libs/_7.mjs +0 -2
- package/dist/_libs/escape-string-regexp.mjs +0 -5
package/dist/vite.d.mts
CHANGED
|
@@ -20,7 +20,7 @@ interface NitroPluginConfig extends NitroConfig {
|
|
|
20
20
|
*/
|
|
21
21
|
_nitro?: Nitro;
|
|
22
22
|
experimental?: NitroConfig["experimental"] & {
|
|
23
|
-
vite
|
|
23
|
+
vite?: {
|
|
24
24
|
/**
|
|
25
25
|
* @experimental Enable `?assets` import proposed by https://github.com/vitejs/vite/discussions/20913
|
|
26
26
|
* @default true
|
package/dist/vite.mjs
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { runtimeDependencies, runtimeDir } from "nitro/meta";
|
|
11
|
-
import { existsSync, watch } from "node:fs";
|
|
1
|
+
import { NODE_MODULES_RE, baseBuildConfig, baseBuildPlugins, basename, copyPublicAssets, dirname, getChunkName, join, libChunkName, m, prepare, prettyPath, resolve, resolveModulePath, v, writeBuildInfo } from "./_build/common.mjs";
|
|
2
|
+
import { formatCompatibilityDate } from "./_libs/compatx.mjs";
|
|
3
|
+
import { createNitro, prerender } from "./_chunks/nitro.mjs";
|
|
4
|
+
import { NitroDevApp } from "./_dev.mjs";
|
|
5
|
+
import { createNitroEnvironment, createServiceEnvironment, createServiceEnvironments, getEnvRunner, initEnvRunner, nitroServiceProxy } from "./_build/vite.env.mjs";
|
|
6
|
+
import { startPreview } from "./_chunks/nitro2.mjs";
|
|
7
|
+
import { assetsPlugin } from "./_libs/pluginutils.mjs";
|
|
8
|
+
import { runtimeDir } from "nitro/meta";
|
|
9
|
+
import { existsSync } from "node:fs";
|
|
12
10
|
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
13
|
-
import { join, resolve } from "node:path";
|
|
14
11
|
import { defu } from "defu";
|
|
15
|
-
import { withBase } from "ufo";
|
|
16
12
|
import { colors } from "consola/utils";
|
|
17
|
-
import { RunnerManager, loadRunner } from "env-runner";
|
|
18
|
-
import { NodeRequest, sendNodeResponse } from "srvx/node";
|
|
19
|
-
import "node:http";
|
|
20
|
-
import { DevEnvironment } from "vite";
|
|
21
|
-
import { createViteHotChannel } from "env-runner/vite";
|
|
22
13
|
const getBundlerConfig = async (ctx) => {
|
|
23
14
|
const nitro = ctx.nitro;
|
|
24
15
|
const base = baseBuildConfig(nitro);
|
|
@@ -56,8 +47,8 @@ const getBundlerConfig = async (ctx) => {
|
|
|
56
47
|
rolldownConfig
|
|
57
48
|
};
|
|
58
49
|
} else {
|
|
59
|
-
const inject = (await import("./_libs/
|
|
60
|
-
const alias = (await import("./_libs/plugin-alias.mjs").then((n) => n.
|
|
50
|
+
const inject = (await import("./_libs/plugin-inject.mjs").then((n) => n.es_exports)).default;
|
|
51
|
+
const alias = (await import("./_libs/plugin-alias.mjs").then((n) => n.dist_exports)).default;
|
|
61
52
|
const rollupConfig = defu({
|
|
62
53
|
plugins: [inject(base.env.inject), alias({ entries: base.aliases })],
|
|
63
54
|
output: {
|
|
@@ -100,12 +91,12 @@ async function buildEnvironments(ctx, builder) {
|
|
|
100
91
|
const nitroOptions = ctx.nitro.options;
|
|
101
92
|
const clientInput = builder.environments.client?.config?.build?.rollupOptions?.input;
|
|
102
93
|
if (nitroOptions.renderer?.template && nitroOptions.renderer?.template === clientInput) {
|
|
103
|
-
const outputPath = resolve
|
|
94
|
+
const outputPath = resolve(nitroOptions.output.publicDir, basename(clientInput));
|
|
104
95
|
if (existsSync(outputPath)) {
|
|
105
96
|
const html = await readFile(outputPath, "utf8").then((r) => r.replace("<!--ssr-outlet-->", `{{{ globalThis.__nitro_vite_envs__?.["ssr"]?.fetch($REQUEST) || "" }}}`));
|
|
106
97
|
await rm(outputPath);
|
|
107
|
-
const tmp = resolve
|
|
108
|
-
await mkdir(dirname
|
|
98
|
+
const tmp = resolve(nitroOptions.buildDir, "vite/index.html");
|
|
99
|
+
await mkdir(dirname(tmp), { recursive: true });
|
|
109
100
|
await writeFile(tmp, html, "utf8");
|
|
110
101
|
nitroOptions.renderer.template = tmp;
|
|
111
102
|
}
|
|
@@ -117,7 +108,7 @@ async function buildEnvironments(ctx, builder) {
|
|
|
117
108
|
await copyPublicAssets(nitro);
|
|
118
109
|
const assetDirs = new Set(Object.values(builder.environments).filter((env) => env.config.consumer === "client").map((env) => env.config.build.assetsDir).filter(Boolean));
|
|
119
110
|
for (const assetsDir of assetDirs) {
|
|
120
|
-
if (!existsSync(resolve
|
|
111
|
+
if (!existsSync(resolve(nitro.options.output.publicDir, assetsDir))) continue;
|
|
121
112
|
const rule = ctx.nitro.options.routeRules[`/${assetsDir}/**`] ??= {};
|
|
122
113
|
if (!rule.headers?.["cache-control"]) rule.headers = {
|
|
123
114
|
...rule.headers,
|
|
@@ -151,313 +142,13 @@ function lazyService(loader) {
|
|
|
151
142
|
|
|
152
143
|
const services = {
|
|
153
144
|
${Object.keys(ctx.services).map((name) => {
|
|
154
|
-
return [name, resolve
|
|
145
|
+
return [name, resolve(ctx.nitro.options.buildDir, "vite/services", name, ctx._entryPoints[name])];
|
|
155
146
|
}).map(([name, entry]) => `[${JSON.stringify(name)}]: lazyService(() => import(${JSON.stringify(entry)}))`).join(",\n")}
|
|
156
147
|
};
|
|
157
148
|
|
|
158
149
|
globalThis.__nitro_vite_envs__ = services;
|
|
159
150
|
`;
|
|
160
151
|
}
|
|
161
|
-
function createFetchableDevEnvironment(name, config, devServer, entry, opts) {
|
|
162
|
-
return new FetchableDevEnvironment(name, config, {
|
|
163
|
-
hot: true,
|
|
164
|
-
transport: createViteHotChannel(devServer, name)
|
|
165
|
-
}, devServer, entry, opts);
|
|
166
|
-
}
|
|
167
|
-
var FetchableDevEnvironment = class extends DevEnvironment {
|
|
168
|
-
devServer;
|
|
169
|
-
#entry;
|
|
170
|
-
#preventExternalize;
|
|
171
|
-
constructor(name, config, context, devServer, entry, opts) {
|
|
172
|
-
super(name, config, context);
|
|
173
|
-
this.devServer = devServer;
|
|
174
|
-
this.#entry = entry;
|
|
175
|
-
this.#preventExternalize = opts?.preventExternalize ?? false;
|
|
176
|
-
}
|
|
177
|
-
async fetchModule(id, importer, options) {
|
|
178
|
-
if (this.#preventExternalize && !id.startsWith("file://") && importer && id[0] !== "." && id[0] !== "/") {
|
|
179
|
-
const resolved = await this.pluginContainer.resolveId(id, importer);
|
|
180
|
-
if (resolved && !resolved.external) return super.fetchModule(resolved.id, importer, options);
|
|
181
|
-
}
|
|
182
|
-
return super.fetchModule(id, importer, options);
|
|
183
|
-
}
|
|
184
|
-
async dispatchFetch(request) {
|
|
185
|
-
return this.devServer.fetch(request);
|
|
186
|
-
}
|
|
187
|
-
async init(...args) {
|
|
188
|
-
await this.devServer.init?.();
|
|
189
|
-
await super.init(...args);
|
|
190
|
-
this.devServer.sendMessage({
|
|
191
|
-
type: "custom",
|
|
192
|
-
event: "nitro:vite-env",
|
|
193
|
-
data: {
|
|
194
|
-
name: this.name,
|
|
195
|
-
entry: this.#entry
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
async function configureViteDevServer(ctx, server) {
|
|
201
|
-
const nitro = ctx.nitro;
|
|
202
|
-
const nitroEnv = server.environments.nitro;
|
|
203
|
-
const nitroConfigFile = nitro.options._c12.configFile;
|
|
204
|
-
if (nitroConfigFile) server.config.configFileDependencies.push(nitroConfigFile);
|
|
205
|
-
if (nitro.options.features.websocket ?? nitro.options.experimental.websocket) server.httpServer.on("upgrade", (req, socket, head) => {
|
|
206
|
-
if (req.headers["sec-websocket-protocol"]?.startsWith("vite-")) return;
|
|
207
|
-
getEnvRunner(ctx).upgrade?.({ node: {
|
|
208
|
-
req,
|
|
209
|
-
socket,
|
|
210
|
-
head
|
|
211
|
-
} });
|
|
212
|
-
});
|
|
213
|
-
const reload = debounce(async () => {
|
|
214
|
-
await scanHandlers(nitro);
|
|
215
|
-
nitro.routing.sync();
|
|
216
|
-
nitroEnv.moduleGraph.invalidateAll();
|
|
217
|
-
nitroEnv.hot.send({ type: "full-reload" });
|
|
218
|
-
});
|
|
219
|
-
const scanDirs = nitro.options.scanDirs.flatMap((dir) => [
|
|
220
|
-
join$1(dir, nitro.options.apiDir || "api"),
|
|
221
|
-
join$1(dir, nitro.options.routesDir || "routes"),
|
|
222
|
-
join$1(dir, "middleware"),
|
|
223
|
-
join$1(dir, "plugins"),
|
|
224
|
-
join$1(dir, "modules")
|
|
225
|
-
]);
|
|
226
|
-
const watchReloadEvents = new Set([
|
|
227
|
-
"add",
|
|
228
|
-
"addDir",
|
|
229
|
-
"unlink",
|
|
230
|
-
"unlinkDir"
|
|
231
|
-
]);
|
|
232
|
-
const scanDirsWatcher = watch$1(scanDirs, { ignoreInitial: true }).on("all", (event, path, stat) => {
|
|
233
|
-
if (watchReloadEvents.has(event)) reload();
|
|
234
|
-
});
|
|
235
|
-
const rootDirWatcher = watch(nitro.options.rootDir, { persistent: false }, (_event, filename) => {
|
|
236
|
-
if (filename && /^server\.[mc]?[jt]sx?$/.test(filename)) reload();
|
|
237
|
-
});
|
|
238
|
-
nitro.hooks.hook("close", () => {
|
|
239
|
-
scanDirsWatcher.close();
|
|
240
|
-
rootDirWatcher.close();
|
|
241
|
-
});
|
|
242
|
-
nitroEnv.devServer.onMessage(async (message) => {
|
|
243
|
-
if (message?.__rpc === "transformHTML") try {
|
|
244
|
-
const html = (await server.transformIndexHtml("/", message.data)).replace("<!--ssr-outlet-->", `{{{ globalThis.__nitro_vite_envs__?.["ssr"]?.fetch($REQUEST) || "" }}}`);
|
|
245
|
-
nitroEnv.devServer.sendMessage({
|
|
246
|
-
__rpc_id: message.__rpc_id,
|
|
247
|
-
data: html
|
|
248
|
-
});
|
|
249
|
-
} catch (error) {
|
|
250
|
-
nitroEnv.devServer.sendMessage({
|
|
251
|
-
__rpc_id: message.__rpc_id,
|
|
252
|
-
error: error instanceof Error ? error.message : String(error)
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
const nitroDevMiddleware = async (nodeReq, nodeRes, next) => {
|
|
257
|
-
if (!nodeReq.url || /^\/@(?:vite|fs|id)\//.test(nodeReq.url) || nodeReq._nitroHandled || server.middlewares.stack.map((mw) => mw.route).some((base) => base && nodeReq.url.startsWith(base))) return next();
|
|
258
|
-
nodeReq._nitroHandled = true;
|
|
259
|
-
const baseURL = nitro.options.baseURL || "/";
|
|
260
|
-
const originalURL = nodeReq.url;
|
|
261
|
-
if (baseURL !== "/") nodeReq.url = withBase(nodeReq.url, baseURL);
|
|
262
|
-
try {
|
|
263
|
-
const req = new NodeRequest({
|
|
264
|
-
req: nodeReq,
|
|
265
|
-
res: nodeRes
|
|
266
|
-
});
|
|
267
|
-
const devAppRes = await ctx.devApp.fetch(req);
|
|
268
|
-
if (nodeRes.writableEnded || nodeRes.headersSent) return;
|
|
269
|
-
if (devAppRes.status !== 404) return await sendNodeResponse(nodeRes, devAppRes);
|
|
270
|
-
const envRes = await nitroEnv.dispatchFetch(req);
|
|
271
|
-
if (nodeRes.writableEnded || nodeRes.headersSent) return;
|
|
272
|
-
return await sendNodeResponse(nodeRes, envRes);
|
|
273
|
-
} catch (error) {
|
|
274
|
-
return next(error);
|
|
275
|
-
} finally {
|
|
276
|
-
if (baseURL !== "/") nodeReq.url = originalURL;
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
server.middlewares.use(function nitroDevMiddlewarePre(req, res, next) {
|
|
280
|
-
const fetchDest = req.headers["sec-fetch-dest"];
|
|
281
|
-
const ext = req.url.match(/\.([a-z0-9]+)(?:[?#]|$)/i)?.[1];
|
|
282
|
-
const isNitroRoute = ext ? !!nitro.routing.routes.match(req.method || "", new URL(withBase(req.url, nitro.options.baseURL), "http://localhost").pathname) : false;
|
|
283
|
-
res.setHeader("vary", "sec-fetch-dest");
|
|
284
|
-
if ((!fetchDest || /^(document|iframe|frame|empty)$/.test(fetchDest)) && (!ext || isNitroRoute) && !/^\/(?:__|@)/.test(req.url)) nitroDevMiddleware(req, res, next);
|
|
285
|
-
else next();
|
|
286
|
-
});
|
|
287
|
-
return () => {
|
|
288
|
-
server.middlewares.use(nitroDevMiddleware);
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
function createNitroEnvironment(ctx) {
|
|
292
|
-
const isWorkerdRunner = _isWorkerdRunner(ctx);
|
|
293
|
-
return {
|
|
294
|
-
consumer: "server",
|
|
295
|
-
build: {
|
|
296
|
-
rollupOptions: ctx.bundlerConfig.rollupConfig,
|
|
297
|
-
rolldownOptions: ctx.bundlerConfig.rolldownConfig,
|
|
298
|
-
minify: ctx.nitro.options.minify,
|
|
299
|
-
emptyOutDir: false,
|
|
300
|
-
sourcemap: ctx.nitro.options.sourcemap,
|
|
301
|
-
commonjsOptions: ctx.nitro.options.commonJS,
|
|
302
|
-
copyPublicDir: false
|
|
303
|
-
},
|
|
304
|
-
resolve: {
|
|
305
|
-
noExternal: ctx.nitro.options.dev ? isWorkerdRunner ? true : [
|
|
306
|
-
/^nitro$/,
|
|
307
|
-
new RegExp(`^(${runtimeDependencies.join("|")})$`),
|
|
308
|
-
...ctx.bundlerConfig.base.noExternal
|
|
309
|
-
] : true,
|
|
310
|
-
conditions: isWorkerdRunner ? [
|
|
311
|
-
"workerd",
|
|
312
|
-
"worker",
|
|
313
|
-
...ctx.nitro.options.exportConditions.filter((c) => c !== "node")
|
|
314
|
-
] : ctx.nitro.options.exportConditions,
|
|
315
|
-
externalConditions: ctx.nitro.options.exportConditions?.filter((c) => !/browser|wasm|module/.test(c))
|
|
316
|
-
},
|
|
317
|
-
define: { "process.env.NODE_ENV": JSON.stringify(ctx.nitro.options.dev ? "development" : "production") },
|
|
318
|
-
dev: { createEnvironment: (envName, envConfig) => {
|
|
319
|
-
const entry = resolve(runtimeDir, "internal/vite/dev-entry.mjs");
|
|
320
|
-
const env = createFetchableDevEnvironment(envName, envConfig, getEnvRunner(ctx), entry, { preventExternalize: isWorkerdRunner });
|
|
321
|
-
ctx._transformRequest = (id) => env.transformRequest(id);
|
|
322
|
-
(ctx._viteEnvs ??= /* @__PURE__ */ new Map()).set(envName, entry);
|
|
323
|
-
return env;
|
|
324
|
-
} }
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
function createServiceEnvironment(ctx, name, serviceConfig) {
|
|
328
|
-
const isWorkerdRunner = _isWorkerdRunner(ctx);
|
|
329
|
-
return {
|
|
330
|
-
consumer: "server",
|
|
331
|
-
build: {
|
|
332
|
-
rollupOptions: {
|
|
333
|
-
input: { index: serviceConfig.entry },
|
|
334
|
-
external: [/^nitro(\/|$)/]
|
|
335
|
-
},
|
|
336
|
-
minify: ctx.nitro.options.minify,
|
|
337
|
-
sourcemap: ctx.nitro.options.sourcemap,
|
|
338
|
-
outDir: join(ctx.nitro.options.buildDir, "vite/services", name),
|
|
339
|
-
emptyOutDir: true,
|
|
340
|
-
copyPublicDir: false
|
|
341
|
-
},
|
|
342
|
-
resolve: {
|
|
343
|
-
...isWorkerdRunner ? { noExternal: true } : {},
|
|
344
|
-
conditions: isWorkerdRunner ? [
|
|
345
|
-
"workerd",
|
|
346
|
-
"worker",
|
|
347
|
-
...ctx.nitro.options.exportConditions.filter((c) => c !== "node")
|
|
348
|
-
] : ctx.nitro.options.exportConditions,
|
|
349
|
-
externalConditions: ctx.nitro.options.exportConditions?.filter((c) => !/browser|wasm|module/.test(c))
|
|
350
|
-
},
|
|
351
|
-
dev: { createEnvironment: (envName, envConfig) => {
|
|
352
|
-
const entry = tryResolve(serviceConfig.entry);
|
|
353
|
-
(ctx._viteEnvs ??= /* @__PURE__ */ new Map()).set(envName, entry);
|
|
354
|
-
return createFetchableDevEnvironment(envName, envConfig, getEnvRunner(ctx), entry, { preventExternalize: isWorkerdRunner });
|
|
355
|
-
} }
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
function createServiceEnvironments(ctx) {
|
|
359
|
-
return Object.fromEntries(Object.entries(ctx.services).map(([name, config]) => [name, createServiceEnvironment(ctx, name, config)]));
|
|
360
|
-
}
|
|
361
|
-
async function initEnvRunner(ctx) {
|
|
362
|
-
if (ctx._envRunner) return ctx._envRunner;
|
|
363
|
-
if (!ctx._initPromise) ctx._initPromise = (async () => {
|
|
364
|
-
const manager = new RunnerManager();
|
|
365
|
-
let _retries = 0;
|
|
366
|
-
manager.onClose((_runner, cause) => {
|
|
367
|
-
if (_retries++ < 3) {
|
|
368
|
-
ctx.nitro.logger.info("Restarting env runner...", cause ? `Cause: ${cause}` : "");
|
|
369
|
-
_loadRunner(ctx, manager);
|
|
370
|
-
} else ctx.nitro.logger.error("Env runner failed after 3 retries.", cause ? `Last cause: ${cause}` : "");
|
|
371
|
-
});
|
|
372
|
-
manager.onReady(() => {
|
|
373
|
-
_retries = 0;
|
|
374
|
-
if (ctx._viteEnvs) for (const [name, entry] of ctx._viteEnvs) manager.sendMessage({
|
|
375
|
-
type: "custom",
|
|
376
|
-
event: "nitro:vite-env",
|
|
377
|
-
data: {
|
|
378
|
-
name,
|
|
379
|
-
entry
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
});
|
|
383
|
-
await _loadRunner(ctx, manager);
|
|
384
|
-
ctx._envRunner = manager;
|
|
385
|
-
return manager;
|
|
386
|
-
})();
|
|
387
|
-
return await ctx._initPromise;
|
|
388
|
-
}
|
|
389
|
-
function getEnvRunner(ctx) {
|
|
390
|
-
if (!ctx._envRunner) throw new Error("Env runner not initialized. Call initEnvRunner() first.");
|
|
391
|
-
return ctx._envRunner;
|
|
392
|
-
}
|
|
393
|
-
async function _loadRunner(ctx, manager) {
|
|
394
|
-
const runnerName = ctx.nitro.options.devServer.runner || process.env.NITRO_DEV_RUNNER || "node-worker";
|
|
395
|
-
const entry = resolve(runtimeDir, "internal/vite/dev-worker.mjs");
|
|
396
|
-
let runner;
|
|
397
|
-
if (runnerName === "miniflare") {
|
|
398
|
-
const { MiniflareEnvRunner } = await import("env-runner/runners/miniflare");
|
|
399
|
-
runner = new MiniflareEnvRunner({
|
|
400
|
-
name: "nitro-vite",
|
|
401
|
-
data: { entry }
|
|
402
|
-
});
|
|
403
|
-
} else runner = await loadRunner(runnerName, {
|
|
404
|
-
name: "nitro-vite",
|
|
405
|
-
data: { entry }
|
|
406
|
-
});
|
|
407
|
-
await manager.reload(runner);
|
|
408
|
-
}
|
|
409
|
-
const NITRO_PROXY_PREFIX = "\0nitro-env-proxy:";
|
|
410
|
-
function nitroServiceProxy() {
|
|
411
|
-
return {
|
|
412
|
-
name: "nitro:service-proxy",
|
|
413
|
-
enforce: "pre",
|
|
414
|
-
applyToEnvironment: (env) => env.name !== "nitro" && env.config.consumer === "server",
|
|
415
|
-
apply: (_config, configEnv) => configEnv.command === "serve",
|
|
416
|
-
resolveId: {
|
|
417
|
-
filter: { id: /^nitro(\/|$)/ },
|
|
418
|
-
handler(id) {
|
|
419
|
-
if (id === "nitro" || id.startsWith("nitro/")) return {
|
|
420
|
-
id: NITRO_PROXY_PREFIX + id,
|
|
421
|
-
moduleSideEffects: false
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
},
|
|
425
|
-
load: {
|
|
426
|
-
filter: { id: /^\0nitro-env-proxy:/ },
|
|
427
|
-
handler(id) {
|
|
428
|
-
if (!id.startsWith(NITRO_PROXY_PREFIX)) return;
|
|
429
|
-
const originalId = id.slice(17);
|
|
430
|
-
return {
|
|
431
|
-
code: [
|
|
432
|
-
`const _mod = await globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__("nitro", ${JSON.stringify(originalId)});`,
|
|
433
|
-
`__vite_ssr_exportAll__(_mod);`,
|
|
434
|
-
`export default _mod.default;`
|
|
435
|
-
].join("\n"),
|
|
436
|
-
map: null
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
function _isWorkerdRunner(ctx) {
|
|
443
|
-
return (ctx.nitro.options.devServer.runner || process.env.NITRO_DEV_RUNNER || "node-worker") === "miniflare";
|
|
444
|
-
}
|
|
445
|
-
function tryResolve(id) {
|
|
446
|
-
if (/^[~#/\0]/.test(id) || isAbsolute$1(id)) return id;
|
|
447
|
-
return resolveModulePath(id, {
|
|
448
|
-
suffixes: ["", "/index"],
|
|
449
|
-
extensions: [
|
|
450
|
-
"",
|
|
451
|
-
".ts",
|
|
452
|
-
".mjs",
|
|
453
|
-
".cjs",
|
|
454
|
-
".js",
|
|
455
|
-
".mts",
|
|
456
|
-
".cts"
|
|
457
|
-
],
|
|
458
|
-
try: true
|
|
459
|
-
}) || id;
|
|
460
|
-
}
|
|
461
152
|
function nitroPreviewPlugin(ctx) {
|
|
462
153
|
return {
|
|
463
154
|
name: "nitro:preview",
|
|
@@ -573,7 +264,7 @@ function nitroEnv(ctx) {
|
|
|
573
264
|
configResolved() {
|
|
574
265
|
if (!ctx.nitro.options.renderer?.handler && !ctx.nitro.options.renderer?.template && ctx.services.ssr?.entry) {
|
|
575
266
|
ctx.nitro.options.renderer ??= {};
|
|
576
|
-
ctx.nitro.options.renderer.handler = resolve
|
|
267
|
+
ctx.nitro.options.renderer.handler = resolve(runtimeDir, "internal/vite/ssr-renderer");
|
|
577
268
|
ctx.nitro.routing.sync();
|
|
578
269
|
}
|
|
579
270
|
}
|
|
@@ -609,9 +300,9 @@ function nitroMain(ctx) {
|
|
|
609
300
|
debug("[main] Generating manifest and entry points for environment:", environment.name);
|
|
610
301
|
const isRegisteredService = Object.keys(ctx.services).includes(environment.name);
|
|
611
302
|
let entryFile;
|
|
612
|
-
const serviceEntry = isRegisteredService && ctx.services[environment.name]?.entry ? resolve
|
|
303
|
+
const serviceEntry = isRegisteredService && ctx.services[environment.name]?.entry ? resolve(ctx.services[environment.name].entry) : void 0;
|
|
613
304
|
for (const [_name, file] of Object.entries(bundle)) if (file.type === "chunk" && isRegisteredService && file.isEntry) {
|
|
614
|
-
if (serviceEntry && file.facadeModuleId && resolve
|
|
305
|
+
if (serviceEntry && file.facadeModuleId && resolve(file.facadeModuleId) === serviceEntry) {
|
|
615
306
|
entryFile = file.fileName;
|
|
616
307
|
break;
|
|
617
308
|
}
|
|
@@ -622,8 +313,9 @@ function nitroMain(ctx) {
|
|
|
622
313
|
ctx._entryPoints[this.environment.name] = entryFile;
|
|
623
314
|
}
|
|
624
315
|
} },
|
|
625
|
-
configureServer: (server) => {
|
|
316
|
+
configureServer: async (server) => {
|
|
626
317
|
debug("[main] Configuring dev server");
|
|
318
|
+
const { configureViteDevServer } = await import("./_build/vite.dev.mjs");
|
|
627
319
|
return configureViteDevServer(ctx, server);
|
|
628
320
|
},
|
|
629
321
|
async hotUpdate({ server, modules, timestamp }) {
|
|
@@ -713,7 +405,7 @@ async function setupNitroContext(ctx, configEnv, userConfig) {
|
|
|
713
405
|
"app",
|
|
714
406
|
"src",
|
|
715
407
|
""
|
|
716
|
-
].flatMap((d) => [ctx.nitro.options.rootDir, ...ctx.nitro.options.scanDirs].map((s) => join
|
|
408
|
+
].flatMap((d) => [ctx.nitro.options.rootDir, ...ctx.nitro.options.scanDirs].map((s) => join(s, d) + "/")),
|
|
717
409
|
extensions: DEFAULT_EXTENSIONS,
|
|
718
410
|
try: true
|
|
719
411
|
});
|
|
@@ -737,7 +429,7 @@ async function setupNitroContext(ctx, configEnv, userConfig) {
|
|
|
737
429
|
ctx.nitro.logger.warn(`Nitro server entry and Vite SSR both set to ${prettyPath(ctx.services.ssr.entry)}. Use a separate SSR entry (e.g. \`src/server.ts\`).`);
|
|
738
430
|
ctx.nitro.options.serverEntry = false;
|
|
739
431
|
}
|
|
740
|
-
const publicDistDir = ctx._publicDistDir = userConfig.build?.outDir || resolve
|
|
432
|
+
const publicDistDir = ctx._publicDistDir = userConfig.build?.outDir || resolve(ctx.nitro.options.buildDir, "vite/public");
|
|
741
433
|
ctx.nitro.options.publicAssets.push({
|
|
742
434
|
dir: publicDistDir,
|
|
743
435
|
maxAge: 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.260522-beta",
|
|
4
4
|
"description": "Build and Deploy Universal JavaScript Servers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api-routes",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"gen-node-compat": "node scripts/gen-node-compat.ts",
|
|
59
59
|
"gen-presets": "obuild --stub && node ./scripts/gen-presets.ts",
|
|
60
60
|
"lint": "oxlint . && oxfmt --check .",
|
|
61
|
-
"
|
|
61
|
+
"fmt": "automd && oxlint --fix . && oxfmt .",
|
|
62
62
|
"nitro": "node ./src/cli/index.ts",
|
|
63
|
-
"release": "node ./scripts/release.
|
|
63
|
+
"release": "node ./scripts/release.ts",
|
|
64
64
|
"stub": "obuild --stub",
|
|
65
65
|
"test": "pnpm lint && pnpm build && pnpm typecheck && pnpm test:rollup && pnpm test:rolldown",
|
|
66
66
|
"test:rolldown": "NITRO_BUILDER=rolldown pnpm vitest",
|
|
@@ -71,46 +71,49 @@
|
|
|
71
71
|
"consola": "^3.4.2",
|
|
72
72
|
"crossws": "^0.4.5",
|
|
73
73
|
"db0": "^0.3.4",
|
|
74
|
-
"env-runner": "^0.1.
|
|
75
|
-
"h3": "^2.0.1-rc.
|
|
74
|
+
"env-runner": "^0.1.9",
|
|
75
|
+
"h3": "^2.0.1-rc.22",
|
|
76
76
|
"hookable": "^6.1.1",
|
|
77
|
-
"nf3": "^0.3.
|
|
77
|
+
"nf3": "^0.3.17",
|
|
78
78
|
"ocache": "^0.1.4",
|
|
79
79
|
"ofetch": "^2.0.0-alpha.3",
|
|
80
80
|
"ohash": "^2.0.11",
|
|
81
|
-
"rolldown": "^1.0.
|
|
81
|
+
"rolldown": "^1.0.2",
|
|
82
82
|
"srvx": "^0.11.15",
|
|
83
83
|
"unenv": "^2.0.0-rc.24",
|
|
84
84
|
"unstorage": "^2.0.0-alpha.7"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
+
"@apphosting/common": "^0.0.9",
|
|
87
88
|
"@azure/functions": "^3.5.1",
|
|
88
|
-
"@azure/static-web-apps-cli": "^2.0.
|
|
89
|
-
"@cloudflare/workers-types": "^4.
|
|
89
|
+
"@azure/static-web-apps-cli": "^2.0.9",
|
|
90
|
+
"@cloudflare/workers-types": "^4.20260521.1",
|
|
91
|
+
"@cloudflare/workers-utils": "^0.21.0",
|
|
90
92
|
"@deno/types": "^0.0.1",
|
|
91
93
|
"@hiogawa/vite-plugin-fullstack": "^0.0.11",
|
|
92
|
-
"@netlify/edge-functions": "^3.0.
|
|
93
|
-
"@netlify/functions": "^5.2.
|
|
94
|
+
"@netlify/edge-functions": "^3.0.7",
|
|
95
|
+
"@netlify/functions": "^5.2.2",
|
|
94
96
|
"@rollup/plugin-alias": "^6.0.0",
|
|
95
97
|
"@rollup/plugin-commonjs": "^29.0.2",
|
|
96
98
|
"@rollup/plugin-inject": "^5.0.5",
|
|
97
99
|
"@rollup/plugin-json": "^6.1.0",
|
|
98
100
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
99
101
|
"@rollup/plugin-replace": "^6.0.3",
|
|
100
|
-
"@scalar/api-reference": "^1.
|
|
102
|
+
"@scalar/api-reference": "^1.57.2",
|
|
103
|
+
"@scalar/openapi-types": "^0.8.0",
|
|
101
104
|
"@types/aws-lambda": "^8.10.161",
|
|
102
|
-
"@types/estree": "^1.0.
|
|
105
|
+
"@types/estree": "^1.0.9",
|
|
103
106
|
"@types/etag": "^1.8.4",
|
|
104
107
|
"@types/http-proxy": "^1.17.17",
|
|
105
|
-
"@types/node": "^25.
|
|
108
|
+
"@types/node": "^25.9.1",
|
|
106
109
|
"@types/node-fetch": "^2.6.13",
|
|
107
110
|
"@types/semver": "^7.7.1",
|
|
108
111
|
"@types/xml2js": "^0.4.14",
|
|
109
|
-
"@typescript/native-preview": "
|
|
110
|
-
"@vercel/queue": "^0.
|
|
111
|
-
"@vitest/coverage-v8": "^4.1.
|
|
112
|
+
"@typescript/native-preview": "7.0.0-dev.20260521.1",
|
|
113
|
+
"@vercel/queue": "^0.2.0",
|
|
114
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
112
115
|
"automd": "^0.4.3",
|
|
113
|
-
"c12": "^4.0.0-beta.
|
|
116
|
+
"c12": "^4.0.0-beta.5",
|
|
114
117
|
"changelogen": "^0.6.2",
|
|
115
118
|
"chokidar": "^5.0.0",
|
|
116
119
|
"citty": "^0.2.2",
|
|
@@ -122,7 +125,6 @@
|
|
|
122
125
|
"destr": "^2.0.5",
|
|
123
126
|
"dot-prop": "^10.1.0",
|
|
124
127
|
"edge-runtime": "^4.0.1",
|
|
125
|
-
"escape-string-regexp": "^5.0.0",
|
|
126
128
|
"etag": "^1.8.1",
|
|
127
129
|
"execa": "^9.6.1",
|
|
128
130
|
"expect-type": "^1.3.0",
|
|
@@ -130,56 +132,57 @@
|
|
|
130
132
|
"get-port-please": "^3.2.0",
|
|
131
133
|
"giget": "^3.2.0",
|
|
132
134
|
"gzip-size": "^7.0.0",
|
|
133
|
-
"httpxy": "^0.5.
|
|
135
|
+
"httpxy": "^0.5.3",
|
|
134
136
|
"klona": "^2.0.6",
|
|
135
137
|
"knitwork": "^1.3.0",
|
|
136
138
|
"magic-string": "^0.30.21",
|
|
137
139
|
"mdzilla": "^0.2.1",
|
|
138
140
|
"mime": "^4.1.0",
|
|
139
|
-
"miniflare": "^4.
|
|
141
|
+
"miniflare": "^4.20260520.0",
|
|
140
142
|
"mlly": "^1.8.2",
|
|
141
|
-
"nypm": "^0.6.
|
|
142
|
-
"obuild": "^0.4.
|
|
143
|
-
"
|
|
144
|
-
"
|
|
143
|
+
"nypm": "^0.6.6",
|
|
144
|
+
"obuild": "^0.4.36",
|
|
145
|
+
"oxc-parser": "link:shims/oxc-parser",
|
|
146
|
+
"oxfmt": "^0.51.0",
|
|
147
|
+
"oxlint": "^1.66.0",
|
|
145
148
|
"pathe": "^2.0.3",
|
|
146
149
|
"perfect-debounce": "^2.1.0",
|
|
147
|
-
"pkg-types": "^2.3.
|
|
150
|
+
"pkg-types": "^2.3.1",
|
|
148
151
|
"pretty-bytes": "^7.1.0",
|
|
149
|
-
"react": "^19.2.
|
|
152
|
+
"react": "^19.2.6",
|
|
150
153
|
"rendu": "^0.1.0",
|
|
151
|
-
"rollup": "^4.60.
|
|
154
|
+
"rollup": "^4.60.4",
|
|
152
155
|
"rou3": "^0.8.1",
|
|
153
156
|
"scule": "^1.3.0",
|
|
154
|
-
"semver": "^7.
|
|
157
|
+
"semver": "^7.8.0",
|
|
155
158
|
"serve-placeholder": "^2.0.2",
|
|
156
159
|
"source-map": "^0.7.6",
|
|
157
160
|
"std-env": "^4.1.0",
|
|
158
161
|
"tinyglobby": "^0.2.16",
|
|
159
162
|
"tsconfck": "^3.1.6",
|
|
160
|
-
"typescript": "^6.0.
|
|
161
|
-
"ufo": "^1.6.
|
|
163
|
+
"typescript": "^6.0.3",
|
|
164
|
+
"ufo": "^1.6.4",
|
|
162
165
|
"ultrahtml": "^1.6.0",
|
|
163
166
|
"uncrypto": "^0.1.3",
|
|
164
167
|
"unctx": "^2.5.0",
|
|
165
|
-
"unimport": "^6.
|
|
168
|
+
"unimport": "^6.3.0",
|
|
166
169
|
"untyped": "^2.0.0",
|
|
167
170
|
"unwasm": "^0.5.3",
|
|
168
|
-
"vite": "^8.0.
|
|
171
|
+
"vite": "^8.0.14",
|
|
169
172
|
"vite7": "npm:vite@^7.3.2",
|
|
170
|
-
"vitest": "^4.1.
|
|
171
|
-
"wrangler": "^4.
|
|
173
|
+
"vitest": "^4.1.7",
|
|
174
|
+
"wrangler": "^4.93.1",
|
|
172
175
|
"xml2js": "^0.6.2",
|
|
173
176
|
"youch": "^4.1.1",
|
|
174
177
|
"youch-core": "^0.3.3",
|
|
175
|
-
"zephyr-agent": "^1.
|
|
178
|
+
"zephyr-agent": "^1.1.1"
|
|
176
179
|
},
|
|
177
180
|
"peerDependencies": {
|
|
178
|
-
"@vercel/queue": "^0.
|
|
181
|
+
"@vercel/queue": "^0.2.0",
|
|
179
182
|
"dotenv": "*",
|
|
180
183
|
"giget": "*",
|
|
181
184
|
"jiti": "^2.6.1",
|
|
182
|
-
"rollup": "^4.60.
|
|
185
|
+
"rollup": "^4.60.3",
|
|
183
186
|
"vite": "^7 || ^8",
|
|
184
187
|
"xml2js": "^0.6.2",
|
|
185
188
|
"zephyr-agent": "^0.2.0"
|
|
@@ -210,14 +213,10 @@
|
|
|
210
213
|
"optional": true
|
|
211
214
|
}
|
|
212
215
|
},
|
|
213
|
-
"resolutions": {
|
|
214
|
-
"cookie-es": "^3.1.1",
|
|
215
|
-
"nitro": "link:."
|
|
216
|
-
},
|
|
217
216
|
"engines": {
|
|
218
217
|
"node": "^20.19.0 || >=22.12.0"
|
|
219
218
|
},
|
|
220
|
-
"packageManager": "pnpm@
|
|
219
|
+
"packageManager": "pnpm@11.1.3",
|
|
221
220
|
"compatiblePackages": {
|
|
222
221
|
"schemaVersion": 1,
|
|
223
222
|
"vite": {
|
|
@@ -230,7 +229,7 @@
|
|
|
230
229
|
},
|
|
231
230
|
"rolldown": {
|
|
232
231
|
"type": "compatible",
|
|
233
|
-
"versions": ">=1.0.0
|
|
232
|
+
"versions": ">=1.0.0"
|
|
234
233
|
}
|
|
235
234
|
}
|
|
236
235
|
}
|