@vercel/build-utils 14.17.0 → 14.19.0
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 +19 -0
- package/DEV_MANIFEST.md +1 -1
- package/dist/fs/run-user-scripts.d.ts +19 -1
- package/dist/fs/run-user-scripts.js +112 -6
- package/dist/index.d.ts +3 -2
- package/dist/index.js +15 -15
- package/dist/schedules.d.ts +15 -24
- package/dist/schedules.js +16 -119
- package/dist/static-files/bundle.d.ts +11 -0
- package/dist/static-files/bundle.js +67 -0
- package/dist/static-files/index.d.ts +11 -0
- package/dist/static-files/index.js +49 -0
- package/dist/static-files/promote.d.ts +19 -0
- package/dist/static-files/promote.js +90 -0
- package/dist/static-files/routes.d.ts +60 -0
- package/dist/static-files/routes.js +205 -0
- package/dist/static-files/types.d.ts +81 -0
- package/dist/static-files/types.js +32 -0
- package/dist/static-files/utils.d.ts +23 -0
- package/dist/static-files/utils.js +58 -0
- package/dist/types.d.ts +14 -27
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @vercel/build-utils
|
|
2
2
|
|
|
3
|
+
## 14.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e58b37a: Breaking (beta): the nested `expression`/`target` `schedules` format is no longer supported in `vercel.json` or Build Output. `schedules` entries use `schedule` plus exactly one of `path`, `function`, `topic`, or `entrypoint`, with optional `name`, `timezone`, and `jitter`. When `name` is omitted, it defaults to a hash of the target and cron expression, matching the name the API derives. `vercel build` leaves unnamed schedules unnamed in `config.json`, except entrypoint schedules, which keep the derived name their function dispatches on.
|
|
8
|
+
|
|
9
|
+
`Schedule` now has the flat shape. Removed exports: `parseScheduleDefinition`, `formatBuildOutputSchedule`, `FlatBuildOutputSchedule`, `ScheduleExpression`, and `ScheduleTarget` from `@vercel/build-utils`; `FlatScheduleDefinition`, `LegacyScheduleDefinition`, and `ScheduleDefinition` from `@vercel/config`; and `VercelConfigFlatSchedule` from `@vercel/client`.
|
|
10
|
+
|
|
11
|
+
## 14.18.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 94f6cea: Flat path `schedules` accept an optional `requestMethod` of `GET` or `POST`, defaulting to `POST`. `vercel build` writes it to Build Output, and `vercel dev` invokes path schedules with it.
|
|
16
|
+
- 3eeaad5: Move static file copying to build utils.
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 8ac5320: Add an experimental workspace-scoped install path for Node builds to avoid installing unrelated monorepo workspaces.
|
|
21
|
+
|
|
3
22
|
## 14.17.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
package/DEV_MANIFEST.md
CHANGED
|
@@ -24,7 +24,7 @@ production consumer scoping where applicable.
|
|
|
24
24
|
## Functions and invocation
|
|
25
25
|
|
|
26
26
|
Every `DevFunction` has a deployment `outputPath` with no leading slash or
|
|
27
|
-
`.func` suffix. It is the identity referenced by a Schedule's `
|
|
27
|
+
`.func` suffix. It is the identity referenced by a Schedule's `function`,
|
|
28
28
|
not necessarily the source filename or the public URL. `sourceFile` optionally
|
|
29
29
|
identifies the original source for source-backed functions.
|
|
30
30
|
|
|
@@ -102,7 +102,25 @@ export declare function usingCorepack(env: {
|
|
|
102
102
|
* across multiple builds in the same Node process (e.g., in unit tests).
|
|
103
103
|
*/
|
|
104
104
|
export declare function resetCustomInstallCommandSet(): void;
|
|
105
|
-
|
|
105
|
+
interface WorkspaceInstallOptions {
|
|
106
|
+
targets: WorkspaceInstallTarget[];
|
|
107
|
+
}
|
|
108
|
+
export interface WorkspaceInstallTarget {
|
|
109
|
+
installRoot?: string;
|
|
110
|
+
isRoot?: boolean;
|
|
111
|
+
name?: string;
|
|
112
|
+
packageJsonPath: string;
|
|
113
|
+
relativePath: string;
|
|
114
|
+
}
|
|
115
|
+
export declare function getWorkspaceInstallCommand({ packageManager, targets, lockfileVersion, }: {
|
|
116
|
+
packageManager: CliType;
|
|
117
|
+
targets: WorkspaceInstallTarget[];
|
|
118
|
+
lockfileVersion: number | undefined;
|
|
119
|
+
}): {
|
|
120
|
+
command: CliType;
|
|
121
|
+
args: string[];
|
|
122
|
+
} | null;
|
|
123
|
+
export declare function runNpmInstall(destPath: string, args?: string[], spawnOpts?: SpawnOptions, meta?: Meta, projectCreatedAt?: number, output?: NpmInstallOutput, workspaceInstall?: WorkspaceInstallOptions): Promise<boolean>;
|
|
106
124
|
/**
|
|
107
125
|
* Prepares the input environment based on the used package manager and lockfile
|
|
108
126
|
* versions.
|
|
@@ -41,6 +41,7 @@ __export(run_user_scripts_exports, {
|
|
|
41
41
|
getPathOverrideForPackageManager: () => getPathOverrideForPackageManager,
|
|
42
42
|
getScriptName: () => getScriptName,
|
|
43
43
|
getSpawnOptions: () => getSpawnOptions,
|
|
44
|
+
getWorkspaceInstallCommand: () => getWorkspaceInstallCommand,
|
|
44
45
|
installDependencies: () => installDependencies,
|
|
45
46
|
resetCustomInstallCommandSet: () => resetCustomInstallCommandSet,
|
|
46
47
|
runBundleInstall: () => runBundleInstall,
|
|
@@ -582,7 +583,7 @@ function checkIfAlreadyInstalled(runNpmInstallSet, packageJsonPath) {
|
|
|
582
583
|
initializedRunNpmInstallSet.add(packageJsonPath);
|
|
583
584
|
return { alreadyInstalled, runNpmInstallSet: initializedRunNpmInstallSet };
|
|
584
585
|
}
|
|
585
|
-
const
|
|
586
|
+
const installSema = new import_async_sema.default(1);
|
|
586
587
|
function installCompletedCovers(packageJsonPath) {
|
|
587
588
|
if (process.env.VERCEL_INSTALL_COMPLETED !== "1") {
|
|
588
589
|
return false;
|
|
@@ -597,18 +598,90 @@ let customInstallCommandSet;
|
|
|
597
598
|
function resetCustomInstallCommandSet() {
|
|
598
599
|
customInstallCommandSet = void 0;
|
|
599
600
|
}
|
|
600
|
-
|
|
601
|
+
function getWorkspaceInstallCommand({
|
|
602
|
+
packageManager,
|
|
603
|
+
targets,
|
|
604
|
+
lockfileVersion
|
|
605
|
+
}) {
|
|
606
|
+
let commandArguments;
|
|
607
|
+
switch (packageManager) {
|
|
608
|
+
case "npm":
|
|
609
|
+
commandArguments = [
|
|
610
|
+
"install",
|
|
611
|
+
"--no-audit",
|
|
612
|
+
...targets.filter((target) => !target.isRoot).map((target) => `--workspace=${target.relativePath}`),
|
|
613
|
+
...targets.some((target) => target.isRoot) ? ["--include-workspace-root"] : []
|
|
614
|
+
];
|
|
615
|
+
break;
|
|
616
|
+
case "pnpm":
|
|
617
|
+
commandArguments = [
|
|
618
|
+
"install",
|
|
619
|
+
...targets.flatMap((target) => [
|
|
620
|
+
"--filter",
|
|
621
|
+
`{${target.relativePath}}...`
|
|
622
|
+
])
|
|
623
|
+
];
|
|
624
|
+
break;
|
|
625
|
+
case "yarn":
|
|
626
|
+
if (detectYarnVersion(lockfileVersion) !== "yarn@4.x")
|
|
627
|
+
return null;
|
|
628
|
+
if (targets.some((target) => !target.name))
|
|
629
|
+
return null;
|
|
630
|
+
commandArguments = [
|
|
631
|
+
"workspaces",
|
|
632
|
+
"focus",
|
|
633
|
+
...targets.map((target) => target.name)
|
|
634
|
+
];
|
|
635
|
+
break;
|
|
636
|
+
case "bun":
|
|
637
|
+
commandArguments = [
|
|
638
|
+
"install",
|
|
639
|
+
...targets.flatMap((target) => [
|
|
640
|
+
"--filter",
|
|
641
|
+
target.isRoot ? "./" : `./${target.relativePath}`
|
|
642
|
+
])
|
|
643
|
+
];
|
|
644
|
+
break;
|
|
645
|
+
}
|
|
646
|
+
if (!commandArguments)
|
|
647
|
+
return null;
|
|
648
|
+
if (process.env.NPM_ONLY_PRODUCTION) {
|
|
649
|
+
commandArguments.push(
|
|
650
|
+
packageManager === "pnpm" ? "--prod" : "--production"
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
return { command: packageManager, args: commandArguments };
|
|
654
|
+
}
|
|
655
|
+
async function runWorkspaceInstall({
|
|
656
|
+
packageManager,
|
|
657
|
+
targets,
|
|
658
|
+
opts,
|
|
659
|
+
lockfileVersion
|
|
660
|
+
}) {
|
|
661
|
+
const installCommand = getWorkspaceInstallCommand({
|
|
662
|
+
packageManager,
|
|
663
|
+
targets,
|
|
664
|
+
lockfileVersion
|
|
665
|
+
});
|
|
666
|
+
if (!installCommand)
|
|
667
|
+
return false;
|
|
668
|
+
opts.prettyCommand = `${installCommand.command} ${installCommand.args.join(" ")}`;
|
|
669
|
+
await spawnAsync(installCommand.command, installCommand.args, opts);
|
|
670
|
+
return true;
|
|
671
|
+
}
|
|
672
|
+
async function runNpmInstall(destPath, args = [], spawnOpts, meta, projectCreatedAt, output, workspaceInstall) {
|
|
601
673
|
if (meta?.isDev) {
|
|
602
674
|
(0, import_debug.default)("Skipping dependency installation because dev mode is enabled");
|
|
603
675
|
return false;
|
|
604
676
|
}
|
|
605
677
|
(0, import_assert.default)(import_path.default.isAbsolute(destPath));
|
|
606
678
|
try {
|
|
607
|
-
await
|
|
679
|
+
await installSema.acquire();
|
|
608
680
|
const {
|
|
609
681
|
cliType,
|
|
610
682
|
packageJsonPath,
|
|
611
683
|
packageJson,
|
|
684
|
+
lockfilePath,
|
|
612
685
|
lockfileVersion,
|
|
613
686
|
packageJsonPackageManager,
|
|
614
687
|
packageJsonDevEngines,
|
|
@@ -621,7 +694,21 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, projectCreate
|
|
|
621
694
|
return false;
|
|
622
695
|
}
|
|
623
696
|
const defaultInstall = args.length === 0;
|
|
624
|
-
|
|
697
|
+
const workspaceInstallRoot = lockfilePath ? import_path.default.dirname(lockfilePath) : void 0;
|
|
698
|
+
const workspaceCandidates = process.env.VERCEL_EXPERIMENTAL_WORKSPACE_SCOPED_INSTALLS === "1" && !installCompletedCovers(packageJsonPath) && defaultInstall && meta && workspaceInstall && workspaceInstallRoot ? workspaceInstall.targets.filter(
|
|
699
|
+
(target) => target.installRoot && import_path.default.normalize(target.installRoot) === import_path.default.normalize(workspaceInstallRoot)
|
|
700
|
+
) : null;
|
|
701
|
+
const workspaceTargets = workspaceCandidates?.length && getWorkspaceInstallCommand({
|
|
702
|
+
packageManager: cliType,
|
|
703
|
+
targets: workspaceCandidates,
|
|
704
|
+
lockfileVersion
|
|
705
|
+
}) ? workspaceCandidates : null;
|
|
706
|
+
if (workspaceTargets?.length && meta) {
|
|
707
|
+
const installed = initializeSet(meta.runNpmInstallSet);
|
|
708
|
+
if (workspaceTargets.every((target) => installed.has(target.packageJsonPath))) {
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
} else if (meta && packageJsonPath && defaultInstall) {
|
|
625
712
|
const { alreadyInstalled, runNpmInstallSet } = checkIfAlreadyInstalled(
|
|
626
713
|
meta.runNpmInstallSet,
|
|
627
714
|
packageJsonPath
|
|
@@ -645,7 +732,7 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, projectCreate
|
|
|
645
732
|
await spawnAsync(
|
|
646
733
|
"yarn",
|
|
647
734
|
["config", "set", "enableGlobalCache", "false"],
|
|
648
|
-
{ cwd: destPath }
|
|
735
|
+
{ cwd: destPath, env: spawnOpts?.env }
|
|
649
736
|
);
|
|
650
737
|
}
|
|
651
738
|
}
|
|
@@ -675,6 +762,24 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, projectCreate
|
|
|
675
762
|
`Warning: This project may see "Error: Dynamic require of "util" is not supported". To avoid this error, remove \`"type": "module"\` from your package.json file, or use \`yarnPath\` instead of Corepack. Learn more: https://vercel.com/docs/errors/error-list#yarn-dynamic-require-of-util-is-not-supported`
|
|
676
763
|
);
|
|
677
764
|
}
|
|
765
|
+
if (workspaceTargets?.length && workspaceInstallRoot && meta) {
|
|
766
|
+
const scopedOpts = { ...opts, cwd: workspaceInstallRoot };
|
|
767
|
+
const installed = await runWorkspaceInstall({
|
|
768
|
+
packageManager: cliType,
|
|
769
|
+
targets: workspaceTargets,
|
|
770
|
+
opts: scopedOpts,
|
|
771
|
+
lockfileVersion
|
|
772
|
+
});
|
|
773
|
+
if (installed) {
|
|
774
|
+
const installedPackages = initializeSet(meta.runNpmInstallSet);
|
|
775
|
+
for (const target of workspaceTargets) {
|
|
776
|
+
installedPackages.add(target.packageJsonPath);
|
|
777
|
+
}
|
|
778
|
+
meta.runNpmInstallSet = installedPackages;
|
|
779
|
+
(0, import_debug.default)(`Install complete [${Date.now() - installTime}ms]`);
|
|
780
|
+
return true;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
678
783
|
await runInstallCommand({
|
|
679
784
|
packageManager: cliType,
|
|
680
785
|
args,
|
|
@@ -684,7 +789,7 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, projectCreate
|
|
|
684
789
|
(0, import_debug.default)(`Install complete [${Date.now() - installTime}ms]`);
|
|
685
790
|
return true;
|
|
686
791
|
} finally {
|
|
687
|
-
|
|
792
|
+
installSema.release();
|
|
688
793
|
}
|
|
689
794
|
}
|
|
690
795
|
function resolveEffectiveBunVersion(nodeVersion, lockfileVersion) {
|
|
@@ -1361,6 +1466,7 @@ const installDependencies = (0, import_util.deprecate)(
|
|
|
1361
1466
|
getPathOverrideForPackageManager,
|
|
1362
1467
|
getScriptName,
|
|
1363
1468
|
getSpawnOptions,
|
|
1469
|
+
getWorkspaceInstallCommand,
|
|
1364
1470
|
installDependencies,
|
|
1365
1471
|
resetCustomInstallCommandSet,
|
|
1366
1472
|
runBundleInstall,
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import download, { downloadFile, type DownloadedFiles, isSymbolicLink, isDirecto
|
|
|
8
8
|
import getWriteableDirectory from './fs/get-writable-directory';
|
|
9
9
|
import glob, { type GlobOptions } from './fs/glob';
|
|
10
10
|
import rename from './fs/rename';
|
|
11
|
-
import { spawnAsync, execCommand, spawnCommand, getScriptName, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, detectPackageManager, getSpawnOptions, getNodeBinPath, getNodeBinPaths, scanParentDirs, type PipInstallResult, type NpmInstallOutput, type CliType } from './fs/run-user-scripts';
|
|
11
|
+
import { spawnAsync, execCommand, spawnCommand, getScriptName, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, detectPackageManager, getSpawnOptions, getNodeBinPath, getNodeBinPaths, scanParentDirs, type PipInstallResult, type NpmInstallOutput, type CliType, type WorkspaceInstallTarget } from './fs/run-user-scripts';
|
|
12
12
|
import { getLatestNodeVersion, getDiscontinuedNodeVersions, getSupportedNodeVersion, isBunVersion, getSupportedBunVersion } from './fs/node-version';
|
|
13
13
|
import { findPackageJson, walkParentDirs, traverseUpDirectories } from './fs/find-package-json';
|
|
14
14
|
import streamToBuffer, { streamToBufferChunks } from './fs/stream-to-buffer';
|
|
@@ -25,7 +25,7 @@ import { validateNpmrc } from './validate-npmrc';
|
|
|
25
25
|
export type { NodejsLambdaOptions, PrerenderInitialMetadata, PrerenderOnMiss };
|
|
26
26
|
export { createDaemonStaticFileFilter } from './daemon-static-publishing';
|
|
27
27
|
export type { LambdaAffinity } from './lambda';
|
|
28
|
-
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, type DownloadedFiles, getWriteableDirectory, glob, type GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, getNodeExecPath, getSupportedNodeVersion, isBunVersion, getSupportedBunVersion, getOrCreateBunBinary, detectPackageManager, runNpmInstall, type NpmInstallOutput, runBundleInstall, runPipInstall, type PipInstallResult, runShellScript, runCustomInstallCommand, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, getServiceUrlEnvVars, getExperimentalServiceUrlEnvVars, streamToBuffer, streamToBufferChunks, debug, isSymbolicLink, isDirectory, isExternalSymlink, isExternalSymlinkTarget, getSymlinkTarget, findMatchingFunction, getLambdaOptionsFromFunction, sanitizeConsumerName, scanParentDirs, findPackageJson, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, type CliType, };
|
|
28
|
+
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, type DownloadedFiles, getWriteableDirectory, glob, type GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, getNodeExecPath, getSupportedNodeVersion, isBunVersion, getSupportedBunVersion, getOrCreateBunBinary, detectPackageManager, runNpmInstall, type NpmInstallOutput, type WorkspaceInstallTarget, runBundleInstall, runPipInstall, type PipInstallResult, runShellScript, runCustomInstallCommand, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, getServiceUrlEnvVars, getExperimentalServiceUrlEnvVars, streamToBuffer, streamToBufferChunks, debug, isSymbolicLink, isDirectory, isExternalSymlink, isExternalSymlinkTarget, getSymlinkTarget, findMatchingFunction, getLambdaOptionsFromFunction, sanitizeConsumerName, scanParentDirs, findPackageJson, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, type CliType, };
|
|
29
29
|
export { EdgeFunction } from './edge-function';
|
|
30
30
|
export { ContainerImage } from './container-image';
|
|
31
31
|
export type { ContainerImageConfig } from './container-image';
|
|
@@ -82,3 +82,4 @@ export { validatePrerender } from './collect-build-result/validate-prerender';
|
|
|
82
82
|
export { getContentType } from './collect-build-result/get-content-type';
|
|
83
83
|
export { fileToBuildOutputFile, type BuildOutputFile, } from './collect-build-result/file-to-build-output-file';
|
|
84
84
|
export { prerenderToBuildOutputFile, type ExtendedPayload, } from './collect-build-result/prerender-to-build-output-file';
|
|
85
|
+
export { EMPTY_DISCOVERY, NAVIGATION_ACCEPT_RE, promoteStaticFiles, staticBundleExclusions, staticDirectoryRedirects, staticFallbackRoutes, staticShadowRoutes, type ShadowRoute, type StaticBundleExclusions, type StaticFallback, type StaticDiscovery, type StaticMount, type StaticPromotionOptions, type StaticPromotionResult, } from './static-files';
|