@vercel/build-utils
Advanced tools
Comparing version 7.1.1 to 7.2.0
# @vercel/build-utils | ||
## 7.2.0 | ||
### Minor Changes | ||
- Add new optional prerender field: experimentalStreamingLambdaPath ([#10476](https://github.com/vercel/vercel/pull/10476)) | ||
- [build-utils] Add zero config detection for bun package manager ([#10486](https://github.com/vercel/vercel/pull/10486)) | ||
### Patch Changes | ||
- add `experimentalBypassFor` field to Prerender ([#10481](https://github.com/vercel/vercel/pull/10481)) | ||
## 7.1.1 | ||
@@ -4,0 +16,0 @@ |
/// <reference types="node" /> | ||
import { SpawnOptions } from 'child_process'; | ||
import { Meta, PackageJson, NodeVersion, Config } from '../types'; | ||
export type CliType = 'yarn' | 'npm' | 'pnpm'; | ||
export type CliType = 'yarn' | 'npm' | 'pnpm' | 'bun'; | ||
export interface ScanParentDirsResult { | ||
@@ -6,0 +6,0 @@ /** |
@@ -210,6 +210,11 @@ "use strict"; | ||
const packageJson = readPackageJson && pkgJsonPath ? JSON.parse(await import_fs_extra.default.readFile(pkgJsonPath, "utf8")) : void 0; | ||
const [yarnLockPath, npmLockPath, pnpmLockPath] = await walkParentDirsMulti({ | ||
const [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath] = await walkParentDirsMulti({ | ||
base: "/", | ||
start: destPath, | ||
filenames: ["yarn.lock", "package-lock.json", "pnpm-lock.yaml"] | ||
filenames: [ | ||
"yarn.lock", | ||
"package-lock.json", | ||
"pnpm-lock.yaml", | ||
"bun.lockb" | ||
] | ||
}); | ||
@@ -219,6 +224,7 @@ let lockfilePath; | ||
let cliType = "yarn"; | ||
const [hasYarnLock, packageLockJson, pnpmLockYaml] = await Promise.all([ | ||
const [hasYarnLock, packageLockJson, pnpmLockYaml, bunLockBin] = await Promise.all([ | ||
Boolean(yarnLockPath), | ||
npmLockPath ? (0, import_read_config_file.readConfigFile)(npmLockPath) : null, | ||
pnpmLockPath ? (0, import_read_config_file.readConfigFile)(pnpmLockPath) : null | ||
pnpmLockPath ? (0, import_read_config_file.readConfigFile)(pnpmLockPath) : null, | ||
bunLockPath ? import_fs_extra.default.readFile(bunLockPath, "utf8") : null | ||
]); | ||
@@ -236,2 +242,6 @@ if (hasYarnLock) { | ||
lockfileVersion = packageLockJson.lockfileVersion; | ||
} else if (bunLockBin) { | ||
cliType = "bun"; | ||
lockfilePath = bunLockPath; | ||
lockfileVersion = 0; | ||
} | ||
@@ -328,2 +338,5 @@ const packageJsonPath = pkgJsonPath || void 0; | ||
commandArgs = args.filter((a) => a !== "--prefer-offline").concat(["install", "--unsafe-perm"]); | ||
} else if (cliType === "bun") { | ||
opts.prettyCommand = "bun install"; | ||
commandArgs = ["install", ...args]; | ||
} else { | ||
@@ -371,2 +384,3 @@ opts.prettyCommand = "yarn install"; | ||
const pnpm8 = "/pnpm8/node_modules/.bin"; | ||
const bun1 = "/bun1"; | ||
const corepackEnabled = env.ENABLE_EXPERIMENTAL_COREPACK === "1"; | ||
@@ -376,3 +390,3 @@ if (cliType === "npm") { | ||
newEnv.PATH = `${npm7}${import_path.default.delimiter}${oldPath}`; | ||
console.log("Detected `package-lock.json` generated by npm 7+..."); | ||
console.log("Detected `package-lock.json` generated by npm 7+"); | ||
} | ||
@@ -383,3 +397,3 @@ } else if (cliType === "pnpm") { | ||
console.log( | ||
`Detected \`pnpm-lock.yaml\` version ${lockfileVersion} generated by pnpm 7...` | ||
`Detected \`pnpm-lock.yaml\` version ${lockfileVersion} generated by pnpm 7` | ||
); | ||
@@ -389,5 +403,13 @@ } else if (typeof lockfileVersion === "number" && lockfileVersion >= 6 && !oldPath.includes(pnpm8) && !corepackEnabled) { | ||
console.log( | ||
`Detected \`pnpm-lock.yaml\` version ${lockfileVersion} generated by pnpm 8...` | ||
`Detected \`pnpm-lock.yaml\` version ${lockfileVersion} generated by pnpm 8` | ||
); | ||
} | ||
} else if (cliType === "bun") { | ||
if (!oldPath.includes(bun1) && !corepackEnabled) { | ||
newEnv.PATH = `${bun1}${import_path.default.delimiter}${oldPath}`; | ||
console.log("Detected `bun.lockb` generated by Bun"); | ||
console.warn( | ||
"Warning: Bun is used as a package manager at build time only, not at runtime with Functions" | ||
); | ||
} | ||
} else { | ||
@@ -449,2 +471,4 @@ if (!env.YARN_NODE_LINKER) { | ||
opts.prettyCommand = `pnpm run ${scriptName}`; | ||
} else if (cliType === "bun") { | ||
opts.prettyCommand = `bun run ${scriptName}`; | ||
} else { | ||
@@ -451,0 +475,0 @@ opts.prettyCommand = `yarn run ${scriptName}`; |
@@ -1,2 +0,2 @@ | ||
import { File } from './types'; | ||
import type { File, HasField } from './types'; | ||
import { Lambda } from './lambda'; | ||
@@ -14,2 +14,4 @@ interface PrerenderOptions { | ||
sourcePath?: string; | ||
experimentalBypassFor?: HasField; | ||
experimentalStreamingLambdaPath?: string; | ||
} | ||
@@ -28,4 +30,6 @@ export declare class Prerender { | ||
sourcePath?: string; | ||
constructor({ expiration, lambda, fallback, group, bypassToken, allowQuery, initialHeaders, initialStatus, passQuery, sourcePath, }: PrerenderOptions); | ||
experimentalBypassFor?: HasField; | ||
experimentalStreamingLambdaPath?: string; | ||
constructor({ expiration, lambda, fallback, group, bypassToken, allowQuery, initialHeaders, initialStatus, passQuery, sourcePath, experimentalBypassFor, experimentalStreamingLambdaPath, }: PrerenderOptions); | ||
} | ||
export {}; |
@@ -35,3 +35,5 @@ "use strict"; | ||
passQuery, | ||
sourcePath | ||
sourcePath, | ||
experimentalBypassFor, | ||
experimentalStreamingLambdaPath | ||
}) { | ||
@@ -72,2 +74,13 @@ this.type = "Prerender"; | ||
} | ||
if (experimentalBypassFor !== void 0) { | ||
if (!Array.isArray(experimentalBypassFor) || experimentalBypassFor.some( | ||
(field) => typeof field !== "object" || // host doesn't need a key | ||
field.type !== "host" && typeof field.key !== "string" || typeof field.type !== "string" || field.value !== void 0 && typeof field.value !== "string" | ||
)) { | ||
throw new Error( | ||
"The `experimentalBypassFor` argument for `Prerender` must be Array of objects with fields `type`, `key` and optionally `value`." | ||
); | ||
} | ||
this.experimentalBypassFor = experimentalBypassFor; | ||
} | ||
if (typeof fallback === "undefined") { | ||
@@ -110,2 +123,10 @@ throw new Error( | ||
} | ||
if (experimentalStreamingLambdaPath !== void 0) { | ||
if (typeof experimentalStreamingLambdaPath !== "string") { | ||
throw new Error( | ||
"The `experimentalStreamingLambdaPath` argument for `Prerender` must be a string." | ||
); | ||
} | ||
this.experimentalStreamingLambdaPath = experimentalStreamingLambdaPath; | ||
} | ||
} | ||
@@ -112,0 +133,0 @@ } |
@@ -46,2 +46,10 @@ /// <reference types="node" /> | ||
} | ||
export type HasField = Array<{ | ||
type: 'host'; | ||
value: string; | ||
} | { | ||
type: 'header' | 'cookie' | 'query'; | ||
key: string; | ||
value?: string; | ||
}>; | ||
export interface Meta { | ||
@@ -48,0 +56,0 @@ isDev?: boolean; |
{ | ||
"name": "@vercel/build-utils", | ||
"version": "7.1.1", | ||
"version": "7.2.0", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1192077
26824