nitro-nightly 3.0.1-20260125-215009-8882bc9e → 3.0.1-20260128-210932-ae83c97e
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/_build/common.mjs +2084 -3212
- package/dist/_build/rolldown.mjs +12 -25
- package/dist/_build/rollup.mjs +11 -27
- package/dist/_build/vite.build.mjs +7 -11
- package/dist/_chunks/dev.mjs +20 -42
- package/dist/_chunks/nitro.mjs +13 -92
- package/dist/_chunks/nitro2.mjs +1 -5
- package/dist/_chunks/utils.mjs +10 -24
- package/dist/_common.mjs +12 -24
- package/dist/_libs/citty.mjs +1 -13
- package/dist/_libs/commondir+is-reference.mjs +12 -22
- package/dist/_libs/compatx.mjs +1 -4
- package/dist/_libs/confbox.mjs +363 -376
- package/dist/_libs/escape-string-regexp.mjs +1 -4
- package/dist/_libs/estree-walker.mjs +4 -92
- package/dist/_libs/hasown+resolve+deepmerge.mjs +144 -230
- package/dist/_libs/httpxy.mjs +5 -21
- package/dist/_libs/klona.mjs +1 -4
- package/dist/_libs/nypm+giget+tinyexec.mjs +874 -926
- package/dist/_libs/plugin-alias.mjs +1 -5
- package/dist/_libs/plugin-inject.mjs +1 -5
- package/dist/_libs/plugin-json.mjs +1 -5
- package/dist/_libs/pluginutils+plugin-commonjs.d.mts +2 -2
- package/dist/_libs/pluginutils.mjs +1 -31
- package/dist/_libs/rc9+c12+dotenv.mjs +43 -83
- package/dist/_libs/readdirp+chokidar.mjs +184 -360
- package/dist/_libs/remapping.mjs +1 -5
- package/dist/_libs/resolve-uri+gen-mapping.mjs +12 -48
- package/dist/_libs/rou3.mjs +1 -32
- package/dist/_libs/tsconfck.mjs +21 -334
- package/dist/_libs/ultrahtml.mjs +3 -16
- package/dist/_libs/unimport+unplugin.mjs +15 -75
- package/dist/_presets.mjs +260 -445
- package/dist/builder.mjs +1 -2
- package/dist/cli/_chunks/build.mjs +1 -5
- package/dist/cli/_chunks/common.mjs +1 -4
- package/dist/cli/_chunks/dev.mjs +1 -5
- package/dist/cli/_chunks/list.mjs +1 -5
- package/dist/cli/_chunks/prepare.mjs +1 -5
- package/dist/cli/_chunks/run.mjs +1 -5
- package/dist/cli/_chunks/task.mjs +1 -5
- package/dist/cli/index.mjs +1 -5
- package/dist/types/index.d.mts +5 -5
- package/dist/types/index.mjs +1 -2
- package/dist/vite.mjs +44 -63
- package/package.json +22 -22
package/dist/builder.mjs
CHANGED
|
@@ -5,5 +5,4 @@ import { a as loadOptions, i as createNitro, n as runTask, r as prerender, t as
|
|
|
5
5
|
import "./_libs/tsconfck.mjs";
|
|
6
6
|
import "./_chunks/nitro2.mjs";
|
|
7
7
|
import { n as createDevServer } from "./_chunks/dev.mjs";
|
|
8
|
-
|
|
9
|
-
export { build, copyPublicAssets, createDevServer, createNitro, getBuildInfo, listTasks, loadOptions, prepare, prerender, runTask, writeTypes };
|
|
8
|
+
export { build, copyPublicAssets, createDevServer, createNitro, getBuildInfo, listTasks, loadOptions, prepare, prerender, runTask, writeTypes };
|
|
@@ -2,8 +2,6 @@ import { ct as resolve } from "../../_build/common.mjs";
|
|
|
2
2
|
import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
3
3
|
import { t as commonArgs } from "./common.mjs";
|
|
4
4
|
import { build, copyPublicAssets, createNitro, prepare, prerender } from "nitro/builder";
|
|
5
|
-
|
|
6
|
-
//#region src/cli/commands/build.ts
|
|
7
5
|
var build_default = defineCommand({
|
|
8
6
|
meta: {
|
|
9
7
|
name: "build",
|
|
@@ -43,6 +41,4 @@ var build_default = defineCommand({
|
|
|
43
41
|
await nitro.close();
|
|
44
42
|
}
|
|
45
43
|
});
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
export { build_default as default };
|
|
44
|
+
export { build_default as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/cli/common.ts
|
|
2
1
|
const commonArgs = {
|
|
3
2
|
dir: {
|
|
4
3
|
type: "string",
|
|
@@ -10,6 +9,4 @@ const commonArgs = {
|
|
|
10
9
|
description: "project root directory (prefer using `--dir`)"
|
|
11
10
|
}
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
export { commonArgs as t };
|
|
12
|
+
export { commonArgs as t };
|
package/dist/cli/_chunks/dev.mjs
CHANGED
|
@@ -5,8 +5,6 @@ import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
|
5
5
|
import { t as commonArgs } from "./common.mjs";
|
|
6
6
|
import { consola } from "consola";
|
|
7
7
|
import { build, createNitro, prepare } from "nitro/builder";
|
|
8
|
-
|
|
9
|
-
//#region src/cli/commands/dev.ts
|
|
10
8
|
const hmrKeyRe = /^runtimeConfig\.|routeRules\./;
|
|
11
9
|
var dev_default = defineCommand({
|
|
12
10
|
meta: {
|
|
@@ -57,6 +55,4 @@ var dev_default = defineCommand({
|
|
|
57
55
|
await reload();
|
|
58
56
|
}
|
|
59
57
|
});
|
|
60
|
-
|
|
61
|
-
//#endregion
|
|
62
|
-
export { dev_default as default };
|
|
58
|
+
export { dev_default as default };
|
|
@@ -2,8 +2,6 @@ import { ct as resolve } from "../../_build/common.mjs";
|
|
|
2
2
|
import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
3
3
|
import { consola } from "consola";
|
|
4
4
|
import { listTasks, loadOptions } from "nitro/builder";
|
|
5
|
-
|
|
6
|
-
//#region src/cli/commands/task/list.ts
|
|
7
5
|
var list_default = defineCommand({
|
|
8
6
|
meta: {
|
|
9
7
|
name: "run",
|
|
@@ -22,6 +20,4 @@ var list_default = defineCommand({
|
|
|
22
20
|
for (const [name, task] of Object.entries(tasks)) consola.log(` - \`${name}\`${task.meta?.description ? ` - ${task.meta.description}` : ""}`);
|
|
23
21
|
}
|
|
24
22
|
});
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
export { list_default as default };
|
|
23
|
+
export { list_default as default };
|
|
@@ -2,8 +2,6 @@ import { ct as resolve } from "../../_build/common.mjs";
|
|
|
2
2
|
import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
3
3
|
import { t as commonArgs } from "./common.mjs";
|
|
4
4
|
import { createNitro, writeTypes } from "nitro/builder";
|
|
5
|
-
|
|
6
|
-
//#region src/cli/commands/prepare.ts
|
|
7
5
|
var prepare_default = defineCommand({
|
|
8
6
|
meta: {
|
|
9
7
|
name: "prepare",
|
|
@@ -14,6 +12,4 @@ var prepare_default = defineCommand({
|
|
|
14
12
|
await writeTypes(await createNitro({ rootDir: resolve(args.dir || args._dir || ".") }));
|
|
15
13
|
}
|
|
16
14
|
});
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { prepare_default as default };
|
|
15
|
+
export { prepare_default as default };
|
package/dist/cli/_chunks/run.mjs
CHANGED
|
@@ -3,8 +3,6 @@ import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
|
3
3
|
import { consola } from "consola";
|
|
4
4
|
import destr from "destr";
|
|
5
5
|
import { loadOptions, runTask } from "nitro/builder";
|
|
6
|
-
|
|
7
|
-
//#region src/cli/commands/task/run.ts
|
|
8
6
|
var run_default = defineCommand({
|
|
9
7
|
meta: {
|
|
10
8
|
name: "run",
|
|
@@ -50,6 +48,4 @@ var run_default = defineCommand({
|
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
});
|
|
53
|
-
|
|
54
|
-
//#endregion
|
|
55
|
-
export { run_default as default };
|
|
51
|
+
export { run_default as default };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/cli/commands/task/index.ts
|
|
4
2
|
var task_default = defineCommand({
|
|
5
3
|
meta: {
|
|
6
4
|
name: "task",
|
|
@@ -11,6 +9,4 @@ var task_default = defineCommand({
|
|
|
11
9
|
run: () => import("./run.mjs").then((r) => r.default)
|
|
12
10
|
}
|
|
13
11
|
});
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { task_default as default };
|
|
12
|
+
export { task_default as default };
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { n as runMain, t as defineCommand } from "../_libs/citty.mjs";
|
|
3
3
|
import { version } from "nitro/meta";
|
|
4
|
-
|
|
5
|
-
//#region src/cli/index.ts
|
|
6
4
|
runMain(defineCommand({
|
|
7
5
|
meta: {
|
|
8
6
|
name: "nitro",
|
|
@@ -16,6 +14,4 @@ runMain(defineCommand({
|
|
|
16
14
|
task: () => import("./_chunks/task.mjs").then((r) => r.default)
|
|
17
15
|
}
|
|
18
16
|
}));
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { };
|
|
17
|
+
export {};
|
package/dist/types/index.d.mts
CHANGED
|
@@ -40,8 +40,8 @@ import { DurableObject } from "cloudflare:workers";
|
|
|
40
40
|
interface InternalApi {}
|
|
41
41
|
type RouterMethod = Lowercase<HTTPMethod>;
|
|
42
42
|
type NitroFetchRequest = Exclude<keyof InternalApi, `/_${string}` | `/api/_${string}`> | Exclude<FetchRequest, string> | (string & {});
|
|
43
|
-
type MiddlewareOf<Route
|
|
44
|
-
type TypedInternalResponse<Route
|
|
43
|
+
type MiddlewareOf<Route extends string, Method extends RouterMethod | "default"> = Method extends keyof InternalApi[MatchedRoutes<Route>] ? InternalApi[MatchedRoutes<Route>][Method] : never;
|
|
44
|
+
type TypedInternalResponse<Route, Default = unknown, Method extends RouterMethod = RouterMethod> = Default extends string | boolean | number | null | void | object ? Default : Route extends string ? MiddlewareOf<Route, Method> extends never ? MiddlewareOf<Route, "default"> extends never ? Default : MiddlewareOf<Route, "default"> : MiddlewareOf<Route, Method> : Default;
|
|
45
45
|
type AvailableRouterMethod<R extends NitroFetchRequest> = R extends string ? keyof InternalApi[MatchedRoutes<R>] extends undefined ? RouterMethod : Extract<keyof InternalApi[MatchedRoutes<R>], "default"> extends undefined ? Extract<RouterMethod, keyof InternalApi[MatchedRoutes<R>]> : RouterMethod : RouterMethod;
|
|
46
46
|
interface NitroFetchOptions<R extends NitroFetchRequest, M extends AvailableRouterMethod<R> = AvailableRouterMethod<R>> extends FetchOptions {
|
|
47
47
|
method?: Uppercase<M> | M;
|
|
@@ -66,9 +66,9 @@ type MaxTuple<N extends any[] = [], T extends any[] = []> = {
|
|
|
66
66
|
current: T;
|
|
67
67
|
result: MaxTuple<N, ["", ...T]>;
|
|
68
68
|
}[[N["length"]] extends [Partial<T>["length"]] ? "current" : "result"];
|
|
69
|
-
type CalcMatchScore<Key extends string, Route
|
|
70
|
-
type _MatchedRoutes<Route
|
|
71
|
-
type MatchedRoutes<Route
|
|
69
|
+
type CalcMatchScore<Key extends string, Route extends string, Score extends any[] = [], Init extends boolean = false, FirstKeySegMatcher extends string = (Init extends true ? ":Invalid:" : "")> = `${Key}/` extends `${infer KeySeg}/${infer KeyRest}` ? KeySeg extends FirstKeySegMatcher ? Subtract<[...Score, ...TupleIfDiff<Route, Key, ["", ""]>], TupleIfDiff<Key, Route, ["", ""]>> : `${Route}/` extends `${infer RouteSeg}/${infer RouteRest}` ? `${RouteSeg}?` extends `${infer RouteSegWithoutQuery}?${string}` ? RouteSegWithoutQuery extends KeySeg ? CalcMatchScore<KeyRest, RouteRest, [...Score, "", ""]> : KeySeg extends `:${string}` ? RouteSegWithoutQuery extends "" ? never : CalcMatchScore<KeyRest, RouteRest, [...Score, ""]> : KeySeg extends RouteSegWithoutQuery ? CalcMatchScore<KeyRest, RouteRest, [...Score, ""]> : never : never : never : never;
|
|
70
|
+
type _MatchedRoutes<Route extends string, MatchedResultUnion extends MatchResult<string> = MatchResult<keyof InternalApi>> = MatchedResultUnion["key"] extends infer MatchedKeys ? MatchedKeys extends string ? Route extends MatchedKeys ? MatchResult<MatchedKeys, true> : MatchedKeys extends `${infer Root}/**${string}` ? MatchedKeys extends `${string}/**` ? Route extends `${Root}/${string}` ? MatchResult<MatchedKeys, false, [], true> : never : MatchResult<MatchedKeys, false, CalcMatchScore<Root, Route, [], true>> : MatchResult<MatchedKeys, false, CalcMatchScore<MatchedKeys, Route, [], true>> : never : never;
|
|
71
|
+
type MatchedRoutes<Route extends string, MatchedKeysResult extends MatchResult<string> = MatchResult<keyof InternalApi>, Matches extends MatchResult<string> = _MatchedRoutes<Route, MatchedKeysResult>> = Route extends "/" ? keyof InternalApi : Extract<Matches, {
|
|
72
72
|
exact: true;
|
|
73
73
|
}> extends never ? Extract<Exclude<Matches, {
|
|
74
74
|
score: never;
|
package/dist/types/index.mjs
CHANGED
package/dist/vite.mjs
CHANGED
|
@@ -19,27 +19,25 @@ import { IncomingMessage } from "node:http";
|
|
|
19
19
|
import { NodeRequest, sendNodeResponse } from "srvx/node";
|
|
20
20
|
import { DevEnvironment } from "vite";
|
|
21
21
|
import { spawn } from "node:child_process";
|
|
22
|
-
|
|
23
|
-
//#region src/build/vite/bundler.ts
|
|
24
22
|
const getBundlerConfig = async (ctx) => {
|
|
25
|
-
const nitro
|
|
26
|
-
const base = baseBuildConfig(nitro
|
|
23
|
+
const nitro = ctx.nitro;
|
|
24
|
+
const base = baseBuildConfig(nitro);
|
|
27
25
|
const commonConfig = {
|
|
28
|
-
input: nitro
|
|
26
|
+
input: nitro.options.entry,
|
|
29
27
|
external: [...base.env.external],
|
|
30
|
-
plugins: [...await baseBuildPlugins(nitro
|
|
28
|
+
plugins: [...await baseBuildPlugins(nitro, base)].filter(Boolean),
|
|
31
29
|
treeshake: { moduleSideEffects(id) {
|
|
32
|
-
return nitro
|
|
30
|
+
return nitro.options.moduleSideEffects.some((p) => id.startsWith(p));
|
|
33
31
|
} },
|
|
34
32
|
onwarn(warning, warn) {
|
|
35
33
|
if (!base.ignoreWarningCodes.has(warning.code || "")) warn(warning);
|
|
36
34
|
},
|
|
37
35
|
output: {
|
|
38
|
-
dir: nitro
|
|
36
|
+
dir: nitro.options.output.serverDir,
|
|
39
37
|
format: "esm",
|
|
40
38
|
entryFileNames: "index.mjs",
|
|
41
|
-
chunkFileNames: (chunk) => getChunkName(chunk, nitro
|
|
42
|
-
inlineDynamicImports: nitro
|
|
39
|
+
chunkFileNames: (chunk) => getChunkName(chunk, nitro),
|
|
40
|
+
inlineDynamicImports: nitro.options.inlineDynamicImports,
|
|
43
41
|
sourcemapIgnoreList: (id) => id.includes("node_modules")
|
|
44
42
|
}
|
|
45
43
|
};
|
|
@@ -50,7 +48,7 @@ const getBundlerConfig = async (ctx) => {
|
|
|
50
48
|
test: NODE_MODULES_RE,
|
|
51
49
|
name: (id) => libChunkName(id)
|
|
52
50
|
}] } }
|
|
53
|
-
}, nitro
|
|
51
|
+
}, nitro.options.rolldownConfig, nitro.options.rollupConfig, commonConfig);
|
|
54
52
|
const outputConfig = rolldownConfig.output;
|
|
55
53
|
if (outputConfig.inlineDynamicImports || outputConfig.format === "iife") delete outputConfig.codeSplitting;
|
|
56
54
|
return {
|
|
@@ -69,7 +67,7 @@ const getBundlerConfig = async (ctx) => {
|
|
|
69
67
|
if (NODE_MODULES_RE.test(id)) return libChunkName(id);
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
|
-
}, nitro
|
|
70
|
+
}, nitro.options.rolldownConfig, nitro.options.rollupConfig, commonConfig);
|
|
73
71
|
const outputConfig = rollupConfig.output;
|
|
74
72
|
if (outputConfig.inlineDynamicImports || outputConfig.format === "iife") delete outputConfig.manualChunks;
|
|
75
73
|
return {
|
|
@@ -78,16 +76,13 @@ const getBundlerConfig = async (ctx) => {
|
|
|
78
76
|
};
|
|
79
77
|
}
|
|
80
78
|
};
|
|
81
|
-
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/build/vite/prod.ts
|
|
84
79
|
const BuilderNames = {
|
|
85
80
|
nitro: colors.magenta("Nitro"),
|
|
86
81
|
client: colors.green("Client"),
|
|
87
82
|
ssr: colors.blue("SSR")
|
|
88
83
|
};
|
|
89
84
|
async function buildEnvironments(ctx, builder) {
|
|
90
|
-
const nitro
|
|
85
|
+
const nitro = ctx.nitro;
|
|
91
86
|
for (const [envName, env] of Object.entries(builder.environments)) {
|
|
92
87
|
const fmtName = BuilderNames[envName] || (envName.length <= 3 ? envName.toUpperCase() : envName[0].toUpperCase() + envName.slice(1));
|
|
93
88
|
if (envName === "nitro" || !env.config.build.rollupOptions.input || env.isBuilt) {
|
|
@@ -95,11 +90,11 @@ async function buildEnvironments(ctx, builder) {
|
|
|
95
90
|
"nitro",
|
|
96
91
|
"ssr",
|
|
97
92
|
"client"
|
|
98
|
-
].includes(envName)) nitro
|
|
93
|
+
].includes(envName)) nitro.logger.info(env.isBuilt ? `Skipping ${fmtName} (already built)` : `Skipping ${fmtName} (no input defined)`);
|
|
99
94
|
continue;
|
|
100
95
|
}
|
|
101
96
|
if (!a && !T) console.log();
|
|
102
|
-
nitro
|
|
97
|
+
nitro.logger.start(`Building [${fmtName}]`);
|
|
103
98
|
await builder.build(env);
|
|
104
99
|
}
|
|
105
100
|
const nitroOptions = ctx.nitro.options;
|
|
@@ -117,12 +112,12 @@ async function buildEnvironments(ctx, builder) {
|
|
|
117
112
|
}
|
|
118
113
|
await builder.writeAssetsManifest?.();
|
|
119
114
|
if (!a && !T) console.log();
|
|
120
|
-
const buildInfo = [["preset", nitro
|
|
121
|
-
nitro
|
|
122
|
-
await copyPublicAssets(nitro
|
|
115
|
+
const buildInfo = [["preset", nitro.options.preset], ["compatibility", formatCompatibilityDate(nitro.options.compatibilityDate)]].filter((e) => e[1]);
|
|
116
|
+
nitro.logger.start(`Building [${BuilderNames.nitro}] ${colors.dim(`(${buildInfo.map(([k, v]) => `${k}: \`${v}\``).join(", ")})`)}`);
|
|
117
|
+
await copyPublicAssets(nitro);
|
|
123
118
|
const assetDirs = new Set(Object.values(builder.environments).filter((env) => env.config.consumer === "client").map((env) => env.config.build.assetsDir).filter(Boolean));
|
|
124
119
|
for (const assetsDir of assetDirs) {
|
|
125
|
-
if (!existsSync(resolve$1(nitro
|
|
120
|
+
if (!existsSync(resolve$1(nitro.options.output.publicDir, assetsDir))) continue;
|
|
126
121
|
const rule = ctx.nitro.options.routeRules[`/${assetsDir}/**`] ??= {};
|
|
127
122
|
if (!rule.headers?.["cache-control"]) rule.headers = {
|
|
128
123
|
...rule.headers,
|
|
@@ -131,16 +126,16 @@ async function buildEnvironments(ctx, builder) {
|
|
|
131
126
|
}
|
|
132
127
|
ctx.nitro.routing.sync();
|
|
133
128
|
await builder.build(builder.environments.nitro);
|
|
134
|
-
await nitro
|
|
135
|
-
await nitro
|
|
136
|
-
await writeBuildInfo(nitro
|
|
137
|
-
const rOutput = relative$1(process.cwd(), nitro
|
|
129
|
+
await nitro.close();
|
|
130
|
+
await nitro.hooks.callHook("compiled", nitro);
|
|
131
|
+
await writeBuildInfo(nitro);
|
|
132
|
+
const rOutput = relative$1(process.cwd(), nitro.options.output.dir);
|
|
138
133
|
const rewriteRelativePaths = (input) => {
|
|
139
134
|
return input.replace(/([\s:])\.\/(\S*)/g, `$1${rOutput}/$2`);
|
|
140
135
|
};
|
|
141
136
|
if (!a && !T) console.log();
|
|
142
|
-
if (nitro
|
|
143
|
-
if (nitro
|
|
137
|
+
if (nitro.options.commands.preview) nitro.logger.success(`You can preview this build using \`${rewriteRelativePaths(nitro.options.commands.preview)}\``);
|
|
138
|
+
if (nitro.options.commands.deploy) nitro.logger.success(`You can deploy this build using \`${rewriteRelativePaths(nitro.options.commands.deploy)}\``);
|
|
144
139
|
}
|
|
145
140
|
function prodSetup(ctx) {
|
|
146
141
|
return `
|
|
@@ -166,9 +161,6 @@ ${Object.keys(ctx.services).map((name) => {
|
|
|
166
161
|
globalThis.__nitro_vite_envs__ = services;
|
|
167
162
|
`;
|
|
168
163
|
}
|
|
169
|
-
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region src/build/vite/dev.ts
|
|
172
164
|
function createFetchableDevEnvironment(name, config, devServer, entry) {
|
|
173
165
|
return new FetchableDevEnvironment(name, config, {
|
|
174
166
|
hot: true,
|
|
@@ -226,23 +218,23 @@ function createTransport(name, hooks) {
|
|
|
226
218
|
};
|
|
227
219
|
}
|
|
228
220
|
async function configureViteDevServer(ctx, server) {
|
|
229
|
-
const nitro
|
|
230
|
-
const nitroEnv
|
|
231
|
-
const nitroConfigFile = nitro
|
|
221
|
+
const nitro = ctx.nitro;
|
|
222
|
+
const nitroEnv = server.environments.nitro;
|
|
223
|
+
const nitroConfigFile = nitro.options._c12.configFile;
|
|
232
224
|
if (nitroConfigFile) server.config.configFileDependencies.push(nitroConfigFile);
|
|
233
|
-
if (nitro
|
|
225
|
+
if (nitro.options.features.websocket ?? nitro.options.experimental.websocket) server.httpServer.on("upgrade", (req, socket, head) => {
|
|
234
226
|
if (req.url?.startsWith("/?token")) return;
|
|
235
227
|
getEnvRunner(ctx).upgrade?.(req, socket, head);
|
|
236
228
|
});
|
|
237
229
|
const reload = debounce(async () => {
|
|
238
|
-
await scanHandlers(nitro
|
|
239
|
-
nitro
|
|
240
|
-
nitroEnv
|
|
241
|
-
nitroEnv
|
|
230
|
+
await scanHandlers(nitro);
|
|
231
|
+
nitro.routing.sync();
|
|
232
|
+
nitroEnv.moduleGraph.invalidateAll();
|
|
233
|
+
nitroEnv.hot.send({ type: "full-reload" });
|
|
242
234
|
});
|
|
243
|
-
const scanDirs = nitro
|
|
244
|
-
join$1(dir, nitro
|
|
245
|
-
join$1(dir, nitro
|
|
235
|
+
const scanDirs = nitro.options.scanDirs.flatMap((dir) => [
|
|
236
|
+
join$1(dir, nitro.options.apiDir || "api"),
|
|
237
|
+
join$1(dir, nitro.options.routesDir || "routes"),
|
|
246
238
|
join$1(dir, "middleware"),
|
|
247
239
|
join$1(dir, "plugins"),
|
|
248
240
|
join$1(dir, "modules")
|
|
@@ -253,23 +245,23 @@ async function configureViteDevServer(ctx, server) {
|
|
|
253
245
|
"unlink",
|
|
254
246
|
"unlinkDir"
|
|
255
247
|
]);
|
|
256
|
-
const scanDirsWatcher = watch$1(scanDirs, { ignoreInitial: true }).on("all", (event, path
|
|
248
|
+
const scanDirsWatcher = watch$1(scanDirs, { ignoreInitial: true }).on("all", (event, path, stat) => {
|
|
257
249
|
if (watchReloadEvents.has(event)) reload();
|
|
258
250
|
});
|
|
259
|
-
const rootDirWatcher = watch(nitro
|
|
251
|
+
const rootDirWatcher = watch(nitro.options.rootDir, { persistent: false }, (_event, filename) => {
|
|
260
252
|
if (filename && /^server\.[mc]?[jt]sx?$/.test(filename)) reload();
|
|
261
253
|
});
|
|
262
|
-
nitro
|
|
254
|
+
nitro.hooks.hook("close", () => {
|
|
263
255
|
scanDirsWatcher.close();
|
|
264
256
|
rootDirWatcher.close();
|
|
265
257
|
});
|
|
266
258
|
const hostIPC = { async transformHTML(html) {
|
|
267
259
|
return server.transformIndexHtml("/", html).then((r) => r.replace("<!--ssr-outlet-->", `{{{ globalThis.__nitro_vite_envs__?.["ssr"]?.fetch($REQUEST) || "" }}}`));
|
|
268
260
|
} };
|
|
269
|
-
nitroEnv
|
|
261
|
+
nitroEnv.devServer.onMessage(async (payload) => {
|
|
270
262
|
if (payload.type === "custom" && payload.event === "nitro:vite-invoke") {
|
|
271
263
|
const res = await hostIPC[payload.data.name](payload.data.data).then((data) => ({ data })).catch((error) => ({ error }));
|
|
272
|
-
nitroEnv
|
|
264
|
+
nitroEnv.devServer.sendMessage({
|
|
273
265
|
type: "custom",
|
|
274
266
|
event: "nitro:vite-invoke-response",
|
|
275
267
|
data: {
|
|
@@ -290,7 +282,7 @@ async function configureViteDevServer(ctx, server) {
|
|
|
290
282
|
const devAppRes = await ctx.devApp.fetch(req);
|
|
291
283
|
if (nodeRes.writableEnded || nodeRes.headersSent) return;
|
|
292
284
|
if (devAppRes.status !== 404) return await sendNodeResponse(nodeRes, devAppRes);
|
|
293
|
-
const envRes = await nitroEnv
|
|
285
|
+
const envRes = await nitroEnv.dispatchFetch(req);
|
|
294
286
|
if (nodeRes.writableEnded || nodeRes.headersSent) return;
|
|
295
287
|
return await sendNodeResponse(nodeRes, envRes);
|
|
296
288
|
} catch (error) {
|
|
@@ -307,9 +299,6 @@ async function configureViteDevServer(ctx, server) {
|
|
|
307
299
|
server.middlewares.use(nitroDevMiddleware);
|
|
308
300
|
};
|
|
309
301
|
}
|
|
310
|
-
|
|
311
|
-
//#endregion
|
|
312
|
-
//#region src/build/vite/env.ts
|
|
313
302
|
function getEnvRunner(ctx) {
|
|
314
303
|
return ctx._envRunner ??= new NodeEnvRunner({
|
|
315
304
|
name: "nitro-vite",
|
|
@@ -331,7 +320,7 @@ function createNitroEnvironment(ctx) {
|
|
|
331
320
|
resolve: {
|
|
332
321
|
noExternal: ctx.nitro.options.dev ? [
|
|
333
322
|
/^nitro$/,
|
|
334
|
-
|
|
323
|
+
new RegExp(`^(${runtimeDependencies.join("|")})$`),
|
|
335
324
|
...ctx.bundlerConfig.base.noExternal
|
|
336
325
|
] : true,
|
|
337
326
|
conditions: ctx.nitro.options.exportConditions,
|
|
@@ -377,9 +366,6 @@ function tryResolve(id) {
|
|
|
377
366
|
try: true
|
|
378
367
|
}) || id;
|
|
379
368
|
}
|
|
380
|
-
|
|
381
|
-
//#endregion
|
|
382
|
-
//#region src/build/vite/preview.ts
|
|
383
369
|
function nitroPreviewPlugin(ctx) {
|
|
384
370
|
return {
|
|
385
371
|
name: "nitro:preview",
|
|
@@ -468,9 +454,6 @@ async function loadPreviewDotEnv(root) {
|
|
|
468
454
|
});
|
|
469
455
|
return Object.entries(env).filter(([_key, val]) => val);
|
|
470
456
|
}
|
|
471
|
-
|
|
472
|
-
//#endregion
|
|
473
|
-
//#region src/build/vite/plugin.ts
|
|
474
457
|
const DEFAULT_EXTENSIONS = [
|
|
475
458
|
".ts",
|
|
476
459
|
".js",
|
|
@@ -604,10 +587,10 @@ function nitroMain(ctx) {
|
|
|
604
587
|
async hotUpdate({ server, modules, timestamp }) {
|
|
605
588
|
const env = this.environment;
|
|
606
589
|
if (ctx.pluginConfig.experimental?.vite.serverReload === false || env.config.consumer === "client") return;
|
|
607
|
-
const clientEnvs = Object.values(server.environments).filter((env
|
|
590
|
+
const clientEnvs = Object.values(server.environments).filter((env) => env.config.consumer === "client");
|
|
608
591
|
let hasServerOnlyModule = false;
|
|
609
592
|
const invalidated = /* @__PURE__ */ new Set();
|
|
610
|
-
for (const mod of modules) if (mod.id && !clientEnvs.some((env
|
|
593
|
+
for (const mod of modules) if (mod.id && !clientEnvs.some((env) => env.moduleGraph.getModuleById(mod.id))) {
|
|
611
594
|
hasServerOnlyModule = true;
|
|
612
595
|
env.moduleGraph.invalidateModule(mod, invalidated, timestamp, false);
|
|
613
596
|
}
|
|
@@ -737,6 +720,4 @@ function getEntry(input) {
|
|
|
737
720
|
function flattenPlugins(plugins) {
|
|
738
721
|
return plugins.flatMap((plugin) => Array.isArray(plugin) ? flattenPlugins(plugin) : [plugin]).filter((p) => p && !(p instanceof Promise));
|
|
739
722
|
}
|
|
740
|
-
|
|
741
|
-
//#endregion
|
|
742
|
-
export { nitro };
|
|
723
|
+
export { nitro };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-nightly",
|
|
3
|
-
"version": "3.0.1-
|
|
3
|
+
"version": "3.0.1-20260128-210932-ae83c97e",
|
|
4
4
|
"description": "Build and Deploy Universal JavaScript Servers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api-routes",
|
|
@@ -68,24 +68,24 @@
|
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"consola": "^3.4.2",
|
|
71
|
-
"crossws": "^0.4.
|
|
71
|
+
"crossws": "^0.4.4",
|
|
72
72
|
"db0": "^0.3.4",
|
|
73
73
|
"h3": "^2.0.1-rc.11",
|
|
74
74
|
"jiti": "^2.6.1",
|
|
75
|
-
"nf3": "^0.3.
|
|
75
|
+
"nf3": "^0.3.7",
|
|
76
76
|
"ofetch": "^2.0.0-alpha.3",
|
|
77
77
|
"ohash": "^2.0.11",
|
|
78
|
-
"oxc-minify": "^0.
|
|
79
|
-
"oxc-transform": "^0.
|
|
78
|
+
"oxc-minify": "^0.111.0",
|
|
79
|
+
"oxc-transform": "^0.111.0",
|
|
80
80
|
"srvx": "^0.10.1",
|
|
81
|
-
"undici": "^7.
|
|
81
|
+
"undici": "^7.19.2",
|
|
82
82
|
"unenv": "^2.0.0-rc.24",
|
|
83
83
|
"unstorage": "^2.0.0-alpha.5"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@azure/functions": "^3.5.1",
|
|
87
87
|
"@azure/static-web-apps-cli": "^2.0.7",
|
|
88
|
-
"@cloudflare/workers-types": "^4.
|
|
88
|
+
"@cloudflare/workers-types": "^4.20260128.0",
|
|
89
89
|
"@deno/types": "^0.0.1",
|
|
90
90
|
"@hiogawa/vite-plugin-fullstack": "^0.0.11",
|
|
91
91
|
"@netlify/edge-functions": "^3.0.3",
|
|
@@ -96,17 +96,17 @@
|
|
|
96
96
|
"@rollup/plugin-json": "^6.1.0",
|
|
97
97
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
98
98
|
"@rollup/plugin-replace": "^6.0.3",
|
|
99
|
-
"@scalar/api-reference": "^1.
|
|
99
|
+
"@scalar/api-reference": "^1.44.0",
|
|
100
100
|
"@types/aws-lambda": "^8.10.160",
|
|
101
101
|
"@types/estree": "^1.0.8",
|
|
102
102
|
"@types/etag": "^1.8.4",
|
|
103
103
|
"@types/fs-extra": "^11.0.4",
|
|
104
104
|
"@types/http-proxy": "^1.17.17",
|
|
105
|
-
"@types/node": "^25.0
|
|
105
|
+
"@types/node": "^25.1.0",
|
|
106
106
|
"@types/node-fetch": "^2.6.13",
|
|
107
107
|
"@types/semver": "^7.7.1",
|
|
108
108
|
"@types/xml2js": "^0.4.14",
|
|
109
|
-
"@vitest/coverage-v8": "^4.0.
|
|
109
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
110
110
|
"automd": "^0.4.2",
|
|
111
111
|
"c12": "^3.3.3",
|
|
112
112
|
"changelogen": "^0.6.2",
|
|
@@ -134,20 +134,20 @@
|
|
|
134
134
|
"knitwork": "^1.3.0",
|
|
135
135
|
"magic-string": "^0.30.21",
|
|
136
136
|
"mime": "^4.1.0",
|
|
137
|
-
"miniflare": "^4.
|
|
137
|
+
"miniflare": "^4.20260124.0",
|
|
138
138
|
"mlly": "^1.8.0",
|
|
139
139
|
"nypm": "^0.6.4",
|
|
140
|
-
"obuild": "^0.4.
|
|
141
|
-
"oxfmt": "^0.
|
|
142
|
-
"oxlint": "^1.
|
|
140
|
+
"obuild": "^0.4.22",
|
|
141
|
+
"oxfmt": "^0.27.0",
|
|
142
|
+
"oxlint": "^1.42.0",
|
|
143
143
|
"pathe": "^2.0.3",
|
|
144
|
-
"perfect-debounce": "^2.
|
|
144
|
+
"perfect-debounce": "^2.1.0",
|
|
145
145
|
"pkg-types": "^2.3.0",
|
|
146
146
|
"pretty-bytes": "^7.1.0",
|
|
147
|
-
"react": "^19.2.
|
|
147
|
+
"react": "^19.2.4",
|
|
148
148
|
"rendu": "^0.0.7",
|
|
149
|
-
"rolldown": "1.0.0-
|
|
150
|
-
"rollup": "^4.
|
|
149
|
+
"rolldown": "1.0.0-rc.2",
|
|
150
|
+
"rollup": "^4.57.0",
|
|
151
151
|
"rou3": "^0.7.12",
|
|
152
152
|
"scule": "^1.3.0",
|
|
153
153
|
"semver": "^7.7.3",
|
|
@@ -164,10 +164,10 @@
|
|
|
164
164
|
"unimport": "^5.6.0",
|
|
165
165
|
"untyped": "^2.0.0",
|
|
166
166
|
"unwasm": "^0.5.3",
|
|
167
|
-
"vite": "8.0.0-beta.
|
|
167
|
+
"vite": "8.0.0-beta.10",
|
|
168
168
|
"vite7": "npm:vite@^7.3.1",
|
|
169
|
-
"vitest": "^4.0.
|
|
170
|
-
"wrangler": "
|
|
169
|
+
"vitest": "^4.0.18",
|
|
170
|
+
"wrangler": "^4.61.0",
|
|
171
171
|
"xml2js": "^0.6.2",
|
|
172
172
|
"youch": "4.1.0-beta.13",
|
|
173
173
|
"youch-core": "^0.3.3"
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
"engines": {
|
|
200
200
|
"node": "^20.19.0 || >=22.12.0"
|
|
201
201
|
},
|
|
202
|
-
"packageManager": "pnpm@10.28.
|
|
202
|
+
"packageManager": "pnpm@10.28.2",
|
|
203
203
|
"compatiblePackages": {
|
|
204
204
|
"schemaVersion": 1,
|
|
205
205
|
"vite": {
|