@vercel/next 4.20.2 → 4.20.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.
@@ -9665,7 +9665,7 @@ async function handleStaticOutputs(outputs, {
9665
9665
  const srcExtension = import_node_path.default.extname(output.filePath);
9666
9666
  const isHtml = srcExtension === ".html";
9667
9667
  if (isHtml) {
9668
- vercelConfig2.overrides[import_node_path.default.posix.join("./", output.pathname + ".html")] = {
9668
+ vercelConfig2.overrides[import_node_path.default.posix.join("./", `${output.pathname}.html`)] = {
9669
9669
  contentType: "text/html; charset=utf-8",
9670
9670
  path: import_node_path.default.posix.join("./", output.pathname)
9671
9671
  };
@@ -9856,6 +9856,7 @@ async function handleNodeOutputs(nodeOutputs, {
9856
9856
  nextEnvLoaderPath
9857
9857
  );
9858
9858
  }
9859
+ const usesSrcDir = await usesSrcDirectory(projectDir);
9859
9860
  await Promise.all(
9860
9861
  nodeOutputs.map(async (output) => {
9861
9862
  await fsSema.acquire();
@@ -9914,11 +9915,12 @@ async function handleNodeOutputs(nodeOutputs, {
9914
9915
  if (filesHashes) {
9915
9916
  filesHashes["___next_launcher.cjs"] = sha256(handlerSource);
9916
9917
  }
9917
- const operationType = output.type === import_constants.AdapterOutputType.APP_PAGE || import_constants.AdapterOutputType.PAGES ? "PAGE" : "API";
9918
+ const operationType = output.type === import_constants.AdapterOutputType.APP_PAGE || output.type === import_constants.AdapterOutputType.PAGES ? "PAGE" : "API";
9918
9919
  const sourceFile = await getSourceFilePathFromPage({
9919
9920
  workPath: projectDir,
9920
9921
  page: output.sourcePage,
9921
- pageExtensions: config.pageExtensions || []
9922
+ pageExtensions: config.pageExtensions || [],
9923
+ usesSrcDir
9922
9924
  });
9923
9925
  const vercelConfigOpts = await (0, import_build_utils.getLambdaOptionsFromFunction)({
9924
9926
  sourceFile,
@@ -10229,39 +10231,29 @@ async function handleMiddleware(output, ctx) {
10229
10231
  }
10230
10232
  return routes;
10231
10233
  }
10232
- var _usesSrcCache;
10233
10234
  async function usesSrcDirectory(workPath) {
10234
- if (!_usesSrcCache) {
10235
- const sourcePages = import_node_path.default.join(workPath, "src", "pages");
10236
- try {
10237
- if ((await import_promises.default.stat(sourcePages)).isDirectory()) {
10238
- _usesSrcCache = true;
10239
- }
10240
- } catch (_err) {
10241
- _usesSrcCache = false;
10242
- }
10243
- }
10244
- if (!_usesSrcCache) {
10245
- const sourceAppdir = import_node_path.default.join(workPath, "src", "app");
10235
+ for (const dir of [
10236
+ import_node_path.default.join(workPath, "src", "pages"),
10237
+ import_node_path.default.join(workPath, "src", "app")
10238
+ ]) {
10246
10239
  try {
10247
- if ((await import_promises.default.stat(sourceAppdir)).isDirectory()) {
10248
- _usesSrcCache = true;
10240
+ if ((await import_promises.default.stat(dir)).isDirectory()) {
10241
+ return true;
10249
10242
  }
10250
10243
  } catch (_err) {
10251
- _usesSrcCache = false;
10252
10244
  }
10253
10245
  }
10254
- return Boolean(_usesSrcCache);
10246
+ return false;
10255
10247
  }
10256
10248
  function isDirectory(path3) {
10257
- return import_fs_extra3.default.existsSync(path3) && import_fs_extra3.default.lstatSync(path3).isDirectory();
10249
+ return import_fs_extra3.default.lstatSync(path3, { throwIfNoEntry: false })?.isDirectory() ?? false;
10258
10250
  }
10259
10251
  async function getSourceFilePathFromPage({
10260
10252
  workPath,
10261
10253
  page,
10262
- pageExtensions
10254
+ pageExtensions,
10255
+ usesSrcDir
10263
10256
  }) {
10264
- const usesSrcDir = await usesSrcDirectory(workPath);
10265
10257
  const extensionsToTry = pageExtensions || ["js", "jsx", "ts", "tsx"];
10266
10258
  for (const pageType of [
10267
10259
  // middleware is not nested in pages/app
@@ -10376,10 +10368,10 @@ function modifyWithRewriteHeaders(rewrites, {
10376
10368
  rewrite.headers = {
10377
10369
  ...rewrite.headers,
10378
10370
  ...pathname ? {
10379
- ["x-nextjs-rewritten-path"]: pathname
10371
+ "x-nextjs-rewritten-path": pathname
10380
10372
  } : {},
10381
10373
  ...query ? {
10382
- ["x-nextjs-rewritten-query"]: query
10374
+ "x-nextjs-rewritten-query": query
10383
10375
  } : {}
10384
10376
  };
10385
10377
  }
@@ -10624,8 +10616,10 @@ if(${cookieCheck}){
10624
10616
  var myAdapter = {
10625
10617
  name: "Vercel",
10626
10618
  async modifyConfig(config, ctx) {
10627
- if (ctx.phase === import_constants2.PHASE_PRODUCTION_BUILD && process.env.VERCEL_IMMUTABLE_STATIC_FILES_ENABLED === "1") {
10628
- config.experimental.supportsImmutableAssets = true;
10619
+ if (ctx.phase === import_constants2.PHASE_PRODUCTION_BUILD) {
10620
+ config.experimental.supportsImmutableAssets = // Default to true, allow users to opt-out
10621
+ (config.experimental.supportsImmutableAssets ?? true) && // AND with infra support to allow disabling via feature flag if necessary.
10622
+ process.env.VERCEL_IMMUTABLE_STATIC_FILES_ENABLED === "1";
10629
10623
  }
10630
10624
  if (process.env.VERCEL_HASH_SALT != null) {
10631
10625
  config.experimental.outputHashSalt = (config.experimental.outputHashSalt ?? "") + process.env.VERCEL_HASH_SALT;
@@ -43,7 +43,7 @@ const getHandlerSource = (ctx) => `
43
43
  return fromSymbol[SYMBOL_FOR_REQ_CONTEXT]?.get?.() ?? {};
44
44
  }
45
45
  return async function handler(request) {
46
- let middlewareHandler = await require("./" + path.posix.join(relativeDistDir, "server", "middleware.js"));
46
+ let middlewareHandler = await require(`./${path.posix.join(relativeDistDir, "server", "middleware.js")}`);
47
47
  middlewareHandler = middlewareHandler.handler || middlewareHandler;
48
48
  const context = getRequestContext();
49
49
  const response = await middlewareHandler(request, {
@@ -65,7 +65,7 @@ const getHandlerSource = (ctx) => `
65
65
  dynamicRoutes: dynamicRoutesRaw,
66
66
  staticRoutes: staticRoutesRaw,
67
67
  i18n
68
- } = require("./" + path.posix.join(relativeDistDir, "routes-manifest.json"));
68
+ } = require(`./${path.posix.join(relativeDistDir, "routes-manifest.json")}`);
69
69
  const matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g;
70
70
  function escapeStringRegexp(str) {
71
71
  return str.replace(matchOperatorsRegex, "\\$&");
@@ -79,9 +79,7 @@ const getHandlerSource = (ctx) => `
79
79
  const staticRoutes = staticRoutesRaw.map((route) => {
80
80
  return {
81
81
  ...route,
82
- namedRegex: new RegExp(
83
- "^" + escapeStringRegexp(route.page) + "$"
84
- )
82
+ namedRegex: new RegExp(`^${escapeStringRegexp(route.page)}$`)
85
83
  };
86
84
  });
87
85
  let appPathRoutesManifest = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.20.2",
3
+ "version": "4.20.3",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -16,7 +16,7 @@
16
16
  "@vercel/nft": "1.10.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@next-community/adapter-vercel": "0.0.1-beta.22",
19
+ "@next-community/adapter-vercel": "0.0.1-beta.24",
20
20
  "@types/aws-lambda": "8.10.19",
21
21
  "@types/buffer-crc32": "0.2.0",
22
22
  "@types/bytes": "3.1.1",
@@ -53,8 +53,8 @@
53
53
  "text-table": "0.2.0",
54
54
  "vitest": "2.0.3",
55
55
  "webpack-sources": "3.2.3",
56
- "@vercel/routing-utils": "6.4.0",
57
- "@vercel/build-utils": "13.32.2"
56
+ "@vercel/build-utils": "13.32.2",
57
+ "@vercel/routing-utils": "6.4.0"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "node build.mjs",