@vercel/next 4.5.2 → 4.6.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 +72 -35
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -13820,6 +13820,9 @@ async function serverBuild({
13820
13820
  ) : {};
13821
13821
  const updated = {
13822
13822
  ...rewrite,
13823
+ // We don't want to perform the actual rewrite here, instead we want
13824
+ // to just add the headers associated with the rewrite.
13825
+ dest: void 0,
13823
13826
  has,
13824
13827
  headers: headers2
13825
13828
  };
@@ -15700,6 +15703,7 @@ function isLegacyNext(nextVersion) {
15700
15703
  }
15701
15704
  var build = async (buildOptions) => {
15702
15705
  let { workPath, repoRootPath } = buildOptions;
15706
+ const builderSpan = buildOptions.span ?? new import_build_utils3.Span({ name: "vc.builder" });
15703
15707
  const {
15704
15708
  files,
15705
15709
  entrypoint,
@@ -15806,18 +15810,38 @@ var build = async (buildOptions) => {
15806
15810
  (0, import_build_utils3.debug)("Found NPM_AUTH_TOKEN in environment, creating .npmrc");
15807
15811
  await writeNpmRc(entryPath, process.env.NPM_AUTH_TOKEN);
15808
15812
  }
15809
- if (typeof installCommand === "string") {
15810
- if (installCommand.trim()) {
15811
- console.log(`Running "install" command: \`${installCommand}\`...`);
15812
- await (0, import_build_utils3.execCommand)(installCommand, {
15813
- ...spawnOpts,
15814
- cwd: entryPath
15815
- });
15816
- } else {
15817
- console.log(`Skipping "install" command...`);
15818
- }
15813
+ const { detectedPackageManager } = (0, import_build_utils3.detectPackageManager)(cliType, lockfileVersion) ?? {};
15814
+ const trimmedInstallCommand = installCommand?.trim();
15815
+ const shouldRunInstallCommand = (
15816
+ // Case 1: We have a zero config install
15817
+ typeof trimmedInstallCommand === "undefined" || // Case 1: We have a install command which is non zero length
15818
+ Boolean(trimmedInstallCommand)
15819
+ );
15820
+ builderSpan.setAttributes({
15821
+ install: JSON.stringify(shouldRunInstallCommand)
15822
+ });
15823
+ if (shouldRunInstallCommand) {
15824
+ await builderSpan.child(import_build_utils3.BUILDER_INSTALLER_STEP, {
15825
+ cliType,
15826
+ lockfileVersion: lockfileVersion?.toString(),
15827
+ packageJsonPackageManager,
15828
+ detectedPackageManager,
15829
+ installCommand: trimmedInstallCommand
15830
+ }).trace(async () => {
15831
+ if (typeof trimmedInstallCommand === "string") {
15832
+ console.log(
15833
+ `Running "install" command: \`${trimmedInstallCommand}\`...`
15834
+ );
15835
+ await (0, import_build_utils3.execCommand)(trimmedInstallCommand, {
15836
+ ...spawnOpts,
15837
+ cwd: entryPath
15838
+ });
15839
+ } else {
15840
+ await (0, import_build_utils3.runNpmInstall)(entryPath, [], spawnOpts, meta, nodeVersion);
15841
+ }
15842
+ });
15819
15843
  } else {
15820
- await (0, import_build_utils3.runNpmInstall)(entryPath, [], spawnOpts, meta, nodeVersion);
15844
+ console.log(`Skipping "install" command...`);
15821
15845
  }
15822
15846
  if (spawnOpts.env.VERCEL_ANALYTICS_ID) {
15823
15847
  (0, import_build_utils3.debug)("Found VERCEL_ANALYTICS_ID in environment");
@@ -15885,32 +15909,45 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
15885
15909
  if (isServerMode) {
15886
15910
  env.NODE_ENV = "production";
15887
15911
  }
15888
- if (buildCommand) {
15889
- const nodeBinPaths = (0, import_build_utils3.getNodeBinPaths)({
15890
- start: entryPath,
15891
- base: repoRootPath
15892
- });
15893
- const nodeBinPath = nodeBinPaths.join(import_path5.default.delimiter);
15894
- env.PATH = `${nodeBinPath}${import_path5.default.delimiter}${env.PATH}`;
15895
- if (!env.YARN_NODE_LINKER) {
15896
- env.YARN_NODE_LINKER = "node-modules";
15897
- }
15898
- (0, import_build_utils3.debug)(
15899
- `Added "${nodeBinPath}" to PATH env because a build command was used.`
15900
- );
15901
- console.log(`Running "${buildCommand}"`);
15902
- await (0, import_build_utils3.execCommand)(buildCommand, {
15903
- ...spawnOpts,
15904
- cwd: entryPath,
15905
- env
15906
- });
15907
- } else if (buildScriptName) {
15908
- await (0, import_build_utils3.runPackageJsonScript)(entryPath, buildScriptName, {
15909
- ...spawnOpts,
15910
- env
15912
+ const shouldRunCompileStep = Boolean(buildCommand) || Boolean(buildScriptName);
15913
+ builderSpan.setAttributes({
15914
+ build: JSON.stringify(shouldRunCompileStep)
15915
+ });
15916
+ if (shouldRunCompileStep) {
15917
+ await builderSpan.child(import_build_utils3.BUILDER_COMPILE_STEP, {
15918
+ buildCommand,
15919
+ buildScriptName
15920
+ }).trace(async () => {
15921
+ if (buildCommand) {
15922
+ const nodeBinPaths = (0, import_build_utils3.getNodeBinPaths)({
15923
+ start: entryPath,
15924
+ base: repoRootPath
15925
+ });
15926
+ const nodeBinPath = nodeBinPaths.join(import_path5.default.delimiter);
15927
+ env.PATH = `${nodeBinPath}${import_path5.default.delimiter}${env.PATH}`;
15928
+ if (!env.YARN_NODE_LINKER) {
15929
+ env.YARN_NODE_LINKER = "node-modules";
15930
+ }
15931
+ (0, import_build_utils3.debug)(
15932
+ `Added "${nodeBinPath}" to PATH env because a build command was used.`
15933
+ );
15934
+ console.log(`Running "${buildCommand}"`);
15935
+ await (0, import_build_utils3.execCommand)(buildCommand, {
15936
+ ...spawnOpts,
15937
+ cwd: entryPath,
15938
+ env
15939
+ });
15940
+ } else if (buildScriptName) {
15941
+ await (0, import_build_utils3.runPackageJsonScript)(entryPath, buildScriptName, {
15942
+ ...spawnOpts,
15943
+ env
15944
+ });
15945
+ }
15911
15946
  });
15947
+ (0, import_build_utils3.debug)("build command exited");
15948
+ } else {
15949
+ console.log(`Skipping "build" command...`);
15912
15950
  }
15913
- (0, import_build_utils3.debug)("build command exited");
15914
15951
  if (buildCallback) {
15915
15952
  await buildCallback(buildOptions);
15916
15953
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.5.2",
3
+ "version": "4.6.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,7 +30,7 @@
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": "9.2.1",
33
+ "@vercel/build-utils": "9.3.1",
34
34
  "@vercel/routing-utils": "5.0.4",
35
35
  "async-sema": "3.0.1",
36
36
  "buffer-crc32": "0.2.13",