@vercel/next 4.3.18 → 4.3.20

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 +80 -53
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -426,7 +426,7 @@ var require_superstatic = __commonJS({
426
426
  collectHasSegments: () => collectHasSegments,
427
427
  convertCleanUrls: () => convertCleanUrls,
428
428
  convertHeaders: () => convertHeaders2,
429
- convertRedirects: () => convertRedirects2,
429
+ convertRedirects: () => convertRedirects3,
430
430
  convertRewrites: () => convertRewrites2,
431
431
  convertTrailingSlash: () => convertTrailingSlash,
432
432
  getCleanUrls: () => getCleanUrls,
@@ -460,7 +460,7 @@ var require_superstatic = __commonJS({
460
460
  }
461
461
  return routes;
462
462
  }
463
- function convertRedirects2(redirects, defaultStatus = 308) {
463
+ function convertRedirects3(redirects, defaultStatus = 308) {
464
464
  return redirects.map((r) => {
465
465
  const { src, segments } = sourceToRegex(r.source);
466
466
  const hasSegments = collectHasSegments(r.has);
@@ -10367,7 +10367,7 @@ __export(src_exports, {
10367
10367
  });
10368
10368
  module.exports = __toCommonJS(src_exports);
10369
10369
  var import_build_utils3 = require("@vercel/build-utils");
10370
- var import_superstatic = __toESM(require_superstatic());
10370
+ var import_superstatic2 = __toESM(require_superstatic());
10371
10371
  var import_nft2 = require("@vercel/nft");
10372
10372
  var import_async_sema3 = __toESM(require_lib());
10373
10373
  var import_escape_string_regexp3 = __toESM(require_escape_string_regexp());
@@ -11955,7 +11955,12 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
11955
11955
  }
11956
11956
  let chain;
11957
11957
  let experimentalStreamingLambdaPath;
11958
- if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ && experimentalStreamingLambdaPaths) {
11958
+ if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ && routesManifest?.ppr?.chain?.headers) {
11959
+ chain = {
11960
+ outputPath: pathnameToOutputName(entryDirectory, routeKey),
11961
+ headers: routesManifest.ppr.chain.headers
11962
+ };
11963
+ } else if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ && experimentalStreamingLambdaPaths) {
11959
11964
  let paths = experimentalStreamingLambdaPaths.get(
11960
11965
  pathnameToOutputName(entryDirectory, routeKey)
11961
11966
  );
@@ -11970,17 +11975,10 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
11970
11975
  );
11971
11976
  }
11972
11977
  experimentalStreamingLambdaPath = paths.output;
11973
- if (routesManifest?.ppr?.chain?.headers) {
11974
- chain = {
11975
- outputPath: pathnameToOutputName(entryDirectory, routeKey),
11976
- headers: routesManifest.ppr.chain.headers
11977
- };
11978
- } else {
11979
- chain = {
11980
- outputPath: paths.output,
11981
- headers: { "x-matched-path": paths.pathname }
11982
- };
11983
- }
11978
+ chain = {
11979
+ outputPath: paths.output,
11980
+ headers: { "x-matched-path": paths.pathname }
11981
+ };
11984
11982
  }
11985
11983
  let htmlAllowQuery = allowQuery;
11986
11984
  if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ && isFallback) {
@@ -13085,6 +13083,7 @@ var import_resolve_from = __toESM(require_resolve_from());
13085
13083
  var import_fs_extra5 = __toESM(require_lib2());
13086
13084
  var import_escape_string_regexp2 = __toESM(require_escape_string_regexp());
13087
13085
  var import_pretty_bytes3 = __toESM(require_pretty_bytes());
13086
+ var import_superstatic = __toESM(require_superstatic());
13088
13087
  var CORRECT_NOT_FOUND_ROUTES_VERSION = "v12.0.1";
13089
13088
  var CORRECT_MIDDLEWARE_ORDER_VERSION = "v12.1.7-canary.29";
13090
13089
  var NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION = "v12.1.7-canary.33";
@@ -13128,7 +13127,6 @@ async function serverBuild({
13128
13127
  dynamicPrefix,
13129
13128
  entryDirectory,
13130
13129
  outputDirectory,
13131
- redirects,
13132
13130
  beforeFilesRewrites,
13133
13131
  afterFilesRewrites,
13134
13132
  fallbackRewrites,
@@ -13149,7 +13147,6 @@ async function serverBuild({
13149
13147
  prerenderManifest,
13150
13148
  appPathRoutesManifest,
13151
13149
  omittedPrerenderRoutes,
13152
- trailingSlashRedirects,
13153
13150
  isCorrectLocaleAPIRoutes,
13154
13151
  requiredServerFilesManifest,
13155
13152
  variantsManifest,
@@ -13963,31 +13960,33 @@ ${JSON.stringify(
13963
13960
  throw new Error("Invariant: PPR lambda isn't streaming");
13964
13961
  }
13965
13962
  lambdas[outputName] = lambda;
13966
- if (!omittedPrerenderRoutes.has(pagePathname)) {
13967
- const output = getPostponeResumeOutput(entryDirectory, pageName);
13968
- lambdas[output] = lambda;
13969
- experimentalStreamingLambdaPaths.set(outputName, {
13970
- pathname: getPostponeResumePathname(pageName),
13971
- output
13972
- });
13973
- }
13974
- for (const [
13975
- routePathname,
13976
- { srcRoute, renderingMode }
13977
- ] of Object.entries(prerenderManifest.staticRoutes)) {
13978
- if (srcRoute !== pagePathname || renderingMode !== "PARTIALLY_STATIC" /* PARTIALLY_STATIC */)
13979
- continue;
13980
- if (routePathname === pagePathname)
13981
- continue;
13982
- const output = getPostponeResumePathname(routePathname);
13983
- lambdas[output] = lambda;
13984
- outputName = import_path4.default.posix.join(entryDirectory, routePathname);
13985
- experimentalStreamingLambdaPaths.set(outputName, {
13986
- pathname: getPostponeResumePathname(routePathname),
13987
- output
13988
- });
13963
+ if (typeof routesManifest?.ppr?.chain?.headers === "undefined") {
13964
+ if (!omittedPrerenderRoutes.has(pagePathname)) {
13965
+ const output = getPostponeResumeOutput(entryDirectory, pageName);
13966
+ lambdas[output] = lambda;
13967
+ experimentalStreamingLambdaPaths.set(outputName, {
13968
+ pathname: getPostponeResumePathname(pageName),
13969
+ output
13970
+ });
13971
+ }
13972
+ for (const [
13973
+ routePathname,
13974
+ { srcRoute, renderingMode }
13975
+ ] of Object.entries(prerenderManifest.staticRoutes)) {
13976
+ if (srcRoute !== pagePathname || renderingMode !== "PARTIALLY_STATIC" /* PARTIALLY_STATIC */)
13977
+ continue;
13978
+ if (routePathname === pagePathname)
13979
+ continue;
13980
+ const output = getPostponeResumePathname(routePathname);
13981
+ lambdas[output] = lambda;
13982
+ outputName = import_path4.default.posix.join(entryDirectory, routePathname);
13983
+ experimentalStreamingLambdaPaths.set(outputName, {
13984
+ pathname: getPostponeResumePathname(routePathname),
13985
+ output
13986
+ });
13987
+ }
13988
+ continue;
13989
13989
  }
13990
- continue;
13991
13990
  }
13992
13991
  if (!group.isAppRouter && !group.isAppRouteHandler) {
13993
13992
  outputName = normalizeIndexOutput(outputName, true);
@@ -14289,6 +14288,22 @@ ${JSON.stringify(
14289
14288
  lambdas[dataPathname] = lambdas[srcPathname];
14290
14289
  }
14291
14290
  }
14291
+ const internalRedirects = [];
14292
+ const userRedirects = [];
14293
+ for (const redirect of routesManifest.redirects || []) {
14294
+ if (redirect.internal) {
14295
+ internalRedirects.push(redirect);
14296
+ } else {
14297
+ userRedirects.push(redirect);
14298
+ }
14299
+ }
14300
+ const internalRedirectRoutes = (0, import_superstatic.convertRedirects)(internalRedirects).map(
14301
+ (item) => {
14302
+ item.continue = true;
14303
+ return item;
14304
+ }
14305
+ );
14306
+ const userRedirectRoutes = (0, import_superstatic.convertRedirects)(userRedirects);
14292
14307
  return {
14293
14308
  wildcard: wildcardConfig,
14294
14309
  images: getImagesConfig(imagesManifest),
@@ -14322,7 +14337,7 @@ ${JSON.stringify(
14322
14337
  // force trailingSlashRedirect to the very top so it doesn't
14323
14338
  // conflict with i18n routes that don't have or don't have the
14324
14339
  // trailing slash
14325
- ...trailingSlashRedirects,
14340
+ ...internalRedirectRoutes,
14326
14341
  ...privateOutputs.routes,
14327
14342
  // normalize _next/data URL before processing redirects
14328
14343
  ...normalizeNextDataRoute(true),
@@ -14427,7 +14442,7 @@ ${JSON.stringify(
14427
14442
  }
14428
14443
  ] : [],
14429
14444
  ...headers,
14430
- ...redirects,
14445
+ ...userRedirectRoutes,
14431
14446
  // middleware comes directly after redirects but before
14432
14447
  // beforeFiles rewrites as middleware is not a "file" route
14433
14448
  ...routesManifest?.skipMiddlewareUrlNormalize ? denormalizeNextDataRoute(true) : [],
@@ -14832,7 +14847,14 @@ ${JSON.stringify(
14832
14847
  }
14833
14848
  ] : [
14834
14849
  {
14835
- src: import_path4.default.posix.join("/", entryDirectory, ".*"),
14850
+ src: import_path4.default.posix.join(
14851
+ "/",
14852
+ entryDirectory,
14853
+ // if entryDirectory is populated we need to
14854
+ // add optional handling for trailing slash so
14855
+ // that the entryDirectory (basePath) itself matches
14856
+ `${entryDirectory !== "." ? "?" : ""}.*`
14857
+ ),
14836
14858
  dest: import_path4.default.posix.join(
14837
14859
  "/",
14838
14860
  entryDirectory,
@@ -14864,7 +14886,14 @@ ${JSON.stringify(
14864
14886
  }
14865
14887
  ] : [
14866
14888
  {
14867
- src: import_path4.default.posix.join("/", entryDirectory, ".*"),
14889
+ src: import_path4.default.posix.join(
14890
+ "/",
14891
+ entryDirectory,
14892
+ // if entryDirectory is populated we need to
14893
+ // add optional handling for trailing slash so
14894
+ // that the entryDirectory (basePath) itself matches
14895
+ `${entryDirectory !== "." ? "?" : ""}.*`
14896
+ ),
14868
14897
  dest: import_path4.default.posix.join(
14869
14898
  "/",
14870
14899
  entryDirectory,
@@ -15250,17 +15279,17 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
15250
15279
  case 2:
15251
15280
  case 3:
15252
15281
  case 4: {
15253
- redirects.push(...(0, import_superstatic.convertRedirects)(routesManifest.redirects));
15282
+ redirects.push(...(0, import_superstatic2.convertRedirects)(routesManifest.redirects));
15254
15283
  if (Array.isArray(routesManifest.rewrites)) {
15255
15284
  afterFilesRewrites.push(
15256
- ...(0, import_superstatic.convertRewrites)(
15285
+ ...(0, import_superstatic2.convertRewrites)(
15257
15286
  routesManifest.rewrites,
15258
15287
  routesManifest.i18n ? ["nextInternalLocale"] : void 0
15259
15288
  )
15260
15289
  );
15261
15290
  } else {
15262
15291
  beforeFilesRewrites.push(
15263
- ...(0, import_superstatic.convertRewrites)(routesManifest.rewrites.beforeFiles).map((r) => {
15292
+ ...(0, import_superstatic2.convertRewrites)(routesManifest.rewrites.beforeFiles).map((r) => {
15264
15293
  if ("check" in r) {
15265
15294
  if (beforeFilesShouldContinue) {
15266
15295
  delete r.check;
@@ -15272,14 +15301,14 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
15272
15301
  })
15273
15302
  );
15274
15303
  afterFilesRewrites.push(
15275
- ...(0, import_superstatic.convertRewrites)(routesManifest.rewrites.afterFiles)
15304
+ ...(0, import_superstatic2.convertRewrites)(routesManifest.rewrites.afterFiles)
15276
15305
  );
15277
15306
  fallbackRewrites.push(
15278
- ...(0, import_superstatic.convertRewrites)(routesManifest.rewrites.fallback)
15307
+ ...(0, import_superstatic2.convertRewrites)(routesManifest.rewrites.fallback)
15279
15308
  );
15280
15309
  }
15281
15310
  if (routesManifest.headers) {
15282
- headers.push(...(0, import_superstatic.convertHeaders)(routesManifest.headers));
15311
+ headers.push(...(0, import_superstatic2.convertHeaders)(routesManifest.headers));
15283
15312
  }
15284
15313
  if (import_semver4.default.gte(nextVersion, REDIRECTS_NO_STATIC_NEXT_VERSION)) {
15285
15314
  redirects.forEach(
@@ -15829,7 +15858,6 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
15829
15858
  afterFilesRewrites,
15830
15859
  fallbackRewrites,
15831
15860
  workPath,
15832
- redirects,
15833
15861
  nodeVersion,
15834
15862
  dynamicPrefix,
15835
15863
  routesManifest,
@@ -15843,7 +15871,6 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
15843
15871
  buildId,
15844
15872
  escapedBuildId,
15845
15873
  outputDirectory,
15846
- trailingSlashRedirects,
15847
15874
  requiredServerFilesManifest,
15848
15875
  privateOutputs,
15849
15876
  hasIsr404Page,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.3.18",
3
+ "version": "4.3.20",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",