@vercel/node 2.9.3 → 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.
@@ -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(entrypointFullPath: string, entrypointRelativePath: string, isMiddleware: boolean): Promise<(request: IncomingMessage) => Promise<VercelProxyResponse>>;
4
+ export declare function createEdgeEventHandler(entrypointFullPath: string, entrypointRelativePath: string, isMiddleware: boolean, isZeroConfig?: boolean): Promise<(request: IncomingMessage) => Promise<VercelProxyResponse>>;
@@ -110,7 +110,7 @@ async function createEdgeRuntime(params) {
110
110
  return undefined;
111
111
  }
112
112
  }
113
- async function createEdgeEventHandler(entrypointFullPath, entrypointRelativePath, isMiddleware) {
113
+ async function createEdgeEventHandler(entrypointFullPath, entrypointRelativePath, isMiddleware, isZeroConfig) {
114
114
  const userCode = await compileUserCode(entrypointFullPath, entrypointRelativePath, isMiddleware);
115
115
  const server = await createEdgeRuntime(userCode);
116
116
  return async function (request) {
@@ -131,8 +131,8 @@ async function createEdgeEventHandler(entrypointFullPath, entrypointRelativePath
131
131
  // We can't currently get a real stack trace from the Edge Function error,
132
132
  // but we can fake a basic one that is still usefult to the user.
133
133
  const fakeStackTrace = ` at (${entrypointRelativePath})`;
134
- const urlPath = extractUrlPath(entrypointRelativePath);
135
- console.log(`Error from API Route ${urlPath}: ${body}\n${fakeStackTrace}`);
134
+ const requestPath = entrypointToRequestPath(entrypointRelativePath, isZeroConfig);
135
+ console.log(`Error from API Route ${requestPath}: ${body}\n${fakeStackTrace}`);
136
136
  // this matches the serverless function bridge launcher's behavior when
137
137
  // an error is thrown in the function
138
138
  process.exit(1);
@@ -146,12 +146,8 @@ async function createEdgeEventHandler(entrypointFullPath, entrypointRelativePath
146
146
  };
147
147
  }
148
148
  exports.createEdgeEventHandler = createEdgeEventHandler;
149
- // turns "api/some.func.js" into "api/some.func"
150
- function extractUrlPath(entrypointRelativePath) {
151
- const parts = entrypointRelativePath.split('.');
152
- if (parts.length === 1) {
153
- return entrypointRelativePath;
154
- }
155
- parts.pop();
156
- return parts.join('.');
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);
157
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/node",
3
- "version": "2.9.3",
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-integration-once": "pnpm test test/integration-*.test.js"
16
+ "test-e2e": "pnpm test test/integration-*.test.js"
17
17
  },
18
18
  "files": [
19
19
  "dist"
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "@edge-runtime/vm": "2.0.0",
33
33
  "@types/node": "14.18.33",
34
- "@vercel/build-utils": "6.2.2",
34
+ "@vercel/build-utils": "6.2.3",
35
35
  "@vercel/node-bridge": "3.1.11",
36
36
  "@vercel/static-config": "2.0.12",
37
37
  "edge-runtime": "2.0.0",
@@ -64,5 +64,5 @@
64
64
  "test-listen": "1.1.0",
65
65
  "ts-morph": "12.0.0"
66
66
  },
67
- "gitHead": "95a4dcfb33d813f1a0ef18d766232d42c876ce69"
67
+ "gitHead": "881e43a0e2d6daa2f7654ad16566960b00d412aa"
68
68
  }