@vercel/node 6.0.0 → 8.1.0
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/dev-server.mjs +41 -3
- package/dist/index.js +45 -5
- package/package.json +5 -5
package/dist/dev-server.mjs
CHANGED
|
@@ -647,6 +647,31 @@ function validateConfiguredRuntime(runtime, entrypoint2) {
|
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
|
+
var MIDDLEWARE_NODEJS_DEFAULT_ENV = "VERCEL_MIDDLEWARE_DEFAULT_RUNTIME_NODEJS";
|
|
651
|
+
var MIDDLEWARE_NODEJS_DEFAULT_SINCE = /* @__PURE__ */ new Date("2026-09-01T00:00:00Z");
|
|
652
|
+
function resolveMiddlewareRuntime({
|
|
653
|
+
configuredRuntime,
|
|
654
|
+
middlewareRuntime,
|
|
655
|
+
projectCreatedAt,
|
|
656
|
+
isDev,
|
|
657
|
+
env
|
|
658
|
+
}) {
|
|
659
|
+
if (isEdgeRuntime(configuredRuntime)) {
|
|
660
|
+
return { runtime: "edge", reason: "config.runtime" };
|
|
661
|
+
}
|
|
662
|
+
if (configuredRuntime === "nodejs") {
|
|
663
|
+
return { runtime: "nodejs", reason: "config.runtime" };
|
|
664
|
+
}
|
|
665
|
+
if (middlewareRuntime === "nodejs") {
|
|
666
|
+
return { runtime: "nodejs", reason: "proxy entrypoint" };
|
|
667
|
+
}
|
|
668
|
+
if (env[MIDDLEWARE_NODEJS_DEFAULT_ENV] === "0") {
|
|
669
|
+
return { runtime: "edge", reason: `${MIDDLEWARE_NODEJS_DEFAULT_ENV}=0` };
|
|
670
|
+
}
|
|
671
|
+
const enabled = isDev === true || env[MIDDLEWARE_NODEJS_DEFAULT_ENV] === "1";
|
|
672
|
+
const isNewProject = projectCreatedAt !== void 0 && projectCreatedAt >= MIDDLEWARE_NODEJS_DEFAULT_SINCE.getTime();
|
|
673
|
+
return enabled && isNewProject ? { runtime: "nodejs", reason: "project creation date" } : { runtime: "edge", reason: "default" };
|
|
674
|
+
}
|
|
650
675
|
async function serializeBody(request) {
|
|
651
676
|
return request.method !== "GET" && request.method !== "HEAD" ? await streamToBuffer(request) : void 0;
|
|
652
677
|
}
|
|
@@ -1137,7 +1162,13 @@ async function compileUserCode2(entrypointPath, awaiter, options) {
|
|
|
1137
1162
|
serverFound();
|
|
1138
1163
|
return this;
|
|
1139
1164
|
};
|
|
1140
|
-
let listener
|
|
1165
|
+
let listener;
|
|
1166
|
+
try {
|
|
1167
|
+
listener = await import(id);
|
|
1168
|
+
} catch (error) {
|
|
1169
|
+
http.Server.prototype.listen = originalListen;
|
|
1170
|
+
throw error;
|
|
1171
|
+
}
|
|
1141
1172
|
for (let i = 0; i < 5; i++) {
|
|
1142
1173
|
if (listener.default)
|
|
1143
1174
|
listener = listener.default;
|
|
@@ -1267,7 +1298,13 @@ async function createEventHandler(entrypoint2, config, options) {
|
|
|
1267
1298
|
);
|
|
1268
1299
|
const maxDuration = typeof configMaxDuration === "number" ? configMaxDuration : void 0;
|
|
1269
1300
|
const isMiddleware = config.middleware === true;
|
|
1270
|
-
const useEdgeRuntime = isMiddleware
|
|
1301
|
+
const useEdgeRuntime = isMiddleware ? resolveMiddlewareRuntime({
|
|
1302
|
+
configuredRuntime: runtime,
|
|
1303
|
+
middlewareRuntime: config.middlewareRuntime,
|
|
1304
|
+
projectCreatedAt: config.projectSettings?.createdAt,
|
|
1305
|
+
isDev: true,
|
|
1306
|
+
env: { ...process.env, ...options.buildEnv }
|
|
1307
|
+
}).runtime === "edge" : isEdgeRuntime(runtime);
|
|
1271
1308
|
if (useEdgeRuntime) {
|
|
1272
1309
|
return createEdgeEventHandler(
|
|
1273
1310
|
entrypointPath,
|
|
@@ -1311,7 +1348,8 @@ async function main() {
|
|
|
1311
1348
|
await listen2(proxyServer, { host: "127.0.0.1", port: requestedPort });
|
|
1312
1349
|
try {
|
|
1313
1350
|
const result = await createEventHandler(entrypoint, config, {
|
|
1314
|
-
shouldAddHelpers
|
|
1351
|
+
shouldAddHelpers,
|
|
1352
|
+
buildEnv
|
|
1315
1353
|
});
|
|
1316
1354
|
handleEvent = result.handler;
|
|
1317
1355
|
onExit = result.onExit;
|
package/dist/index.js
CHANGED
|
@@ -72484,6 +72484,32 @@ function validateMiddlewareRuntime(runtime, entrypoint, requiredRuntime) {
|
|
|
72484
72484
|
);
|
|
72485
72485
|
}
|
|
72486
72486
|
}
|
|
72487
|
+
var MIDDLEWARE_NODEJS_DEFAULT_ENV = "VERCEL_MIDDLEWARE_DEFAULT_RUNTIME_NODEJS";
|
|
72488
|
+
var MIDDLEWARE_NODEJS_DEFAULT_SINCE = /* @__PURE__ */ new Date("2026-09-01T00:00:00Z");
|
|
72489
|
+
var edgeMiddlewareDeprecationWarning = (entrypoint) => `Warning: ${entrypoint} uses the deprecated "edge" runtime. Migrate to the Node.js runtime for better performance and reliability by exporting \`const config = { runtime: 'nodejs' }\`. Learn more: https://vercel.com/docs/routing-middleware#runtime-options`;
|
|
72490
|
+
function resolveMiddlewareRuntime({
|
|
72491
|
+
configuredRuntime,
|
|
72492
|
+
middlewareRuntime,
|
|
72493
|
+
projectCreatedAt,
|
|
72494
|
+
isDev,
|
|
72495
|
+
env
|
|
72496
|
+
}) {
|
|
72497
|
+
if (isEdgeRuntime(configuredRuntime)) {
|
|
72498
|
+
return { runtime: "edge", reason: "config.runtime" };
|
|
72499
|
+
}
|
|
72500
|
+
if (configuredRuntime === "nodejs") {
|
|
72501
|
+
return { runtime: "nodejs", reason: "config.runtime" };
|
|
72502
|
+
}
|
|
72503
|
+
if (middlewareRuntime === "nodejs") {
|
|
72504
|
+
return { runtime: "nodejs", reason: "proxy entrypoint" };
|
|
72505
|
+
}
|
|
72506
|
+
if (env[MIDDLEWARE_NODEJS_DEFAULT_ENV] === "0") {
|
|
72507
|
+
return { runtime: "edge", reason: `${MIDDLEWARE_NODEJS_DEFAULT_ENV}=0` };
|
|
72508
|
+
}
|
|
72509
|
+
const enabled = isDev === true || env[MIDDLEWARE_NODEJS_DEFAULT_ENV] === "1";
|
|
72510
|
+
const isNewProject = projectCreatedAt !== void 0 && projectCreatedAt >= MIDDLEWARE_NODEJS_DEFAULT_SINCE.getTime();
|
|
72511
|
+
return enabled && isNewProject ? { runtime: "nodejs", reason: "project creation date" } : { runtime: "edge", reason: "default" };
|
|
72512
|
+
}
|
|
72487
72513
|
|
|
72488
72514
|
// src/build.ts
|
|
72489
72515
|
var require_2 = (0, import_module2.createRequire)(__filename);
|
|
@@ -72787,6 +72813,7 @@ var build = async ({
|
|
|
72787
72813
|
config = {},
|
|
72788
72814
|
meta = {},
|
|
72789
72815
|
service,
|
|
72816
|
+
span,
|
|
72790
72817
|
considerBuildCommand = false,
|
|
72791
72818
|
entrypointCallback,
|
|
72792
72819
|
checks = () => {
|
|
@@ -72848,17 +72875,30 @@ var build = async ({
|
|
|
72848
72875
|
}
|
|
72849
72876
|
}
|
|
72850
72877
|
const isMiddleware = config.middleware === true;
|
|
72851
|
-
let isEdgeFunction = isMiddleware;
|
|
72852
72878
|
const project = new import_ts_morph.Project();
|
|
72853
|
-
const staticConfig = (0, import_static_config.getConfig)(project, entrypointPath);
|
|
72879
|
+
const staticConfig = (0, import_static_config.getConfig)(project, entrypointPath, void 0, span);
|
|
72854
72880
|
const runtime = staticConfig?.runtime;
|
|
72855
72881
|
validateMiddlewareRuntime(
|
|
72856
72882
|
runtime,
|
|
72857
72883
|
entrypoint,
|
|
72858
72884
|
isMiddleware ? config.middlewareRuntime : void 0
|
|
72859
72885
|
);
|
|
72860
|
-
|
|
72861
|
-
|
|
72886
|
+
let isEdgeFunction = false;
|
|
72887
|
+
if (isMiddleware) {
|
|
72888
|
+
const middleware = resolveMiddlewareRuntime({
|
|
72889
|
+
configuredRuntime: runtime,
|
|
72890
|
+
middlewareRuntime: config.middlewareRuntime,
|
|
72891
|
+
projectCreatedAt: config.projectSettings?.createdAt,
|
|
72892
|
+
isDev: meta.isDev,
|
|
72893
|
+
env: process.env
|
|
72894
|
+
});
|
|
72895
|
+
isEdgeFunction = middleware.runtime === "edge";
|
|
72896
|
+
(0, import_build_utils6.debug)(
|
|
72897
|
+
`Middleware runtime for "${entrypoint}": ${middleware.runtime} (${middleware.reason})`
|
|
72898
|
+
);
|
|
72899
|
+
if (isEdgeFunction) {
|
|
72900
|
+
console.warn(edgeMiddlewareDeprecationWarning(entrypoint));
|
|
72901
|
+
}
|
|
72862
72902
|
} else if (runtime) {
|
|
72863
72903
|
isEdgeFunction = isEdgeRuntime(runtime);
|
|
72864
72904
|
}
|
|
@@ -73219,7 +73259,7 @@ var startDevServer = async (opts) => {
|
|
|
73219
73259
|
await syncDependencies(workPath, opts.onStdout, opts.onStderr);
|
|
73220
73260
|
}
|
|
73221
73261
|
const project = new import_ts_morph2.Project();
|
|
73222
|
-
const staticConfig = (0, import_static_config2.getConfig)(project, entrypointPath);
|
|
73262
|
+
const staticConfig = (0, import_static_config2.getConfig)(project, entrypointPath, void 0, opts.span);
|
|
73223
73263
|
if (config.middlewareRuntime) {
|
|
73224
73264
|
validateMiddlewareRuntime(
|
|
73225
73265
|
staticConfig?.runtime,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/node",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"tsx": "4.21.0",
|
|
33
33
|
"typescript": "npm:typescript@5.9.3",
|
|
34
34
|
"undici": "5.28.4",
|
|
35
|
-
"@vercel/
|
|
36
|
-
"@vercel/
|
|
35
|
+
"@vercel/static-config": "3.4.2",
|
|
36
|
+
"@vercel/error-utils": "2.2.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@vercel/build-utils": "14.
|
|
39
|
+
"@vercel/build-utils": "14.5.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@babel/core": "7.24.4",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"tree-kill": "1.2.2",
|
|
60
60
|
"vite": "^6.4.3",
|
|
61
61
|
"vitest": "^4.1.10",
|
|
62
|
-
"@vercel/build-utils": "14.
|
|
62
|
+
"@vercel/build-utils": "14.5.0",
|
|
63
63
|
"@vercel/functions": "3.9.5"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|