@vercel/node 2.5.11 → 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 +20 -6
- package/dist/index.js +12 -11
- package/package.json +6 -6
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,14 +177,26 @@ 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);
|
182
193
|
} catch (error) {
|
183
194
|
// we can't easily show a meaningful stack trace
|
184
195
|
// so, stick to just the error message for now
|
185
|
-
|
196
|
+
const msg = error.cause
|
197
|
+
? (error.message + ': ' + (error.cause.message || error.cause))
|
198
|
+
: error.message;
|
199
|
+
event.respondWith(new Response(msg, {
|
186
200
|
status: 500,
|
187
201
|
headers: {
|
188
202
|
'x-vercel-failed': 'edge-wrapper'
|
@@ -236,8 +250,8 @@ async function createEdgeRuntime(params) {
|
|
236
250
|
return undefined;
|
237
251
|
}
|
238
252
|
}
|
239
|
-
async function createEdgeEventHandler(entrypointPath, entrypointLabel) {
|
240
|
-
const userCode = await compileUserCode(entrypointPath, entrypointLabel);
|
253
|
+
async function createEdgeEventHandler(entrypointPath, entrypointLabel, isMiddleware) {
|
254
|
+
const userCode = await compileUserCode(entrypointPath, entrypointLabel, isMiddleware);
|
241
255
|
const server = await createEdgeRuntime(userCode);
|
242
256
|
return async function (request) {
|
243
257
|
if (!server) {
|
@@ -285,7 +299,7 @@ async function createEventHandler(entrypoint, config, options) {
|
|
285
299
|
// an Edge Function, otherwise needs to be opted-in via
|
286
300
|
// `export const config = { runtime: 'experimental-edge' }`
|
287
301
|
if (config.middleware === true || runtime === 'experimental-edge') {
|
288
|
-
return createEdgeEventHandler(entrypointPath, entrypoint);
|
302
|
+
return createEdgeEventHandler(entrypointPath, entrypoint, config.middleware || false);
|
289
303
|
}
|
290
304
|
return createServerlessEventHandler(entrypointPath, options);
|
291
305
|
}
|
package/dist/index.js
CHANGED
@@ -227806,15 +227806,12 @@ class Job {
|
|
227806
227806
|
return;
|
227807
227807
|
if (path.endsWith('.node'))
|
227808
227808
|
return await sharedlib_emit_1.sharedLibEmit(path, this);
|
227809
|
-
|
227810
|
-
|
227811
|
-
|
227812
|
-
|
227813
|
-
|
227814
|
-
|
227815
|
-
}
|
227816
|
-
};
|
227817
|
-
await handlePjsonBoundary(path);
|
227809
|
+
// js files require the "type": "module" lookup, so always emit the package.json
|
227810
|
+
if (path.endsWith('.js')) {
|
227811
|
+
const pjsonBoundary = await this.getPjsonBoundary(path);
|
227812
|
+
if (pjsonBoundary)
|
227813
|
+
await this.emitFile(pjsonBoundary + path_1.sep + 'package.json', 'resolve', path);
|
227814
|
+
}
|
227818
227815
|
let analyzeResult;
|
227819
227816
|
const cachedAnalysis = this.analysisCache.get(path);
|
227820
227817
|
if (cachedAnalysis) {
|
@@ -227835,8 +227832,12 @@ class Job {
|
|
227835
227832
|
this.esmFileList.add(path_1.relative(this.base, path));
|
227836
227833
|
await Promise.all([
|
227837
227834
|
...[...assets].map(async (asset) => {
|
227838
|
-
|
227839
|
-
|
227835
|
+
const ext = path_1.extname(asset);
|
227836
|
+
if (ext === '.js' || ext === '.mjs' || ext === '.node' || ext === '' ||
|
227837
|
+
this.ts && (ext === '.ts' || ext === '.tsx') && asset.startsWith(this.base) && asset.slice(this.base.length).indexOf(path_1.sep + 'node_modules' + path_1.sep) === -1)
|
227838
|
+
await this.emitDependency(asset, path);
|
227839
|
+
else
|
227840
|
+
await this.emitFile(asset, 'asset', path);
|
227840
227841
|
}),
|
227841
227842
|
...[...deps].map(async (dep) => {
|
227842
227843
|
try {
|
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",
|
@@ -53,7 +53,7 @@
|
|
53
53
|
"@types/node-fetch": "^2.6.1",
|
54
54
|
"@types/test-listen": "1.1.0",
|
55
55
|
"@vercel/ncc": "0.24.0",
|
56
|
-
"@vercel/nft": "0.22.
|
56
|
+
"@vercel/nft": "0.22.1",
|
57
57
|
"content-type": "1.0.4",
|
58
58
|
"cookie": "0.4.0",
|
59
59
|
"etag": "1.8.1",
|
@@ -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
|
}
|