@vercel/next 4.13.4 → 4.14.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 +43 -37
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -11962,48 +11962,53 @@ async function usesSrcDirectory(workPath) {
11962
11962
  async function getSourceFilePathFromPage({
11963
11963
  workPath,
11964
11964
  page,
11965
- pageExtensions
11965
+ pageExtensions,
11966
+ nextVersion
11966
11967
  }) {
11967
11968
  const usesSrcDir = await usesSrcDirectory(workPath);
11968
11969
  const extensionsToTry = pageExtensions || ["js", "jsx", "ts", "tsx"];
11969
- for (const pageType of [
11970
- // middleware is not nested in pages/app
11971
- ...page === "middleware" ? [""] : ["pages", "app"]
11972
- ]) {
11973
- let fsPath = import_path3.default.join(workPath, pageType, page);
11974
- if (usesSrcDir) {
11975
- fsPath = import_path3.default.join(workPath, "src", pageType, page);
11976
- }
11977
- if (import_fs_extra3.default.existsSync(fsPath)) {
11978
- return import_path3.default.relative(workPath, fsPath);
11979
- }
11980
- const extensionless = fsPath.replace(import_path3.default.extname(fsPath), "");
11981
- for (const ext of extensionsToTry) {
11982
- fsPath = `${extensionless}.${ext}`;
11983
- if (pageType === "app" && extensionless === import_path3.default.join(workPath, `${usesSrcDir ? "src/" : ""}app/index`)) {
11984
- fsPath = `${extensionless.replace(/index$/, "page")}.${ext}`;
11970
+ const isNextJs16Plus = nextVersion && import_semver.default.gte(nextVersion, "16.0.0");
11971
+ const pagesToCheck = page === "middleware" && isNextJs16Plus ? ["proxy", "middleware"] : [page];
11972
+ for (const pageToCheck of pagesToCheck) {
11973
+ for (const pageType of [
11974
+ // middleware/proxy is not nested in pages/app
11975
+ ...pageToCheck === "middleware" || pageToCheck === "proxy" ? [""] : ["pages", "app"]
11976
+ ]) {
11977
+ let fsPath = import_path3.default.join(workPath, pageType, pageToCheck);
11978
+ if (usesSrcDir) {
11979
+ fsPath = import_path3.default.join(workPath, "src", pageType, pageToCheck);
11985
11980
  }
11986
11981
  if (import_fs_extra3.default.existsSync(fsPath)) {
11987
11982
  return import_path3.default.relative(workPath, fsPath);
11988
11983
  }
11989
- }
11990
- if (isDirectory(extensionless)) {
11991
- if (pageType === "pages") {
11992
- for (const ext of extensionsToTry) {
11993
- fsPath = import_path3.default.join(extensionless, `index.${ext}`);
11994
- if (import_fs_extra3.default.existsSync(fsPath)) {
11995
- return import_path3.default.relative(workPath, fsPath);
11996
- }
11984
+ const extensionless = fsPath.replace(import_path3.default.extname(fsPath), "");
11985
+ for (const ext of extensionsToTry) {
11986
+ fsPath = `${extensionless}.${ext}`;
11987
+ if (pageType === "app" && extensionless === import_path3.default.join(workPath, `${usesSrcDir ? "src/" : ""}app/index`)) {
11988
+ fsPath = `${extensionless.replace(/index$/, "page")}.${ext}`;
11997
11989
  }
11998
- } else {
11999
- for (const ext of extensionsToTry) {
12000
- fsPath = import_path3.default.join(extensionless, `page.${ext}`);
12001
- if (import_fs_extra3.default.existsSync(fsPath)) {
12002
- return import_path3.default.relative(workPath, fsPath);
11990
+ if (import_fs_extra3.default.existsSync(fsPath)) {
11991
+ return import_path3.default.relative(workPath, fsPath);
11992
+ }
11993
+ }
11994
+ if (isDirectory(extensionless)) {
11995
+ if (pageType === "pages") {
11996
+ for (const ext of extensionsToTry) {
11997
+ fsPath = import_path3.default.join(extensionless, `index.${ext}`);
11998
+ if (import_fs_extra3.default.existsSync(fsPath)) {
11999
+ return import_path3.default.relative(workPath, fsPath);
12000
+ }
12003
12001
  }
12004
- fsPath = import_path3.default.join(extensionless, `route.${ext}`);
12005
- if (import_fs_extra3.default.existsSync(fsPath)) {
12006
- return import_path3.default.relative(workPath, fsPath);
12002
+ } else {
12003
+ for (const ext of extensionsToTry) {
12004
+ fsPath = import_path3.default.join(extensionless, `page.${ext}`);
12005
+ if (import_fs_extra3.default.existsSync(fsPath)) {
12006
+ return import_path3.default.relative(workPath, fsPath);
12007
+ }
12008
+ fsPath = import_path3.default.join(extensionless, `route.${ext}`);
12009
+ if (import_fs_extra3.default.existsSync(fsPath)) {
12010
+ return import_path3.default.relative(workPath, fsPath);
12011
+ }
12007
12012
  }
12008
12013
  }
12009
12014
  }
@@ -12015,6 +12020,9 @@ async function getSourceFilePathFromPage({
12015
12020
  if (page === "/_global-error/page") {
12016
12021
  return "";
12017
12022
  }
12023
+ if (page === "middleware" && isNextJs16Plus) {
12024
+ return "";
12025
+ }
12018
12026
  if (!INTERNAL_PAGES.includes(page)) {
12019
12027
  console.log(
12020
12028
  `WARNING: Unable to find source file for page ${page} with extensions: ${extensionsToTry.join(
@@ -13143,7 +13151,8 @@ async function getNodeMiddleware({
13143
13151
  const sourceFile = await getSourceFilePathFromPage({
13144
13152
  workPath: entryPath,
13145
13153
  page: normalizeSourceFilePageFromManifest("/middleware", "middleware", {}),
13146
- pageExtensions
13154
+ pageExtensions,
13155
+ nextVersion
13147
13156
  });
13148
13157
  const vercelConfigOpts = await (0, import_build_utils.getLambdaOptionsFromFunction)({
13149
13158
  sourceFile,
@@ -16342,7 +16351,6 @@ var build = async (buildOptions) => {
16342
16351
  cliType,
16343
16352
  lockfileVersion,
16344
16353
  packageJsonPackageManager,
16345
- nodeVersion,
16346
16354
  env: spawnOpts.env || {},
16347
16355
  turboSupportsCorepackHome,
16348
16356
  projectCreatedAt: config.projectSettings?.createdAt
@@ -16429,7 +16437,6 @@ var build = async (buildOptions) => {
16429
16437
  [],
16430
16438
  spawnOpts,
16431
16439
  meta,
16432
- nodeVersion,
16433
16440
  config.projectSettings?.createdAt
16434
16441
  );
16435
16442
  }
@@ -16945,7 +16952,6 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
16945
16952
  ["--production"],
16946
16953
  spawnOpts,
16947
16954
  meta,
16948
- nodeVersion,
16949
16955
  config.projectSettings?.createdAt
16950
16956
  );
16951
16957
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.13.4",
3
+ "version": "4.14.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -30,8 +30,8 @@
30
30
  "@types/semver": "6.0.0",
31
31
  "@types/text-table": "0.2.1",
32
32
  "@types/webpack-sources": "3.2.0",
33
- "@vercel/build-utils": "12.1.3",
34
- "@vercel/routing-utils": "5.2.0",
33
+ "@vercel/build-utils": "12.2.0",
34
+ "@vercel/routing-utils": "5.2.1",
35
35
  "async-sema": "3.0.1",
36
36
  "buffer-crc32": "0.2.13",
37
37
  "bytes": "3.1.2",