@vercel/build-utils 8.4.1 → 8.4.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @vercel/build-utils
2
2
 
3
+ ## 8.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Introduce new chain configuration types for Partial Prerendering ([#12063](https://github.com/vercel/vercel/pull/12063))
8
+
9
+ ## 8.4.2
10
+
11
+ ### Patch Changes
12
+
13
+ - Revert "Revert "Revert "Fix corepack `packageManager` detection on monorepos""" ([#12099](https://github.com/vercel/vercel/pull/12099))
14
+
3
15
  ## 8.4.1
4
16
 
5
17
  ### Patch Changes
@@ -26,12 +26,6 @@ export interface ScanParentDirsResult {
26
26
  * or `undefined` if not found.
27
27
  */
28
28
  lockfileVersion?: number;
29
- /**
30
- * The contents of the `packageManager` field from `package.json` if found.
31
- * The value may come from a different `package.json` file than the one
32
- * specified by `packageJsonPath`, in the case of a monorepo.
33
- */
34
- packageJsonPackageManager?: string;
35
29
  }
36
30
  export interface TraverseUpDirectoriesProps {
37
31
  /**
@@ -219,10 +219,7 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
219
219
  filename: "package.json"
220
220
  });
221
221
  const packageJson = readPackageJson && pkgJsonPath ? JSON.parse(await import_fs_extra.default.readFile(pkgJsonPath, "utf8")) : void 0;
222
- const {
223
- paths: [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath],
224
- packageJsonPackageManager
225
- } = await walkParentDirsMulti({
222
+ const [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath] = await walkParentDirsMulti({
226
223
  base,
227
224
  start: destPath,
228
225
  filenames: [
@@ -261,21 +258,19 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
261
258
  lockfilePath = bunLockPath;
262
259
  lockfileVersion = 0;
263
260
  } else {
264
- cliType = detectPackageManagerNameWithoutLockfile(
265
- packageJsonPackageManager
266
- );
261
+ cliType = packageJson ? detectPackageManagerNameWithoutLockfile(packageJson) : "npm";
267
262
  }
268
263
  const packageJsonPath = pkgJsonPath || void 0;
269
264
  return {
270
265
  cliType,
271
266
  packageJson,
272
- packageJsonPackageManager,
273
267
  lockfilePath,
274
268
  lockfileVersion,
275
269
  packageJsonPath
276
270
  };
277
271
  }
278
- function detectPackageManagerNameWithoutLockfile(packageJsonPackageManager) {
272
+ function detectPackageManagerNameWithoutLockfile(packageJson) {
273
+ const packageJsonPackageManager = packageJson.packageManager;
279
274
  if (usingCorepack(process.env, packageJsonPackageManager)) {
280
275
  const corepackPackageManager = validateVersionSpecifier(
281
276
  packageJsonPackageManager
@@ -320,26 +315,17 @@ async function walkParentDirsMulti({
320
315
  start,
321
316
  filenames
322
317
  }) {
323
- let packageManager;
324
318
  for (const dir of traverseUpDirectories({ start, base })) {
325
319
  const fullPaths = filenames.map((f) => import_path.default.join(dir, f));
326
320
  const existResults = await Promise.all(
327
321
  fullPaths.map((f) => import_fs_extra.default.pathExists(f))
328
322
  );
329
323
  const foundOneOrMore = existResults.some((b) => b);
330
- const packageJsonPath = import_path.default.join(dir, "package.json");
331
- const packageJson = await import_fs_extra.default.readJSON(packageJsonPath).catch(() => null);
332
- if (packageJson?.packageManager) {
333
- packageManager = packageJson.packageManager;
334
- }
335
324
  if (foundOneOrMore) {
336
- return {
337
- paths: fullPaths.map((f, i) => existResults[i] ? f : void 0),
338
- packageJsonPackageManager: packageManager
339
- };
325
+ return fullPaths.map((f, i) => existResults[i] ? f : void 0);
340
326
  }
341
327
  }
342
- return { paths: [], packageJsonPackageManager: packageManager };
328
+ return [];
343
329
  }
344
330
  function isSet(v) {
345
331
  return v?.constructor?.name === "Set";
@@ -352,13 +338,7 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
352
338
  (0, import_assert.default)(import_path.default.isAbsolute(destPath));
353
339
  try {
354
340
  await runNpmInstallSema.acquire();
355
- const {
356
- cliType,
357
- packageJsonPath,
358
- lockfileVersion,
359
- packageJsonPackageManager,
360
- packageJson
361
- } = await scanParentDirs(destPath);
341
+ const { cliType, packageJsonPath, packageJson, lockfileVersion } = await scanParentDirs(destPath, true);
362
342
  if (!packageJsonPath) {
363
343
  (0, import_debug.default)(
364
344
  `Skipping dependency installation because no package.json was found for ${destPath}`
@@ -387,7 +367,7 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
387
367
  opts.env = getEnvForPackageManager({
388
368
  cliType,
389
369
  lockfileVersion,
390
- packageJsonPackageManager,
370
+ packageJsonPackageManager: packageJson?.packageManager,
391
371
  nodeVersion,
392
372
  env,
393
373
  packageJsonEngines: packageJson?.engines
@@ -726,11 +706,14 @@ async function runCustomInstallCommand({
726
706
  spawnOpts
727
707
  }) {
728
708
  console.log(`Running "install" command: \`${installCommand}\`...`);
729
- const { cliType, lockfileVersion, packageJsonPackageManager, packageJson } = await scanParentDirs(destPath);
709
+ const { cliType, lockfileVersion, packageJson } = await scanParentDirs(
710
+ destPath,
711
+ true
712
+ );
730
713
  const env = getEnvForPackageManager({
731
714
  cliType,
732
715
  lockfileVersion,
733
- packageJsonPackageManager,
716
+ packageJsonPackageManager: packageJson?.packageManager,
734
717
  nodeVersion,
735
718
  env: spawnOpts?.env || {},
736
719
  packageJsonEngines: packageJson?.engines
@@ -744,7 +727,10 @@ async function runCustomInstallCommand({
744
727
  }
745
728
  async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
746
729
  (0, import_assert.default)(import_path.default.isAbsolute(destPath));
747
- const { packageJson, cliType, lockfileVersion, packageJsonPackageManager } = await scanParentDirs(destPath, true);
730
+ const { packageJson, cliType, lockfileVersion } = await scanParentDirs(
731
+ destPath,
732
+ true
733
+ );
748
734
  const scriptName = getScriptName(
749
735
  packageJson,
750
736
  typeof scriptNames === "string" ? [scriptNames] : scriptNames
@@ -759,7 +745,7 @@ async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
759
745
  env: getEnvForPackageManager({
760
746
  cliType,
761
747
  lockfileVersion,
762
- packageJsonPackageManager,
748
+ packageJsonPackageManager: packageJson?.packageManager,
763
749
  nodeVersion: void 0,
764
750
  env: (0, import_clone_env.cloneEnv)(process.env, spawnOpts?.env),
765
751
  packageJsonEngines: packageJson?.engines