@vercel/next 4.16.3 → 4.16.5

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.
@@ -9645,6 +9645,7 @@ async function handleStaticOutputs(outputs, {
9645
9645
  );
9646
9646
  }
9647
9647
  var vercelConfig = JSON.parse(process.env.NEXT_ADAPTER_VERCEL_CONFIG || "{}");
9648
+ var hasWarnedAboutDotEnv = false;
9648
9649
  function isGeneratedStep(routeName) {
9649
9650
  return routeName.includes(".well-known/workflow/v1/step") || routeName.includes("api/generated/steps");
9650
9651
  }
@@ -9688,6 +9689,30 @@ async function writeDeterministicRoutesManifest(distDir) {
9688
9689
  await import_promises.default.writeFile(outputManifestPath, JSON.stringify(manifest));
9689
9690
  return outputManifestPath;
9690
9691
  }
9692
+ async function getProjectEnvFiles(projectDir) {
9693
+ const envFiles = [];
9694
+ const projectFiles = (await import_promises.default.readdir(projectDir).catch(() => [])).sort();
9695
+ for (const file of projectFiles) {
9696
+ const isEnv = file === ".env" || file.startsWith(".env.");
9697
+ if (!isEnv) {
9698
+ continue;
9699
+ }
9700
+ const statResult = await import_promises.default.lstat(import_node_path.default.join(projectDir, file)).catch(() => {
9701
+ return void 0;
9702
+ });
9703
+ if (statResult?.isFile()) {
9704
+ envFiles.push(file);
9705
+ }
9706
+ }
9707
+ return envFiles;
9708
+ }
9709
+ function resolveNextEnvLoaderPath(projectDir) {
9710
+ const { createRequire } = require("module");
9711
+ const projectRequire = createRequire(import_node_path.default.join(projectDir, "package.json"));
9712
+ const nextPackagePath = projectRequire.resolve("next/package.json");
9713
+ const requireFromNext = createRequire(nextPackagePath);
9714
+ return requireFromNext.resolve("@next/env");
9715
+ }
9691
9716
  async function handleNodeOutputs(nodeOutputs, {
9692
9717
  config,
9693
9718
  distDir,
@@ -9728,6 +9753,27 @@ async function handleNodeOutputs(nodeOutputs, {
9728
9753
  import_node_path.default.posix.relative(repoRoot, distDir),
9729
9754
  "routes-manifest.json"
9730
9755
  );
9756
+ const envFiles = await getProjectEnvFiles(projectDir);
9757
+ const hasProjectEnvFiles = envFiles.length > 0;
9758
+ const envFilePathMap = {};
9759
+ let nextEnvLoaderPathRelativeToProjectDir;
9760
+ for (const envFile of envFiles) {
9761
+ envFilePathMap[import_node_path.default.posix.join(import_node_path.default.posix.relative(repoRoot, projectDir), envFile)] = import_node_path.default.posix.relative(repoRoot, import_node_path.default.join(projectDir, envFile));
9762
+ }
9763
+ if (hasProjectEnvFiles) {
9764
+ if (!hasWarnedAboutDotEnv) {
9765
+ console.warn(
9766
+ "Detected .env file, it is strongly recommended to use Vercel's env handling instead"
9767
+ );
9768
+ hasWarnedAboutDotEnv = true;
9769
+ }
9770
+ const nextEnvLoaderPath = resolveNextEnvLoaderPath(projectDir);
9771
+ envFilePathMap[import_node_path.default.posix.relative(repoRoot, nextEnvLoaderPath)] = import_node_path.default.posix.relative(repoRoot, nextEnvLoaderPath);
9772
+ nextEnvLoaderPathRelativeToProjectDir = import_node_path.default.posix.relative(
9773
+ projectDir,
9774
+ nextEnvLoaderPath
9775
+ );
9776
+ }
9731
9777
  await Promise.all(
9732
9778
  nodeOutputs.map(async (output) => {
9733
9779
  await fsSema.acquire();
@@ -9741,6 +9787,9 @@ async function handleNodeOutputs(nodeOutputs, {
9741
9787
  files[relPath] = import_node_path.default.posix.relative(repoRoot, fsPath);
9742
9788
  }
9743
9789
  files[import_node_path.default.posix.relative(repoRoot, output.filePath)] = import_node_path.default.posix.relative(repoRoot, output.filePath);
9790
+ if (hasProjectEnvFiles) {
9791
+ Object.assign(files, envFilePathMap);
9792
+ }
9744
9793
  if (output.type === import_constants.AdapterOutputType.PAGES) {
9745
9794
  const notFoundOutput = pages404Output || pagesErrorOutput;
9746
9795
  if (notFoundOutput) {
@@ -9767,7 +9816,8 @@ async function handleNodeOutputs(nodeOutputs, {
9767
9816
  projectRelativeDistDir: import_node_path.default.posix.relative(projectDir, distDir),
9768
9817
  prerenderFallbackFalseMap,
9769
9818
  isMiddleware,
9770
- nextConfig: config
9819
+ nextConfig: config,
9820
+ nextEnvLoaderPathRelativeToProjectDir
9771
9821
  })
9772
9822
  );
9773
9823
  const operationType = output.type === import_constants.AdapterOutputType.APP_PAGE || import_constants.AdapterOutputType.PAGES ? "PAGE" : "API";
@@ -24,8 +24,15 @@ module.exports = __toCommonJS(node_handler_exports);
24
24
  const getHandlerSource = (ctx) => `
25
25
  process.env.NODE_ENV = 'production';
26
26
  process.chdir(__dirname);
27
-
28
- require('next/setup-node-env')
27
+
28
+ require('next/setup-node-env');
29
+
30
+ if (process.env.__PRIVATE_NEXT_ENV_LOADER_PATH) {
31
+ const { loadEnvConfig } = require(
32
+ './' + process.env.__PRIVATE_NEXT_ENV_LOADER_PATH
33
+ );
34
+ loadEnvConfig('.', process.env.NODE_ENV === 'development');
35
+ }
29
36
 
30
37
  const _n_handler = (${ctx.isMiddleware ? () => {
31
38
  const path = require("path");
@@ -289,6 +296,9 @@ const getHandlerSource = (ctx) => `
289
296
  ).replaceAll(
290
297
  "process.env.__PRIVATE_NEXT_CONFIG",
291
298
  JSON.stringify(ctx.nextConfig)
299
+ ).replaceAll(
300
+ "process.env.__PRIVATE_NEXT_ENV_LOADER_PATH",
301
+ JSON.stringify(ctx.nextEnvLoaderPathRelativeToProjectDir || "")
292
302
  );
293
303
  // Annotate the CommonJS export names for ESM import in node:
294
304
  0 && (module.exports = {
package/dist/index.js CHANGED
@@ -2097,13 +2097,13 @@ var require_clone = __commonJS({
2097
2097
  if (obj === null || typeof obj !== "object")
2098
2098
  return obj;
2099
2099
  if (obj instanceof Object)
2100
- var copy = { __proto__: getPrototypeOf(obj) };
2100
+ var copy2 = { __proto__: getPrototypeOf(obj) };
2101
2101
  else
2102
- var copy = /* @__PURE__ */ Object.create(null);
2102
+ var copy2 = /* @__PURE__ */ Object.create(null);
2103
2103
  Object.getOwnPropertyNames(obj).forEach(function(key) {
2104
- Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
2104
+ Object.defineProperty(copy2, key, Object.getOwnPropertyDescriptor(obj, key));
2105
2105
  });
2106
- return copy;
2106
+ return copy2;
2107
2107
  }
2108
2108
  }
2109
2109
  });
@@ -2858,7 +2858,7 @@ var require_copy = __commonJS({
2858
2858
  var { pathExists: pathExists2 } = require_path_exists2();
2859
2859
  var { utimesMillis } = require_utimes();
2860
2860
  var stat2 = require_stat();
2861
- async function copy(src, dest, opts = {}) {
2861
+ async function copy2(src, dest, opts = {}) {
2862
2862
  if (typeof opts === "function") {
2863
2863
  opts = { filter: opts };
2864
2864
  }
@@ -2977,7 +2977,7 @@ var require_copy = __commonJS({
2977
2977
  await fs5.unlink(dest);
2978
2978
  return fs5.symlink(resolvedSrc, dest);
2979
2979
  }
2980
- module2.exports = copy;
2980
+ module2.exports = copy2;
2981
2981
  }
2982
2982
  });
2983
2983
 
@@ -3703,7 +3703,7 @@ var require_move = __commonJS({
3703
3703
  "use strict";
3704
3704
  var fs5 = require_fs();
3705
3705
  var path6 = require("path");
3706
- var { copy } = require_copy2();
3706
+ var { copy: copy2 } = require_copy2();
3707
3707
  var { remove: remove2 } = require_remove();
3708
3708
  var { mkdirp } = require_mkdirs();
3709
3709
  var { pathExists: pathExists2 } = require_path_exists2();
@@ -3742,7 +3742,7 @@ var require_move = __commonJS({
3742
3742
  errorOnExist: true,
3743
3743
  preserveTimestamps: true
3744
3744
  };
3745
- await copy(src, dest, opts);
3745
+ await copy2(src, dest, opts);
3746
3746
  return remove2(src);
3747
3747
  }
3748
3748
  module2.exports = move;
@@ -16801,6 +16801,22 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
16801
16801
  } catch (_) {
16802
16802
  }
16803
16803
  if (buildOutputVersion) {
16804
+ const publicDir = import_path6.default.join(entryPath, "public");
16805
+ const staticOutputDir = import_path6.default.join(
16806
+ entryPath,
16807
+ outputDirectory,
16808
+ "output/static"
16809
+ );
16810
+ if (await (0, import_fs_extra6.pathExists)(publicDir)) {
16811
+ const publicFiles = await (0, import_build_utils3.glob)("**/*", publicDir);
16812
+ for (const fileName of Object.keys(publicFiles)) {
16813
+ const destPath = import_path6.default.join(staticOutputDir, fileName);
16814
+ if (!await (0, import_fs_extra6.pathExists)(destPath)) {
16815
+ const srcPath = publicFiles[fileName].fsPath;
16816
+ await (0, import_fs_extra6.copy)(srcPath, destPath);
16817
+ }
16818
+ }
16819
+ }
16804
16820
  return {
16805
16821
  buildOutputPath: import_path6.default.join(entryPath, outputDirectory, "output"),
16806
16822
  buildOutputVersion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.16.3",
3
+ "version": "4.16.5",
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.5.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@next-community/adapter-vercel": "0.0.1-beta.15",
19
+ "@next-community/adapter-vercel": "0.0.1-beta.16",
20
20
  "@types/aws-lambda": "8.10.19",
21
21
  "@types/buffer-crc32": "0.2.0",
22
22
  "@types/bytes": "3.1.1",
@@ -53,7 +53,7 @@
53
53
  "test-listen": "1.1.0",
54
54
  "text-table": "0.2.0",
55
55
  "webpack-sources": "3.2.3",
56
- "@vercel/build-utils": "13.10.0",
56
+ "@vercel/build-utils": "13.12.2",
57
57
  "@vercel/routing-utils": "6.1.1"
58
58
  },
59
59
  "scripts": {