@vercel/build-utils 13.26.1 → 13.26.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
+ ## 13.26.3
4
+
5
+ ### Patch Changes
6
+
7
+ - b66bd3e: Fix prebuilt deployments failing with "invalid relative path" when using the `--standalone` flag in pnpm monorepos by skipping external node_modules symlinks and copying traced files at their logical paths instead.
8
+
9
+ ## 13.26.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 647c1e8: Cleanup getLambdaSupportsStreaming
14
+
3
15
  ## 13.26.1
4
16
 
5
17
  ### Patch Changes
@@ -1,7 +1,6 @@
1
1
  import type { Lambda } from './lambda';
2
2
  import type { NodejsLambda } from './nodejs-lambda';
3
3
  import type { BytecodeCachingOptions } from './process-serverless/get-lambda-preload-scripts';
4
- import type { SupportsStreamingResult } from './process-serverless/get-lambda-supports-streaming';
5
4
  /**
6
5
  * Optional wrapper around async work, allowing callers to inject tracing
7
6
  * (e.g. dd-trace spans) without coupling the shared code to a tracer.
@@ -59,8 +58,6 @@ export interface FinalizeLambdaResult {
59
58
  /** Compressed size in bytes. */
60
59
  size: number;
61
60
  uncompressedBytes: number;
62
- /** Non-fatal streaming detection error, if any. Caller decides how to log. */
63
- streamingError?: SupportsStreamingResult['error'];
64
61
  }
