@vercel/node 2.5.13 → 2.5.14
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.js +16 -5
- package/package.json +5 -5
package/dist/dev-server.js
CHANGED
@@ -126,7 +126,7 @@ async function serializeRequest(message) {
|
|
126
126
|
body,
|
127
127
|
});
|
128
128
|
}
|
129
|
-
async function compileUserCode(entrypointPath, entrypointLabel) {
|
129
|
+
async function compileUserCode(entrypointPath, entrypointLabel, isMiddleware) {
|
130
130
|
const { wasmAssets, plugin: edgeWasmPlugin } = edge_wasm_plugin_1.createEdgeWasmPlugin();
|
131
131
|
try {
|
132
132
|
const result = await esbuild_1.default.build({
|
@@ -146,6 +146,8 @@ async function compileUserCode(entrypointPath, entrypointLabel) {
|
|
146
146
|
const userCode = `
|
147
147
|
${compiledFile.text};
|
148
148
|
|
149
|
+
const isMiddleware = ${isMiddleware};
|
150
|
+
|
149
151
|
addEventListener('fetch', async (event) => {
|
150
152
|
try {
|
151
153
|
let serializedRequest = await event.request.text();
|
@@ -175,7 +177,16 @@ async function compileUserCode(entrypointPath, entrypointLabel) {
|
|
175
177
|
let response = await edgeHandler(event.request, event);
|
176
178
|
|
177
179
|
if (!response) {
|
178
|
-
|
180
|
+
if (isMiddleware) {
|
181
|
+
// allow empty responses to pass through
|
182
|
+
response = new Response(null, {
|
183
|
+
headers: {
|
184
|
+
'x-middleware-next': '1',
|
185
|
+
},
|
186
|
+
});
|
187
|
+
} else {
|
188
|
+
throw new Error('Edge Function "${entrypointLabel}" did not return a response.');
|
189
|
+
}
|
179
190
|
}
|
180
191
|
|
181
192
|
return event.respondWith(response);
|
@@ -239,8 +250,8 @@ async function createEdgeRuntime(params) {
|
|
239
250
|
return undefined;
|
240
251
|
}
|
241
252
|
}
|
242
|
-
async function createEdgeEventHandler(entrypointPath, entrypointLabel) {
|
243
|
-
const userCode = await compileUserCode(entrypointPath, entrypointLabel);
|
253
|
+
async function createEdgeEventHandler(entrypointPath, entrypointLabel, isMiddleware) {
|
254
|
+
const userCode = await compileUserCode(entrypointPath, entrypointLabel, isMiddleware);
|
244
255
|
const server = await createEdgeRuntime(userCode);
|
245
256
|
return async function (request) {
|
246
257
|
if (!server) {
|
@@ -288,7 +299,7 @@ async function createEventHandler(entrypoint, config, options) {
|
|
288
299
|
// an Edge Function, otherwise needs to be opted-in via
|
289
300
|
// `export const config = { runtime: 'experimental-edge' }`
|
290
301
|
if (config.middleware === true || runtime === 'experimental-edge') {
|
291
|
-
return createEdgeEventHandler(entrypointPath, entrypoint);
|
302
|
+
return createEdgeEventHandler(entrypointPath, entrypoint, config.middleware || false);
|
292
303
|
}
|
293
304
|
return createServerlessEventHandler(entrypointPath, options);
|
294
305
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/node",
|
3
|
-
"version": "2.5.
|
3
|
+
"version": "2.5.14",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "./dist/index",
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
|
@@ -29,12 +29,12 @@
|
|
29
29
|
}
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
-
"@edge-runtime/vm": "1.1.0-beta.
|
32
|
+
"@edge-runtime/vm": "1.1.0-beta.32",
|
33
33
|
"@types/node": "*",
|
34
|
-
"@vercel/build-utils": "5.4.
|
34
|
+
"@vercel/build-utils": "5.4.2",
|
35
35
|
"@vercel/node-bridge": "3.0.0",
|
36
36
|
"@vercel/static-config": "2.0.3",
|
37
|
-
"edge-runtime": "1.1.0-beta.
|
37
|
+
"edge-runtime": "1.1.0-beta.32",
|
38
38
|
"esbuild": "0.14.47",
|
39
39
|
"exit-hook": "2.2.1",
|
40
40
|
"node-fetch": "2.6.7",
|
@@ -61,5 +61,5 @@
|
|
61
61
|
"source-map-support": "0.5.12",
|
62
62
|
"test-listen": "1.1.0"
|
63
63
|
},
|
64
|
-
"gitHead": "
|
64
|
+
"gitHead": "d5537500d8957985c1ffb3798659a611cc2e5d5d"
|
65
65
|
}
|