@vercel/node 2.4.4 → 2.4.5
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 -9
- package/package.json +4 -4
package/dist/dev-server.js
CHANGED
@@ -126,20 +126,20 @@ async function serializeRequest(message) {
|
|
126
126
|
body,
|
127
127
|
});
|
128
128
|
}
|
129
|
-
async function compileUserCode(
|
129
|
+
async function compileUserCode(entrypointPath, entrypointLabel) {
|
130
130
|
try {
|
131
131
|
const result = await esbuild_1.default.build({
|
132
132
|
platform: 'node',
|
133
133
|
target: 'node14',
|
134
134
|
sourcemap: 'inline',
|
135
135
|
bundle: true,
|
136
|
-
entryPoints: [
|
136
|
+
entryPoints: [entrypointPath],
|
137
137
|
write: false,
|
138
138
|
format: 'cjs',
|
139
139
|
});
|
140
140
|
const compiledFile = result.outputFiles?.[0];
|
141
141
|
if (!compiledFile) {
|
142
|
-
throw new Error(`Compilation of ${
|
142
|
+
throw new Error(`Compilation of ${entrypointLabel} produced no output files.`);
|
143
143
|
}
|
144
144
|
const userCode = new util_1.TextDecoder().decode(compiledFile.contents);
|
145
145
|
return `
|
@@ -173,6 +173,10 @@ async function compileUserCode(entrypoint) {
|
|
173
173
|
|
174
174
|
let response = await edgeHandler(event.request, event);
|
175
175
|
|
176
|
+
if (!response) {
|
177
|
+
throw new Error('Edge Function "${entrypointLabel}" did not return a response.');
|
178
|
+
}
|
179
|
+
|
176
180
|
return event.respondWith(response);
|
177
181
|
} catch (error) {
|
178
182
|
// we can't easily show a meaningful stack trace
|
@@ -207,6 +211,9 @@ async function createEdgeRuntime(userCode) {
|
|
207
211
|
module: {
|
208
212
|
exports: {},
|
209
213
|
},
|
214
|
+
process: {
|
215
|
+
env: process.env,
|
216
|
+
},
|
210
217
|
});
|
211
218
|
return context;
|
212
219
|
},
|
@@ -223,8 +230,8 @@ async function createEdgeRuntime(userCode) {
|
|
223
230
|
return undefined;
|
224
231
|
}
|
225
232
|
}
|
226
|
-
async function createEdgeEventHandler(
|
227
|
-
const userCode = await compileUserCode(
|
233
|
+
async function createEdgeEventHandler(entrypointPath, entrypointLabel) {
|
234
|
+
const userCode = await compileUserCode(entrypointPath, entrypointLabel);
|
228
235
|
const server = await createEdgeRuntime(userCode);
|
229
236
|
return async function (request) {
|
230
237
|
if (!server) {
|
@@ -266,15 +273,15 @@ function parseRuntime(entrypoint, entryPointPath) {
|
|
266
273
|
return runtime;
|
267
274
|
}
|
268
275
|
async function createEventHandler(entrypoint, config, options) {
|
269
|
-
const
|
270
|
-
const runtime = parseRuntime(entrypoint,
|
276
|
+
const entrypointPath = path_1.join(process.cwd(), entrypoint);
|
277
|
+
const runtime = parseRuntime(entrypoint, entrypointPath);
|
271
278
|
// `middleware.js`/`middleware.ts` file is always run as
|
272
279
|
// an Edge Function, otherwise needs to be opted-in via
|
273
280
|
// `export const config = { runtime: 'experimental-edge' }`
|
274
281
|
if (config.middleware === true || runtime === 'experimental-edge') {
|
275
|
-
return createEdgeEventHandler(
|
282
|
+
return createEdgeEventHandler(entrypointPath, entrypoint);
|
276
283
|
}
|
277
|
-
return createServerlessEventHandler(
|
284
|
+
return createServerlessEventHandler(entrypointPath, options);
|
278
285
|
}
|
279
286
|
let handleEvent;
|
280
287
|
let handlerEventError;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/node",
|
3
|
-
"version": "2.4.
|
3
|
+
"version": "2.4.5",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "./dist/index",
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
|
@@ -31,13 +31,13 @@
|
|
31
31
|
},
|
32
32
|
"dependencies": {
|
33
33
|
"@types/node": "*",
|
34
|
-
"@vercel/build-utils": "5.0.
|
34
|
+
"@vercel/build-utils": "5.0.4",
|
35
35
|
"@vercel/node-bridge": "3.0.0",
|
36
36
|
"@vercel/static-config": "2.0.1",
|
37
37
|
"edge-runtime": "1.0.1",
|
38
38
|
"esbuild": "0.14.47",
|
39
39
|
"exit-hook": "2.2.1",
|
40
|
-
"node-fetch": "2.6.
|
40
|
+
"node-fetch": "2.6.7",
|
41
41
|
"ts-node": "8.9.1",
|
42
42
|
"typescript": "4.3.4"
|
43
43
|
},
|
@@ -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": "3d3774ee7e3d344b3292d2166d485bdf41a68d4c"
|
65
65
|
}
|