65
62
  /**
66
63
  * Core Lambda finalization logic shared between BYOF and build-container.
@@ -98,18 +98,17 @@ async function finalizeLambda(params) {
98
98
  bytecodeCachingOptions
99
99
  )
100
100
  };
101
- const streamingResult = await (0, import_get_lambda_supports_streaming.getLambdaSupportsStreaming)(
101
+ const streamingResult = (0, import_get_lambda_supports_streaming.getLambdaSupportsStreaming)(
102
102
  lambda,
103
103
  forceStreamingRuntime
104
104
  );
105
- lambda.supportsResponseStreaming = streamingResult.supportsStreaming;
105
+ lambda.supportsResponseStreaming = streamingResult;
106
106
  return {
107
107
  buffer: zipResult.buffer,
108
108
  zipPath: zipResult.zipPath ?? null,
109
109
  digest: zipResult.digest,
110
110
  size: zipResult.size,
111
- uncompressedBytes,
112
- streamingError: streamingResult.error
111
+ uncompressedBytes
113
112
  };
114
113
  }
115
114
  // Annotate the CommonJS export names for ESM import in node:
@@ -5,5 +5,8 @@ export interface DownloadedFiles {
5
5
  }
6
6
  export declare function isDirectory(mode: number): boolean;
7
7
  export declare function isSymbolicLink(mode: number): boolean;
8
+ export declare function isExternalSymlinkTarget(target: string): boolean;
9
+ export declare function getSymlinkTarget(file: File): string | null;
10
+ export declare function isExternalSymlink(file: File): boolean;
8
11
  export declare function downloadFile(file: File, fsPath: string): Promise<FileFsRef>;
9
12
  export default function download(files: Files, basePath: string, meta?: Meta): Promise<DownloadedFiles>;
@@ -30,7 +30,10 @@ var download_exports = {};
30
30
  __export(download_exports, {
31
31
  default: () => download,
32
32
  downloadFile: () => downloadFile,
33
+ getSymlinkTarget: () => getSymlinkTarget,
33
34
  isDirectory: () => isDirectory,
35
+ isExternalSymlink: () => isExternalSymlink,
36
+ isExternalSymlinkTarget: () => isExternalSymlinkTarget,
34
37
  isSymbolicLink: () => isSymbolicLink
35
38
  });
36
39
  module.exports = __toCommonJS(download_exports);
@@ -48,6 +51,30 @@ function isDirectory(mode) {
48
51
  function isSymbolicLink(mode) {
49
52
  return (mode & S_IFMT) === S_IFLNK;
50
53
  }
54
+ function isExternalSymlinkTarget(target) {
55
+ return target.startsWith("../") || target.startsWith("..\\") || import_path.default.isAbsolute(target);
56
+ }
57
+ function getSymlinkTarget(file) {
58
+ if (!isSymbolicLink(file.mode)) {
59
+ return null;
60
+ }
61
+ if (file.type === "FileFsRef") {
62
+ try {
63
+ return (0, import_fs_extra.readlinkSync)(file.fsPath);
64
+ } catch {
65
+ return null;
66
+ }
67
+ }
68
+ if (file.type === "FileBlob") {
69
+ const { data } = file;
70
+ return typeof data === "string" ? data : data.toString("utf8");
71
+ }
72
+ return null;
73
+ }
74
+ function isExternalSymlink(file) {
75
+ const target = getSymlinkTarget(file);
76
+ return target !== null && isExternalSymlinkTarget(target);
77
+ }
51
78
  async function prepareSymlinkTarget(file, fsPath) {
52
79
  const mkdirPromise = (0, import_fs_extra.mkdirp)(import_path.default.dirname(fsPath));
53
80
  if (file.type === "FileFsRef") {
@@ -124,7 +151,7 @@ async function download(files, basePath, meta) {
124
151
  for (let i = 1; i < parts.length; i++) {
125
152
  const dir = parts.slice(0, i).join("/");
126
153
  const parent = files[dir];
127
- if (parent && isSymbolicLink(parent.mode)) {
154
+ if (parent && isSymbolicLink(parent.mode) && !isExternalSymlink(parent)) {
128
155
  console.warn(
129
156
  `Warning: file "${name}" is within a symlinked directory "${dir}" and will be ignored`
130
157
  );
@@ -143,6 +170,9 @@ async function download(files, basePath, meta) {
143
170
  // Annotate the CommonJS export names for ESM import in node:
144
171
  0 && (module.exports = {
145
172
  downloadFile,
173
+ getSymlinkTarget,
146
174
  isDirectory,
175
+ isExternalSymlink,
176
+ isExternalSymlinkTarget,
147
177
  isSymbolicLink
148
178
  });
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import FileRef from './file-ref';
4
4
  import { Lambda, createLambda, getLambdaOptionsFromFunction, sanitizeConsumerName } from './lambda';
5
5
  import { NodejsLambda, type NodejsLambdaOptions } from './nodejs-lambda';
6
6
  import { Prerender } from './prerender';
7
- import download, { downloadFile, DownloadedFiles, isSymbolicLink, isDirectory } from './fs/download';
7
+ import download, { downloadFile, DownloadedFiles, isSymbolicLink, isDirectory, isExternalSymlink, isExternalSymlinkTarget, getSymlinkTarget } from './fs/download';
8
8
  import getWriteableDirectory from './fs/get-writable-directory';
9
9
  import glob, { GlobOptions } from './fs/glob';
10
10
  import rename from './fs/rename';
@@ -20,7 +20,7 @@ import { cloneEnv } from './clone-env';
20
20
  import { hardLinkDir } from './hard-link-dir';
21
21
  import { validateNpmrc } from './validate-npmrc';
22
22
  export type { NodejsLambdaOptions };
23
- export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, getSupportedNodeVersion, isBunVersion, getSupportedBunVersion, detectPackageManager, runNpmInstall, NpmInstallOutput, runBundleInstall, runPipInstall, PipInstallResult, runShellScript, runCustomInstallCommand, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, getServiceUrlEnvVars, getExperimentalServiceUrlEnvVars, streamToBuffer, streamToBufferChunks, debug, isSymbolicLink, isDirectory, getLambdaOptionsFromFunction, sanitizeConsumerName, scanParentDirs, findPackageJson, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, };
23
+ export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, getSupportedNodeVersion, isBunVersion, getSupportedBunVersion, detectPackageManager, runNpmInstall, NpmInstallOutput, runBundleInstall, runPipInstall, PipInstallResult, runShellScript, runCustomInstallCommand, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, getServiceUrlEnvVars, getExperimentalServiceUrlEnvVars, streamToBuffer, streamToBufferChunks, debug, isSymbolicLink, isDirectory, isExternalSymlink, isExternalSymlinkTarget, getSymlinkTarget, getLambdaOptionsFromFunction, sanitizeConsumerName, scanParentDirs, findPackageJson, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, };
24
24
  export { EdgeFunction } from './edge-function';
25
25
  export { readConfigFile, getPackageJson } from './fs/read-config-file';
26
26
  export { normalizePath } from './fs/normalize-path';
@@ -43,7 +43,7 @@ export * from './service-path-utils';
43
43
  export { getEncryptedEnv, type EncryptedEnvFile, } from './process-serverless/get-encrypted-env-file';
44
44
  export { getLambdaEnvironment } from './process-serverless/get-lambda-environment';
45
45
  export { getLambdaPreloadScripts, type BytecodeCachingOptions, } from './process-serverless/get-lambda-preload-scripts';
46
- export { getLambdaSupportsStreaming, type SupportsStreamingResult, } from './process-serverless/get-lambda-supports-streaming';
46
+ export { getLambdaSupportsStreaming } from './process-serverless/get-lambda-supports-streaming';
47
47
  export { streamToDigestAsync, sha256, md5, type FileDigest, } from './fs/stream-to-digest-async';
48
48
  export { getBuildResultMetadata, type BuildResultMetadata, } from './collect-build-result/get-build-result-metadata';
49
49
  export { validateBuildResult, SUPPORTED_AL2023_RUNTIMES, type ValidateBuildResultParams, type ValidateBuildResultResult, } from './collect-build-result/validate-build-result';
package/dist/index.js CHANGED
@@ -34571,6 +34571,7 @@ __export(src_exports, {
34571
34571
  getSpawnOptions: () => getSpawnOptions,
34572
34572
  getSupportedBunVersion: () => getSupportedBunVersion,
34573
34573
  getSupportedNodeVersion: () => getSupportedNodeVersion,
34574
+ getSymlinkTarget: () => getSymlinkTarget,
34574
34575
  getWriteableDirectory: () => getWritableDirectory,
34575
34576
  glob: () => glob,
34576
34577
  hardLinkDir: () => hardLinkDir,
@@ -34582,6 +34583,8 @@ __export(src_exports, {
34582
34583
  isDirectory: () => isDirectory,
34583
34584
  isExperimentalBackendsEnabled: () => isExperimentalBackendsEnabled,
34584
34585
  isExperimentalBackendsWithoutIntrospectionEnabled: () => isExperimentalBackendsWithoutIntrospectionEnabled,
34586
+ isExternalSymlink: () => isExternalSymlink,
34587
+ isExternalSymlinkTarget: () => isExternalSymlinkTarget,
34585
34588
  isNodeBackendFramework: () => isNodeBackendFramework,
34586
34589
  isNodeEntrypoint: () => isNodeEntrypoint,
34587
34590
  isPythonEntrypoint: () => isPythonEntrypoint,
@@ -35053,6 +35056,30 @@ function isDirectory(mode) {
35053
35056
  function isSymbolicLink(mode) {
35054
35057
  return (mode & S_IFMT) === S_IFLNK;
35055
35058
  }
35059
+ function isExternalSymlinkTarget(target) {
35060
+ return target.startsWith("../") || target.startsWith("..\\") || import_path2.default.isAbsolute(target);
35061
+ }
35062
+ function getSymlinkTarget(file) {
35063
+ if (!isSymbolicLink(file.mode)) {
35064
+ return null;
35065
+ }
35066
+ if (file.type === "FileFsRef") {
35067
+ try {
35068
+ return (0, import_fs_extra2.readlinkSync)(file.fsPath);
35069
+ } catch {
35070
+ return null;
35071
+ }
35072
+ }
35073
+ if (file.type === "FileBlob") {
35074
+ const { data } = file;
35075
+ return typeof data === "string" ? data : data.toString("utf8");
35076
+ }
35077
+ return null;
35078
+ }
35079
+ function isExternalSymlink(file) {
35080
+ const target = getSymlinkTarget(file);
35081
+ return target !== null && isExternalSymlinkTarget(target);
35082
+ }
35056
35083
  async function prepareSymlinkTarget(file, fsPath) {
35057
35084
  const mkdirPromise = (0, import_fs_extra2.mkdirp)(import_path2.default.dirname(fsPath));
35058
35085
  if (file.type === "FileFsRef") {
@@ -35129,7 +35156,7 @@ async function download(files, basePath, meta) {
35129
35156
  for (let i = 1; i < parts.length; i++) {
35130
35157
  const dir = parts.slice(0, i).join("/");
35131
35158
  const parent = files[dir];
35132
- if (parent && isSymbolicLink(parent.mode)) {
35159
+ if (parent && isSymbolicLink(parent.mode) && !isExternalSymlink(parent)) {
35133
35160
  console.warn(
35134
35161
  `Warning: file "${name}" is within a symlinked directory "${dir}" and will be ignored`
35135
35162
  );
@@ -39327,20 +39354,20 @@ function getLambdaEnvironment(lambda, buffer, options) {
39327
39354
  }
39328
39355
 
39329
39356
  // src/process-serverless/get-lambda-supports-streaming.ts
39330
- async function getLambdaSupportsStreaming(lambda, forceStreamingRuntime) {
39357
+ function getLambdaSupportsStreaming(lambda, forceStreamingRuntime) {
39331
39358
  if (lambda.awsLambdaHandler) {
39332
- return { supportsStreaming: false };
39359
+ return false;
39333
39360
  }
39334
39361
  if (forceStreamingRuntime) {
39335
- return { supportsStreaming: true };
39362
+ return true;
39336
39363
  }
39337
39364
  if (typeof lambda.supportsResponseStreaming === "boolean") {
39338
- return { supportsStreaming: lambda.supportsResponseStreaming };
39365
+ return lambda.supportsResponseStreaming;
39339
39366
  }
39340
39367
  if ("launcherType" in lambda && lambda.launcherType === "Nodejs") {
39341
- return { supportsStreaming: true };
39368
+ return true;
39342
39369
  }
39343
- return { supportsStreaming: void 0 };
39370
+ return void 0;
39344
39371
  }
39345
39372
 
39346
39373
  // src/fs/stream-to-digest-async.ts
@@ -39710,18 +39737,17 @@ async function finalizeLambda(params) {
39710
39737
  bytecodeCachingOptions
39711
39738
  )
39712
39739
  };
39713
- const streamingResult = await getLambdaSupportsStreaming(
39740
+ const streamingResult = getLambdaSupportsStreaming(
39714
39741
  lambda,
39715
39742
  forceStreamingRuntime
39716
39743
  );
39717
- lambda.supportsResponseStreaming = streamingResult.supportsStreaming;
39744
+ lambda.supportsResponseStreaming = streamingResult;
39718
39745
  return {
39719
39746
  buffer: zipResult.buffer,
39720
39747
  zipPath: zipResult.zipPath ?? null,
39721
39748
  digest: zipResult.digest,
39722
39749
  size: zipResult.size,
39723
- uncompressedBytes,
39724
- streamingError: streamingResult.error
39750
+ uncompressedBytes
39725
39751
  };
39726
39752
  }
39727
39753
 
@@ -40382,6 +40408,7 @@ function getExtendedPayload({
40382
40408
  getSpawnOptions,
40383
40409
  getSupportedBunVersion,
40384
40410
  getSupportedNodeVersion,
40411
+ getSymlinkTarget,
40385
40412
  getWriteableDirectory,
40386
40413
  glob,
40387
40414
  hardLinkDir,
@@ -40393,6 +40420,8 @@ function getExtendedPayload({
40393
40420
  isDirectory,
40394
40421
  isExperimentalBackendsEnabled,
40395
40422
  isExperimentalBackendsWithoutIntrospectionEnabled,
40423
+ isExternalSymlink,
40424
+ isExternalSymlinkTarget,
40396
40425
  isNodeBackendFramework,
40397
40426
  isNodeEntrypoint,
40398
40427
  isPythonEntrypoint,
@@ -5,13 +5,6 @@ interface LambdaLike {
5
5
  runtime: string;
6
6
  supportsResponseStreaming?: boolean;
7
7
  }
8
- export interface SupportsStreamingResult {
9
- supportsStreaming: boolean | undefined;
10
- error?: {
11
- handler: string;
12
- message: string;
13
- };
14
- }
15
8
  /**
16
9
  * Determines if a Lambda should have streaming enabled.
17
10
  *
@@ -25,5 +18,5 @@ export interface SupportsStreamingResult {
25
18
  * enabled. If the setting is defined it will be honored. Enabled by
26
19
  * default for Node.js.
27
20
  */
