@vercel/node 2.4.1-canary.0 → 2.4.3

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.
@@ -168,7 +168,7 @@ async function compileUserCode(entrypoint) {
168
168
 
169
169
  let edgeHandler = module.exports.default;
170
170
  if (!edgeHandler) {
171
- throw new Error('No default export was found. Add a default export to handle requests.');
171
+ throw new Error('No default export was found. Add a default export to handle requests. Learn more: https://vercel.link/creating-edge-middleware');
172
172
  }
173
173
 
174
174
  let response = await edgeHandler(event.request, event);
@@ -261,7 +261,7 @@ function parseRuntime(entrypoint, entryPointPath) {
261
261
  const staticConfig = static_config_1.getConfig(project, entryPointPath);
262
262
  const runtime = staticConfig?.runtime;
263
263
  if (runtime && !validRuntimes.includes(runtime)) {
264
- throw new Error(`Invalid function runtime "${runtime}" for "${entrypoint}". Valid runtimes are: ${JSON.stringify(validRuntimes)}`);
264
+ throw new Error(`Invalid function runtime "${runtime}" for "${entrypoint}". Valid runtimes are: ${JSON.stringify(validRuntimes)}. Learn more: https://vercel.link/creating-edge-functions`);
265
265
  }
266
266
  return runtime;
267
267
  }
package/dist/index.js CHANGED
@@ -304748,9 +304748,7 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
304748
304748
  let routes;
304749
304749
  let output;
304750
304750
  const handler = renameTStoJS(path_1.relative(baseDir, entrypointPath));
304751
- const outputName = config.zeroConfig
304752
- ? handler.substring(0, handler.length - 3)
304753
- : handler;
304751
+ const outputPath = utils_1.entrypointToOutputPath(entrypoint, config.zeroConfig);
304754
304752
  const isMiddleware = config.middleware === true;
304755
304753
  // Will output an `EdgeFunction` for when `config.middleware = true`
304756
304754
  // (i.e. for root-level "middleware" file) or if source code contains:
@@ -304775,9 +304773,7 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
304775
304773
  routes = [
304776
304774
  {
304777
304775
  src,
304778
- middlewarePath: config.zeroConfig
304779
- ? outputName
304780
- : path_1.relative(baseDir, entrypointPath),
304776
+ middlewarePath: outputPath,
304781
304777
  continue: true,
304782
304778
  override: true,
304783
304779
  },
@@ -304788,7 +304784,7 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
304788
304784
  entrypoint: handler,
304789
304785
  files: preparedFiles,
304790
304786
  // TODO: remove - these two properties should not be required
304791
- name: outputName,
304787
+ name: outputPath,
304792
304788
  deploymentTarget: 'v8-worker',
304793
304789
  });
304794
304790
  }
@@ -305311,7 +305307,8 @@ function filterDiagnostics(diagnostics, ignore) {
305311
305307
  "use strict";
305312
305308
 
305313
305309
  Object.defineProperty(exports, "__esModule", ({ value: true }));
305314
- exports.getRegExpFromMatchers = void 0;
305310
+ exports.entrypointToOutputPath = exports.getRegExpFromMatchers = void 0;
305311
+ const path_1 = __webpack_require__(85622);
305315
305312
  const path_to_regexp_1 = __webpack_require__(91786);
305316
305313
  function getRegExpFromMatchers(matcherOrMatchers) {
305317
305314
  if (!matcherOrMatchers) {
@@ -305333,6 +305330,23 @@ function getRegExpFromMatcher(matcher) {
305333
305330
  const re = path_to_regexp_1.pathToRegexp(matcher);
305334
305331
  return re.source;
305335
305332
  }
305333
+ /**
305334
+ * If `zeroConfig`:
305335
+ * "api/foo.js" -> "api/foo.js"
305336
+ * "api/foo.ts" -> "api/foo.ts"
305337
+ *
305338
+ * If *NOT* `zeroConfig`:
305339
+ * "api/foo.js" -> "api/foo"
305340
+ * "api/foo.ts" -> "api/foo"
305341
+ */
305342
+ function entrypointToOutputPath(entrypoint, zeroConfig) {
305343
+ if (zeroConfig) {
305344
+ const ext = path_1.extname(entrypoint);
305345
+ return entrypoint.slice(0, entrypoint.length - ext.length);
305346
+ }
305347
+ return entrypoint;
305348
+ }
305349
+ exports.entrypointToOutputPath = entrypointToOutputPath;
305336
305350
 
305337
305351
 
305338
305352
  /***/ }),
package/dist/utils.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRegExpFromMatchers = void 0;
3
+ exports.entrypointToOutputPath = exports.getRegExpFromMatchers = void 0;
4
+ const path_1 = require("path");
4
5
  const path_to_regexp_1 = require("path-to-regexp");
5
6
  function getRegExpFromMatchers(matcherOrMatchers) {
6
7
  if (!matcherOrMatchers) {
@@ -22,3 +23,20 @@ function getRegExpFromMatcher(matcher) {
22
23
  const re = path_to_regexp_1.pathToRegexp(matcher);
23
24
  return re.source;
24
25
  }
26
+ /**
27
+ * If `zeroConfig`:
28
+ * "api/foo.js" -> "api/foo.js"
29
+ * "api/foo.ts" -> "api/foo.ts"
30
+ *
31
+ * If *NOT* `zeroConfig`:
32
+ * "api/foo.js" -> "api/foo"
33
+ * "api/foo.ts" -> "api/foo"
34
+ */
35
+ function entrypointToOutputPath(entrypoint, zeroConfig) {
36
+ if (zeroConfig) {
37
+ const ext = path_1.extname(entrypoint);
38
+ return entrypoint.slice(0, entrypoint.length - ext.length);
39
+ }
40
+ return entrypoint;
41
+ }
42
+ exports.entrypointToOutputPath = entrypointToOutputPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/node",
3
- "version": "2.4.1-canary.0",
3
+ "version": "2.4.3",
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-integration-once": "yarn test test/integration.test.js",
15
15
  "test": "jest --env node --verbose --bail --runInBand",
16
- "test-unit": "yarn test test/prepare-cache.test.ts",
16
+ "test-unit": "yarn test test/prepare-cache.test.ts test/utils.test.ts",
17
17
  "prepublishOnly": "node build"
18
18
  },
19
19
  "files": [
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@types/node": "*",
34
- "@vercel/build-utils": "5.0.1-canary.0",
34
+ "@vercel/build-utils": "5.0.2",
35
35
  "@vercel/node-bridge": "3.0.0",
36
36
  "@vercel/static-config": "2.0.1",
37
37
  "edge-runtime": "1.0.1",
@@ -61,5 +61,5 @@
61
61
  "source-map-support": "0.5.12",
62
62
  "test-listen": "1.1.0"
63
63
  },
64
- "gitHead": "3c48b40b43e3357c4c06bfe05e1192b1434b691f"
64
+ "gitHead": "d2f8d178f77e15cb490cce73f5766537d892f763"
65
65
  }