@vercel/node 5.2.1 → 5.3.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 +22 -13
- package/dist/index.js +3 -12
- package/package.json +3 -3
package/dist/dev-server.mjs
CHANGED
@@ -629,14 +629,9 @@ var EdgeRuntimes = /* @__PURE__ */ ((EdgeRuntimes2) => {
|
|
629
629
|
function isEdgeRuntime(runtime) {
|
630
630
|
return runtime !== void 0 && Object.values(EdgeRuntimes).includes(runtime);
|
631
631
|
}
|
632
|
-
var ALLOWED_RUNTIMES = Object.values(EdgeRuntimes);
|
632
|
+
var ALLOWED_RUNTIMES = [...Object.values(EdgeRuntimes), "nodejs"];
|
633
633
|
function validateConfiguredRuntime(runtime, entrypoint2) {
|
634
634
|
if (runtime) {
|
635
|
-
if (runtime === "nodejs") {
|
636
|
-
throw new Error(
|
637
|
-
`${entrypoint2}: \`config.runtime: "nodejs"\` semantics will evolve soon. Please remove the \`runtime\` key to keep the existing behavior.`
|
638
|
-
);
|
639
|
-
}
|
640
635
|
if (!ALLOWED_RUNTIMES.includes(runtime)) {
|
641
636
|
throw new Error(
|
642
637
|
`${entrypoint2}: unsupported "runtime" value in \`config\`: ${JSON.stringify(
|
@@ -1121,10 +1116,21 @@ async function compileUserCode2(entrypointPath, awaiter, options) {
|
|
1121
1116
|
if (listener.default)
|
1122
1117
|
listener = listener.default;
|
1123
1118
|
}
|
1124
|
-
|
1119
|
+
const shouldUseWebHandlers = options.isMiddleware || HTTP_METHODS.some((method) => typeof listener[method] === "function");
|
1120
|
+
if (shouldUseWebHandlers) {
|
1125
1121
|
const { createWebExportsHandler: createWebExportsHandler2 } = await Promise.resolve().then(() => (init_helpers_web(), helpers_web_exports));
|
1126
1122
|
const getWebExportsHandler = createWebExportsHandler2(awaiter);
|
1127
|
-
|
1123
|
+
let handler = listener;
|
1124
|
+
if (options.isMiddleware) {
|
1125
|
+
handler = HTTP_METHODS.reduce(
|
1126
|
+
(acc, method) => {
|
1127
|
+
acc[method] = listener;
|
1128
|
+
return acc;
|
1129
|
+
},
|
1130
|
+
{}
|
1131
|
+
);
|
1132
|
+
}
|
1133
|
+
return getWebExportsHandler(handler, HTTP_METHODS);
|
1128
1134
|
}
|
1129
1135
|
return async (req, res) => {
|
1130
1136
|
if (options.shouldAddHelpers && typeof listener.listen !== "function") {
|
@@ -1206,23 +1212,26 @@ async function createEventHandler(entrypoint2, config, options) {
|
|
1206
1212
|
sourceFile: entrypoint2,
|
1207
1213
|
config
|
1208
1214
|
});
|
1209
|
-
|
1215
|
+
const isMiddleware = config.middleware === true;
|
1216
|
+
const useEdgeRuntime = isMiddleware && !runtime || isEdgeRuntime(runtime);
|
1217
|
+
if (useEdgeRuntime) {
|
1210
1218
|
return createEdgeEventHandler(
|
1211
1219
|
entrypointPath,
|
1212
1220
|
entrypoint2,
|
1213
|
-
|
1221
|
+
isMiddleware,
|
1214
1222
|
config.zeroConfig,
|
1215
1223
|
maxDuration
|
1216
1224
|
);
|
1217
1225
|
}
|
1218
1226
|
const content = await readFile(entrypointPath, "utf8");
|
1219
|
-
const isStreaming = staticConfig?.supportsResponseStreaming || await hasWebHandlers(async () => parseCjs(content).exports) || await hasWebHandlers(
|
1227
|
+
const isStreaming = staticConfig?.supportsResponseStreaming || isMiddleware || await hasWebHandlers(async () => parseCjs(content).exports) || await hasWebHandlers(
|
1220
1228
|
async () => init.then(() => parseEsm(content)[1].map((specifier) => specifier.n))
|
1221
1229
|
);
|
1222
1230
|
return createServerlessEventHandler(entrypointPath, {
|
1223
1231
|
mode: isStreaming ? "streaming" : "buffer",
|
1224
|
-
shouldAddHelpers: options.shouldAddHelpers,
|
1225
|
-
maxDuration
|
1232
|
+
shouldAddHelpers: isMiddleware ? false : options.shouldAddHelpers,
|
1233
|
+
maxDuration,
|
1234
|
+
isMiddleware
|
1226
1235
|
});
|
1227
1236
|
}
|
1228
1237
|
async function hasWebHandlers(getExports) {
|
package/dist/index.js
CHANGED
@@ -69741,14 +69741,9 @@ var EdgeRuntimes = /* @__PURE__ */ ((EdgeRuntimes2) => {
|
|
69741
69741
|
function isEdgeRuntime(runtime) {
|
69742
69742
|
return runtime !== void 0 && Object.values(EdgeRuntimes).includes(runtime);
|
69743
69743
|
}
|
69744
|
-
var ALLOWED_RUNTIMES = Object.values(EdgeRuntimes);
|
69744
|
+
var ALLOWED_RUNTIMES = [...Object.values(EdgeRuntimes), "nodejs"];
|
69745
69745
|
function validateConfiguredRuntime(runtime, entrypoint) {
|
69746
69746
|
if (runtime) {
|
69747
|
-
if (runtime === "nodejs") {
|
69748
|
-
throw new Error(
|
69749
|
-
`${entrypoint}: \`config.runtime: "nodejs"\` semantics will evolve soon. Please remove the \`runtime\` key to keep the existing behavior.`
|
69750
|
-
);
|
69751
|
-
}
|
69752
69747
|
if (!ALLOWED_RUNTIMES.includes(runtime)) {
|
69753
69748
|
throw new Error(
|
69754
69749
|
`${entrypoint}: unsupported "runtime" value in \`config\`: ${JSON.stringify(
|
@@ -70052,11 +70047,6 @@ var build = async ({
|
|
70052
70047
|
const handler = renameTStoJS((0, import_path3.relative)(baseDir, entrypointPath));
|
70053
70048
|
const outputPath = entrypointToOutputPath(entrypoint, config.zeroConfig);
|
70054
70049
|
if (isMiddleware) {
|
70055
|
-
if (!isEdgeFunction) {
|
70056
|
-
throw new Error(
|
70057
|
-
`Middleware file can not be a Node.js Serverless Function`
|
70058
|
-
);
|
70059
|
-
}
|
70060
70050
|
const src = getRegExpFromMatchers(staticConfig?.matcher);
|
70061
70051
|
const middlewareRawSrc = [];
|
70062
70052
|
if (staticConfig?.matcher) {
|
@@ -70091,7 +70081,8 @@ var build = async ({
|
|
70091
70081
|
handler,
|
70092
70082
|
architecture: staticConfig?.architecture,
|
70093
70083
|
runtime: nodeVersion.runtime,
|
70094
|
-
|
70084
|
+
useWebApi: isMiddleware,
|
70085
|
+
shouldAddHelpers: isMiddleware ? false : shouldAddHelpers,
|
70095
70086
|
shouldAddSourcemapSupport,
|
70096
70087
|
awsLambdaHandler,
|
70097
70088
|
supportsResponseStreaming,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/node",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.3.0",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"main": "./dist/index",
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
|
@@ -17,7 +17,7 @@
|
|
17
17
|
"@edge-runtime/primitives": "4.1.0",
|
18
18
|
"@edge-runtime/vm": "3.2.0",
|
19
19
|
"@types/node": "16.18.11",
|
20
|
-
"@vercel/build-utils": "10.6.
|
20
|
+
"@vercel/build-utils": "10.6.1",
|
21
21
|
"@vercel/error-utils": "2.0.3",
|
22
22
|
"@vercel/nft": "0.29.2",
|
23
23
|
"@vercel/static-config": "3.1.1",
|
@@ -57,7 +57,7 @@
|
|
57
57
|
"tree-kill": "1.2.2",
|
58
58
|
"vite": "^5.1.6",
|
59
59
|
"vitest": "^2.0.1",
|
60
|
-
"@vercel/functions": "2.
|
60
|
+
"@vercel/functions": "2.2.2"
|
61
61
|
},
|
62
62
|
"scripts": {
|
63
63
|
"build": "node build.mjs",
|