@vercel/node 2.7.1 → 2.8.0

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.
@@ -71,13 +71,12 @@ function listen(server, port, host) {
71
71
  });
72
72
  });
73
73
  }
74
- const validRuntimes = ['experimental-edge'];
75
74
  function parseRuntime(entrypoint, entryPointPath) {
76
75
  const project = new ts_morph_1.Project();
77
76
  const staticConfig = static_config_1.getConfig(project, entryPointPath);
78
77
  const runtime = staticConfig?.runtime;
79
- if (runtime && !validRuntimes.includes(runtime)) {
80
- throw new Error(`Invalid function runtime "${runtime}" for "${entrypoint}". Valid runtimes are: ${JSON.stringify(validRuntimes)}. Learn more: https://vercel.link/creating-edge-functions`);
78
+ if (runtime && !utils_1.isEdgeRuntime(runtime)) {
79
+ throw new Error(`Invalid function runtime "${runtime}" for "${entrypoint}". Valid runtimes are: ${JSON.stringify(Object.values(utils_1.EdgeRuntimes))}. Learn more: https://vercel.link/creating-edge-functions`);
81
80
  }
82
81
  return runtime;
83
82
  }
@@ -86,8 +85,8 @@ async function createEventHandler(entrypoint, config, options) {
86
85
  const runtime = parseRuntime(entrypoint, entrypointPath);
87
86
  // `middleware.js`/`middleware.ts` file is always run as
88
87
  // an Edge Function, otherwise needs to be opted-in via
89
- // `export const config = { runtime: 'experimental-edge' }`
90
- if (config.middleware === true || runtime === 'experimental-edge') {
88
+ // `export const config = { runtime: 'edge' }`
89
+ if (config.middleware === true || utils_1.isEdgeRuntime(runtime)) {
91
90
  return edge_handler_1.createEdgeEventHandler(entrypointPath, entrypoint, config.middleware || false);
92
91
  }
93
92
  return serverless_handler_1.createServerlessEventHandler(entrypointPath, {
package/dist/index.js CHANGED
@@ -304740,7 +304740,7 @@ const utils_1 = __webpack_require__(84411);
304740
304740
  function isPortInfo(v) {
304741
304741
  return v && typeof v.port === 'number';
304742
304742
  }
304743
- const ALLOWED_RUNTIMES = ['nodejs', 'experimental-edge'];
304743
+ const ALLOWED_RUNTIMES = ['nodejs', ...Object.values(utils_1.EdgeRuntimes)];
304744
304744
  const require_ = eval('require');
304745
304745
  const tscPath = path_1.resolve(path_1.dirname(require_.resolve('typescript')), '../bin/tsc');
304746
304746
  // eslint-disable-next-line no-useless-escape
@@ -304975,7 +304975,7 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
304975
304975
  const isMiddleware = config.middleware === true;
304976
304976
  // Will output an `EdgeFunction` for when `config.middleware = true`
304977
304977
  // (i.e. for root-level "middleware" file) or if source code contains:
304978
- // `export const config = { runtime: 'experimental-edge' }`
304978
+ // `export const config = { runtime: 'edge' }`
304979
304979
  let isEdgeFunction = isMiddleware;
304980
304980
  const project = new ts_morph_1.Project();
304981
304981
  const staticConfig = static_config_1.getConfig(project, entrypointPath);
@@ -304983,7 +304983,7 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
304983
304983
  if (!ALLOWED_RUNTIMES.includes(staticConfig.runtime)) {
304984
304984
  throw new Error(`Unsupported "runtime" property in \`config\`: ${JSON.stringify(staticConfig.runtime)} (must be one of: ${JSON.stringify(ALLOWED_RUNTIMES)})`);
304985
304985
  }
304986
- isEdgeFunction = staticConfig.runtime === 'experimental-edge';
304986
+ isEdgeFunction = utils_1.isEdgeRuntime(staticConfig.runtime);
304987
304987
  }
304988
304988
  build_utils_1.debug('Tracing input files...');
304989
304989
  const traceTime = Date.now();
@@ -305555,7 +305555,7 @@ function filterDiagnostics(diagnostics, ignore) {
305555
305555
  "use strict";
305556
305556
 
305557
305557
  Object.defineProperty(exports, "__esModule", ({ value: true }));
305558
- exports.logError = exports.entrypointToOutputPath = exports.getRegExpFromMatchers = void 0;
305558
+ exports.isEdgeRuntime = exports.EdgeRuntimes = exports.logError = exports.entrypointToOutputPath = exports.getRegExpFromMatchers = void 0;
305559
305559
  const path_1 = __webpack_require__(85622);
305560
305560
  const path_to_regexp_1 = __webpack_require__(91786);
305561
305561
  const build_utils_1 = __webpack_require__(63445);
@@ -305611,6 +305611,16 @@ function logError(error) {
305611
305611
  }
305612
305612
  }
305613
305613
  exports.logError = logError;
305614
+ var EdgeRuntimes;
305615
+ (function (EdgeRuntimes) {
305616
+ EdgeRuntimes["Edge"] = "edge";
305617
+ EdgeRuntimes["ExperimentalEdge"] = "experimental-edge";
305618
+ })(EdgeRuntimes = exports.EdgeRuntimes || (exports.EdgeRuntimes = {}));
305619
+ function isEdgeRuntime(runtime) {
305620
+ return (runtime !== undefined &&
305621
+ Object.values(EdgeRuntimes).includes(runtime));
305622
+ }
305623
+ exports.isEdgeRuntime = isEdgeRuntime;
305614
305624
 
305615
305625
 
305616
305626
  /***/ }),
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logError = exports.entrypointToOutputPath = exports.getRegExpFromMatchers = void 0;
3
+ exports.isEdgeRuntime = exports.EdgeRuntimes = exports.logError = exports.entrypointToOutputPath = exports.getRegExpFromMatchers = void 0;
4
4
  const path_1 = require("path");
5
5
  const path_to_regexp_1 = require("path-to-regexp");
6
6
  const build_utils_1 = require("@vercel/build-utils");
@@ -56,3 +56,13 @@ function logError(error) {
56
56
  }
57
57
  }
58
58
  exports.logError = logError;
59
+ var EdgeRuntimes;
60
+ (function (EdgeRuntimes) {
61
+ EdgeRuntimes["Edge"] = "edge";
62
+ EdgeRuntimes["ExperimentalEdge"] = "experimental-edge";
63
+ })(EdgeRuntimes = exports.EdgeRuntimes || (exports.EdgeRuntimes = {}));
64
+ function isEdgeRuntime(runtime) {
65
+ return (runtime !== undefined &&
66
+ Object.values(EdgeRuntimes).includes(runtime));
67
+ }
68
+ exports.isEdgeRuntime = isEdgeRuntime;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/node",
3
- "version": "2.7.1",
3
+ "version": "2.8.0",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
@@ -61,5 +61,5 @@
61
61
  "source-map-support": "0.5.12",
62
62
  "test-listen": "1.1.0"
63
63
  },
64
- "gitHead": "b37ac5f798acbfb8f04e047301766440ad0d4c59"
64
+ "gitHead": "584d0ea8535f1fad5588a4dc51269d4985a32875"
65
65
  }