28
- export declare function getLambdaSupportsStreaming(lambda: LambdaLike, forceStreamingRuntime: boolean): Promise<SupportsStreamingResult>;
21
+ export declare function getLambdaSupportsStreaming(lambda: LambdaLike, forceStreamingRuntime: boolean): boolean | undefined;
29
22
  export {};
@@ -21,20 +21,20 @@ __export(get_lambda_supports_streaming_exports, {
21
21
  getLambdaSupportsStreaming: () => getLambdaSupportsStreaming
22
22
  });
23
23
  module.exports = __toCommonJS(get_lambda_supports_streaming_exports);
24
- async function getLambdaSupportsStreaming(lambda, forceStreamingRuntime) {
24
+ function getLambdaSupportsStreaming(lambda, forceStreamingRuntime) {
25
25
  if (lambda.awsLambdaHandler) {
26
- return { supportsStreaming: false };
26
+ return false;
27
27
  }
28
28
  if (forceStreamingRuntime) {
29
- return { supportsStreaming: true };
29
+ return true;
30
30
  }
31
31
  if (typeof lambda.supportsResponseStreaming === "boolean") {
32
- return { supportsStreaming: lambda.supportsResponseStreaming };
32
+ return lambda.supportsResponseStreaming;
33
33
  }
34
34
  if ("launcherType" in lambda && lambda.launcherType === "Nodejs") {
35
- return { supportsStreaming: true };
35
+ return true;
36
36
  }
37
- return { supportsStreaming: void 0 };
37
+ return void 0;
38
38
  }
39
39
  // Annotate the CommonJS export names for ESM import in node:
40
40
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "13.26.1",
3
+ "version": "13.26.3",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -55,8 +55,8 @@
55
55
  "vitest": "2.0.1",
56
56
  "typescript": "4.9.5",
57
57
  "yazl": "2.5.1",
58
- "@vercel/routing-utils": "6.2.0",
59
- "@vercel/error-utils": "2.1.0"
58
+ "@vercel/error-utils": "2.1.0",
59
+ "@vercel/routing-utils": "6.2.0"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "node build.mjs",