@vercel/node 2.9.2 → 2.9.4
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
CHANGED
@@ -39,7 +39,7 @@ async function createEventHandler(entrypoint, config, options) {
|
|
39
39
|
// an Edge Function, otherwise needs to be opted-in via
|
40
40
|
// `export const config = { runtime: 'edge' }`
|
41
41
|
if (config.middleware === true || utils_1.isEdgeRuntime(runtime)) {
|
42
|
-
return edge_handler_1.createEdgeEventHandler(entrypointPath, entrypoint, config.middleware || false);
|
42
|
+
return edge_handler_1.createEdgeEventHandler(entrypointPath, entrypoint, config.middleware || false, config.zeroConfig);
|
43
43
|
}
|
44
44
|
return serverless_handler_1.createServerlessEventHandler(entrypointPath, {
|
45
45
|
shouldAddHelpers: options.shouldAddHelpers,
|
@@ -1,4 +1,4 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
import { IncomingMessage } from 'http';
|
3
3
|
import { VercelProxyResponse } from '@vercel/node-bridge/types';
|
4
|
-
export declare function createEdgeEventHandler(
|
4
|
+
export declare function createEdgeEventHandler(entrypointFullPath: string, entrypointRelativePath: string, isMiddleware: boolean, isZeroConfig?: boolean): Promise<(request: IncomingMessage) => Promise<VercelProxyResponse>>;
|
@@ -28,7 +28,7 @@ async function serializeRequest(message) {
|
|
28
28
|
body,
|
29
29
|
});
|
30
30
|
}
|
31
|
-
async function compileUserCode(
|
31
|
+
async function compileUserCode(entrypointFullPath, entrypointRelativePath, isMiddleware) {
|
32
32
|
const { wasmAssets, plugin: edgeWasmPlugin } = edge_wasm_plugin_1.createEdgeWasmPlugin();
|
33
33
|
try {
|
34
34
|
const result = await esbuild_1.default.build({
|
@@ -42,13 +42,13 @@ async function compileUserCode(entrypointPath, entrypointLabel, isMiddleware) {
|
|
42
42
|
legalComments: 'none',
|
43
43
|
bundle: true,
|
44
44
|
plugins: [edgeWasmPlugin],
|
45
|
-
entryPoints: [
|
45
|
+
entryPoints: [entrypointFullPath],
|
46
46
|
write: false,
|
47
47
|
format: 'cjs',
|
48
48
|
});
|
49
49
|
const compiledFile = result.outputFiles?.[0];
|
50
50
|
if (!compiledFile) {
|
51
|
-
throw new Error(`Compilation of ${
|
51
|
+
throw new Error(`Compilation of ${entrypointRelativePath} produced no output files.`);
|
52
52
|
}
|
53
53
|
const userCode = `
|
54
54
|
// strict mode
|
@@ -59,7 +59,7 @@ async function compileUserCode(entrypointPath, entrypointLabel, isMiddleware) {
|
|
59
59
|
|
60
60
|
// request metadata
|
61
61
|
const IS_MIDDLEWARE = ${isMiddleware};
|
62
|
-
const ENTRYPOINT_LABEL = '${
|
62
|
+
const ENTRYPOINT_LABEL = '${entrypointRelativePath}';
|
63
63
|
|
64
64
|
// edge handler
|
65
65
|
${edgeHandlerTemplate}
|
@@ -110,8 +110,8 @@ async function createEdgeRuntime(params) {
|
|
110
110
|
return undefined;
|
111
111
|
}
|
112
112
|
}
|
113
|
-
async function createEdgeEventHandler(
|
114
|
-
const userCode = await compileUserCode(
|
113
|
+
async function createEdgeEventHandler(entrypointFullPath, entrypointRelativePath, isMiddleware, isZeroConfig) {
|
114
|
+
const userCode = await compileUserCode(entrypointFullPath, entrypointRelativePath, isMiddleware);
|
115
115
|
const server = await createEdgeRuntime(userCode);
|
116
116
|
return async function (request) {
|
117
117
|
if (!server) {
|
@@ -128,8 +128,11 @@ async function createEdgeEventHandler(entrypointPath, entrypointLabel, isMiddlew
|
|
128
128
|
const body = await response.text();
|
129
129
|
const isUserError = response.headers.get('x-vercel-failed') === 'edge-wrapper';
|
130
130
|
if (isUserError && response.status >= 500) {
|
131
|
-
//
|
132
|
-
|
131
|
+
// We can't currently get a real stack trace from the Edge Function error,
|
132
|
+
// but we can fake a basic one that is still usefult to the user.
|
133
|
+
const fakeStackTrace = ` at (${entrypointRelativePath})`;
|
134
|
+
const requestPath = entrypointToRequestPath(entrypointRelativePath, isZeroConfig);
|
135
|
+
console.log(`Error from API Route ${requestPath}: ${body}\n${fakeStackTrace}`);
|
133
136
|
// this matches the serverless function bridge launcher's behavior when
|
134
137
|
// an error is thrown in the function
|
135
138
|
process.exit(1);
|
@@ -143,3 +146,8 @@ async function createEdgeEventHandler(entrypointPath, entrypointLabel, isMiddlew
|
|
143
146
|
};
|
144
147
|
}
|
145
148
|
exports.createEdgeEventHandler = createEdgeEventHandler;
|
149
|
+
function entrypointToRequestPath(entrypointRelativePath, isZeroConfig) {
|
150
|
+
// ensure the path starts with a slash to match conventions used elsewhere,
|
151
|
+
// notably when rendering serverless function paths in error messages
|
152
|
+
return '/' + utils_1.entrypointToOutputPath(entrypointRelativePath, isZeroConfig);
|
153
|
+
}
|
package/dist/index.js
CHANGED
@@ -301059,11 +301059,13 @@ async function compile(workPath, baseDir, entrypointPath, config, nodeVersion, i
|
|
301059
301059
|
shouldAddSourcemapSupport = true;
|
301060
301060
|
return source;
|
301061
301061
|
}
|
301062
|
+
const conditions = isEdgeFunction ? ['worker', 'browser'] : undefined;
|
301062
301063
|
const { fileList, esmFileList, warnings } = await nft_1.nodeFileTrace([...inputFiles], {
|
301063
301064
|
base: baseDir,
|
301064
301065
|
processCwd: workPath,
|
301065
301066
|
ts: true,
|
301066
301067
|
mixedModules: true,
|
301068
|
+
conditions,
|
301067
301069
|
resolve(id, parent, job, cjsResolve) {
|
301068
301070
|
const normalizedWasmImports = id.replace(/\.wasm\?module$/i, '.wasm');
|
301069
301071
|
return resolve_dependency_1.default(normalizedWasmImports, parent, job, cjsResolve);
|
@@ -301632,21 +301634,17 @@ function register(opts = {}) {
|
|
301632
301634
|
getCurrentDirectory: () => cwd,
|
301633
301635
|
getCanonicalFileName: path => path,
|
301634
301636
|
};
|
301635
|
-
function createTSError(diagnostics) {
|
301636
|
-
const message = formatDiagnostics(diagnostics, diagnosticHost);
|
301637
|
-
return new build_utils_1.NowBuildError({ code: 'NODE_TYPESCRIPT_ERROR', message });
|
301638
|
-
}
|
301639
301637
|
function reportTSError(diagnostics, shouldExit) {
|
301640
301638
|
if (!diagnostics || diagnostics.length === 0) {
|
301641
301639
|
return;
|
301642
301640
|
}
|
301643
|
-
const
|
301641
|
+
const message = formatDiagnostics(diagnostics, diagnosticHost);
|
301644
301642
|
if (shouldExit) {
|
301645
|
-
throw
|
301643
|
+
throw new build_utils_1.NowBuildError({ code: 'NODE_TYPESCRIPT_ERROR', message });
|
301646
301644
|
}
|
301647
301645
|
else {
|
301648
301646
|
// Print error in red color and continue execution.
|
301649
|
-
console.error(
|
301647
|
+
console.error(message);
|
301650
301648
|
}
|
301651
301649
|
}
|
301652
301650
|
function getBuild(configFileName = '', skipTypeCheck) {
|
package/dist/typescript.js
CHANGED
@@ -123,21 +123,17 @@ function register(opts = {}) {
|
|
123
123
|
getCurrentDirectory: () => cwd,
|
124
124
|
getCanonicalFileName: path => path,
|
125
125
|
};
|
126
|
-
function createTSError(diagnostics) {
|
127
|
-
const message = formatDiagnostics(diagnostics, diagnosticHost);
|
128
|
-
return new build_utils_1.NowBuildError({ code: 'NODE_TYPESCRIPT_ERROR', message });
|
129
|
-
}
|
130
126
|
function reportTSError(diagnostics, shouldExit) {
|
131
127
|
if (!diagnostics || diagnostics.length === 0) {
|
132
128
|
return;
|
133
129
|
}
|
134
|
-
const
|
130
|
+
const message = formatDiagnostics(diagnostics, diagnosticHost);
|
135
131
|
if (shouldExit) {
|
136
|
-
throw
|
132
|
+
throw new build_utils_1.NowBuildError({ code: 'NODE_TYPESCRIPT_ERROR', message });
|
137
133
|
}
|
138
134
|
else {
|
139
135
|
// Print error in red color and continue execution.
|
140
|
-
console.error(
|
136
|
+
console.error(message);
|
141
137
|
}
|
142
138
|
}
|
143
139
|
function getBuild(configFileName = '', skipTypeCheck) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/node",
|
3
|
-
"version": "2.9.
|
3
|
+
"version": "2.9.4",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "./dist/index",
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
"build": "node build",
|
14
14
|
"test": "jest --env node --verbose --bail --runInBand",
|
15
15
|
"test-unit": "pnpm test test/prepare-cache.test.ts test/utils.test.ts",
|
16
|
-
"test-
|
16
|
+
"test-e2e": "pnpm test test/integration-*.test.js"
|
17
17
|
},
|
18
18
|
"files": [
|
19
19
|
"dist"
|
@@ -31,8 +31,8 @@
|
|
31
31
|
"dependencies": {
|
32
32
|
"@edge-runtime/vm": "2.0.0",
|
33
33
|
"@types/node": "14.18.33",
|
34
|
-
"@vercel/build-utils": "6.2.
|
35
|
-
"@vercel/node-bridge": "3.1.
|
34
|
+
"@vercel/build-utils": "6.2.3",
|
35
|
+
"@vercel/node-bridge": "3.1.11",
|
36
36
|
"@vercel/static-config": "2.0.12",
|
37
37
|
"edge-runtime": "2.0.0",
|
38
38
|
"esbuild": "0.14.47",
|
@@ -64,5 +64,5 @@
|
|
64
64
|
"test-listen": "1.1.0",
|
65
65
|
"ts-morph": "12.0.0"
|
66
66
|
},
|
67
|
-
"gitHead": "
|
67
|
+
"gitHead": "881e43a0e2d6daa2f7654ad16566960b00d412aa"
|
68
68
|
}
|