@vercel/node 5.8.27 → 5.9.1

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.
Files changed (2) hide show
  1. package/dist/index.js +47 -8
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -72281,6 +72281,14 @@ function getRegExpFromMatchers(matcherOrMatchers) {
72281
72281
  const regExps = matchers.flatMap(getRegExpFromMatcher).join("|");
72282
72282
  return regExps;
72283
72283
  }
72284
+ function resolveMiddlewareMatcher(configuredMatcher, sourceMatcher, entrypoint) {
72285
+ if (configuredMatcher !== void 0 && sourceMatcher !== void 0) {
72286
+ throw new Error(
72287
+ `${entrypoint}: \`proxy.matcher\` in vercel.json conflicts with \`config.matcher\` exported from the proxy entrypoint. Configure the matcher in only one location.`
72288
+ );
72289
+ }
72290
+ return configuredMatcher ?? sourceMatcher;
72291
+ }
72284
72292
  function getRegExpFromMatcher(matcher, index, allMatchers) {
72285
72293
  if (typeof matcher !== "string") {
72286
72294
  throw new Error(
@@ -72327,6 +72335,14 @@ function validateConfiguredRuntime(runtime, entrypoint) {
72327
72335
  }
72328
72336
  }
72329
72337
  }
72338
+ function validateMiddlewareRuntime(runtime, entrypoint, requiredRuntime) {
72339
+ validateConfiguredRuntime(runtime, entrypoint);
72340
+ if (requiredRuntime === "nodejs" && isEdgeRuntime(runtime)) {
72341
+ throw new Error(
72342
+ `${entrypoint}: explicit proxy entrypoints only support the Node.js runtime. Remove \`runtime: ${JSON.stringify(runtime)}\` from the exported \`config\`.`
72343
+ );
72344
+ }
72345
+ }
72330
72346
 
72331
72347
  // src/build.ts
72332
72348
  var require_2 = (0, import_module2.createRequire)(__filename);
@@ -72691,8 +72707,14 @@ var build = async ({
72691
72707
  const project = new import_ts_morph.Project();
72692
72708
  const staticConfig = (0, import_static_config.getConfig)(project, entrypointPath);
72693
72709
  const runtime = staticConfig?.runtime;
72694
- validateConfiguredRuntime(runtime, entrypoint);
72695
- if (runtime) {
72710
+ validateMiddlewareRuntime(
72711
+ runtime,
72712
+ entrypoint,
72713
+ isMiddleware ? config.middlewareRuntime : void 0
72714
+ );
72715
+ if (isMiddleware && config.middlewareRuntime === "nodejs") {
72716
+ isEdgeFunction = false;
72717
+ } else if (runtime) {
72696
72718
  isEdgeFunction = isEdgeRuntime(runtime);
72697
72719
  }
72698
72720
  checks({
@@ -72716,13 +72738,18 @@ var build = async ({
72716
72738
  let handler = renameTStoJS((0, import_path3.relative)(baseDir, entrypointPath));
72717
72739
  const outputPath = entrypointToOutputPath(entrypoint, config.zeroConfig);
72718
72740
  if (isMiddleware) {
72719
- const src = getRegExpFromMatchers(staticConfig?.matcher);
72741
+ const matcher = resolveMiddlewareMatcher(
72742
+ config.middlewareMatcher,
72743
+ staticConfig?.matcher,
72744
+ entrypoint
72745
+ );
72746
+ const src = getRegExpFromMatchers(matcher);
72720
72747
  const middlewareRawSrc = [];
72721
- if (staticConfig?.matcher) {
72722
- if (Array.isArray(staticConfig.matcher)) {
72723
- middlewareRawSrc.push(...staticConfig.matcher);
72748
+ if (matcher) {
72749
+ if (Array.isArray(matcher)) {
72750
+ middlewareRawSrc.push(...matcher);
72724
72751
  } else {
72725
- middlewareRawSrc.push(staticConfig.matcher);
72752
+ middlewareRawSrc.push(matcher);
72726
72753
  }
72727
72754
  }
72728
72755
  routes = [
@@ -73124,6 +73151,13 @@ var startDevServer = async (opts) => {
73124
73151
  }
73125
73152
  const project = new import_ts_morph2.Project();
73126
73153
  const staticConfig = (0, import_static_config2.getConfig)(project, entrypointPath);
73154
+ if (config.middlewareRuntime) {
73155
+ validateMiddlewareRuntime(
73156
+ staticConfig?.runtime,
73157
+ entrypoint,
73158
+ config.middlewareRuntime
73159
+ );
73160
+ }
73127
73161
  const vercelConfigFile = opts.files["vercel.json"];
73128
73162
  let bunVersion;
73129
73163
  try {
@@ -73146,7 +73180,12 @@ var startDevServer = async (opts) => {
73146
73180
  }
73147
73181
  const runtime = bunVersion ? "bun" : "node";
73148
73182
  if (config.middleware === true && typeof meta.requestUrl === "string") {
73149
- const matchers = new RegExp(getRegExpFromMatchers(staticConfig?.matcher));
73183
+ const matcher = resolveMiddlewareMatcher(
73184
+ config.middlewareMatcher,
73185
+ staticConfig?.matcher,
73186
+ entrypoint
73187
+ );
73188
+ const matchers = new RegExp(getRegExpFromMatchers(matcher));
73150
73189
  const parsed = new URL(meta.requestUrl, "http://localhost");
73151
73190
  if (!matchers.test(parsed.pathname)) {
73152
73191
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/node",
3
- "version": "5.8.27",
3
+ "version": "5.9.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
@@ -32,8 +32,8 @@
32
32
  "tsx": "4.21.0",
33
33
  "typescript": "npm:typescript@5.9.3",
34
34
  "undici": "5.28.4",
35
+ "@vercel/build-utils": "13.36.1",
35
36
  "@vercel/error-utils": "2.2.0",
36
- "@vercel/build-utils": "13.35.0",
37
37
  "@vercel/static-config": "3.4.0"
38
38
  },
39
39
  "devDependencies": {