@vercel/build-utils 10.5.0 → 10.6.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 +16 -0
- package/dist/fs/run-user-scripts.js +16 -1
- package/dist/index.js +52 -60
- package/dist/lambda.d.ts +1 -1
- package/dist/lambda.js +1 -0
- package/dist/schemas.d.ts +4 -0
- package/dist/schemas.js +5 -1
- package/dist/types.d.ts +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# @vercel/build-utils
|
2
2
|
|
3
|
+
## 10.6.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- provide a more verbose error when package.json is not valid ([#13346](https://github.com/vercel/vercel/pull/13346))
|
8
|
+
|
9
|
+
- Allow configuring functions `architecture` via the `vercel.json` configuration ([#13344](https://github.com/vercel/vercel/pull/13344))
|
10
|
+
|
11
|
+
## 10.5.1
|
12
|
+
|
13
|
+
### Patch Changes
|
14
|
+
|
15
|
+
- Display warning when yarn dynamic require error may happen ([#13143](https://github.com/vercel/vercel/pull/13143))
|
16
|
+
|
17
|
+
- [build-utils] increase max memory limit ([#13162](https://github.com/vercel/vercel/pull/13162))
|
18
|
+
|
3
19
|
## 10.5.0
|
4
20
|
|
5
21
|
### Minor Changes
|
@@ -239,7 +239,16 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
239
239
|
start: destPath,
|
240
240
|
filename: "package.json"
|
241
241
|
});
|
242
|
-
|
242
|
+
let packageJson;
|
243
|
+
if (readPackageJson && pkgJsonPath) {
|
244
|
+
try {
|
245
|
+
packageJson = JSON.parse(await import_fs_extra.default.readFile(pkgJsonPath, "utf8"));
|
246
|
+
} catch (err) {
|
247
|
+
throw new Error(
|
248
|
+
`Could not read ${pkgJsonPath}: ${err.message}.`
|
249
|
+
);
|
250
|
+
}
|
251
|
+
}
|
243
252
|
const {
|
244
253
|
paths: [
|
245
254
|
yarnLockPath,
|
@@ -547,6 +556,12 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion,
|
|
547
556
|
turboSupportsCorepackHome,
|
548
557
|
projectCreatedAt
|
549
558
|
});
|
559
|
+
const maySeeDynamicRequireYarnBug = process.env?.ENABLE_EXPERIMENTAL_COREPACK && packageJson?.packageManager?.startsWith("yarn") && packageJson?.type === "module";
|
560
|
+
if (maySeeDynamicRequireYarnBug) {
|
561
|
+
console.warn(
|
562
|
+
`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`
|
563
|
+
);
|
564
|
+
}
|
550
565
|
await runInstallCommand({
|
551
566
|
packageManager: cliType,
|
552
567
|
args,
|
package/dist/index.js
CHANGED
@@ -10825,9 +10825,9 @@ var require_fs2 = __commonJS({
|
|
10825
10825
|
}
|
10826
10826
|
});
|
10827
10827
|
|
10828
|
-
// ../../node_modules/.pnpm/minimatch@5.1
|
10828
|
+
// ../../node_modules/.pnpm/minimatch@5.0.1/node_modules/minimatch/lib/path.js
|
10829
10829
|
var require_path = __commonJS({
|
10830
|
-
"../../node_modules/.pnpm/minimatch@5.1
|
10830
|
+
"../../node_modules/.pnpm/minimatch@5.0.1/node_modules/minimatch/lib/path.js"(exports2, module2) {
|
10831
10831
|
var isWindows = typeof process === "object" && process && process.platform === "win32";
|
10832
10832
|
module2.exports = isWindows ? { sep: "\\" } : { sep: "/" };
|
10833
10833
|
}
|
@@ -10984,9 +10984,9 @@ var require_brace_expansion2 = __commonJS({
|
|
10984
10984
|
}
|
10985
10985
|
});
|
10986
10986
|
|
10987
|
-
// ../../node_modules/.pnpm/minimatch@5.1
|
10987
|
+
// ../../node_modules/.pnpm/minimatch@5.0.1/node_modules/minimatch/minimatch.js
|
10988
10988
|
var require_minimatch2 = __commonJS({
|
10989
|
-
"../../node_modules/.pnpm/minimatch@5.1
|
10989
|
+
"../../node_modules/.pnpm/minimatch@5.0.1/node_modules/minimatch/minimatch.js"(exports2, module2) {
|
10990
10990
|
var minimatch2 = module2.exports = (p, pattern, options = {}) => {
|
10991
10991
|
assertValidPattern(pattern);
|
10992
10992
|
if (!options.nocomment && pattern.charAt(0) === "#") {
|
@@ -11072,9 +11072,7 @@ var require_minimatch2 = __commonJS({
|
|
11072
11072
|
return list;
|
11073
11073
|
};
|
11074
11074
|
var globUnescape = (s) => s.replace(/\\(.)/g, "$1");
|
11075
|
-
var charUnescape = (s) => s.replace(/\\([^-\]])/g, "$1");
|
11076
11075
|
var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
11077
|
-
var braExpEscape = (s) => s.replace(/[[\]\\]/g, "\\$&");
|
11078
11076
|
var Minimatch = class {
|
11079
11077
|
constructor(pattern, options) {
|
11080
11078
|
assertValidPattern(pattern);
|
@@ -11083,10 +11081,6 @@ var require_minimatch2 = __commonJS({
|
|
11083
11081
|
this.options = options;
|
11084
11082
|
this.set = [];
|
11085
11083
|
this.pattern = pattern;
|
11086
|
-
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
|
11087
|
-
if (this.windowsPathsNoEscape) {
|
11088
|
-
this.pattern = this.pattern.replace(/\\/g, "/");
|
11089
|
-
}
|
11090
11084
|
this.regexp = null;
|
11091
11085
|
this.negate = false;
|
11092
11086
|
this.comment = false;
|
@@ -11131,7 +11125,7 @@ var require_minimatch2 = __commonJS({
|
|
11131
11125
|
negateOffset++;
|
11132
11126
|
}
|
11133
11127
|
if (negateOffset)
|
11134
|
-
this.pattern = pattern.
|
11128
|
+
this.pattern = pattern.substr(negateOffset);
|
11135
11129
|
this.negate = negate;
|
11136
11130
|
}
|
11137
11131
|
// set partial to true to test if, for example,
|
@@ -11222,7 +11216,7 @@ var require_minimatch2 = __commonJS({
|
|
11222
11216
|
if (pattern === "")
|
11223
11217
|
return "";
|
11224
11218
|
let re = "";
|
11225
|
-
let hasMagic =
|
11219
|
+
let hasMagic = !!options.nocase;
|
11226
11220
|
let escaping = false;
|
11227
11221
|
const patternListStack = [];
|
11228
11222
|
const negativeLists = [];
|
@@ -11233,10 +11227,7 @@ var require_minimatch2 = __commonJS({
|
|
11233
11227
|
let cs;
|
11234
11228
|
let pl;
|
11235
11229
|
let sp;
|
11236
|
-
|
11237
|
-
let dotFileAllowed = options.dot || dotTravAllowed;
|
11238
|
-
const patternStart = () => dotTravAllowed ? "" : dotFileAllowed ? "(?!(?:^|\\/)\\.{1,2}(?:$|\\/))" : "(?!\\.)";
|
11239
|
-
const subPatternStart = (p) => p.charAt(0) === "." ? "" : options.dot ? "(?!(?:^|\\/)\\.{1,2}(?:$|\\/))" : "(?!\\.)";
|
11230
|
+
const patternStart = pattern.charAt(0) === "." ? "" : options.dot ? "(?!(?:^|\\/)\\.{1,2}(?:$|\\/))" : "(?!\\.)";
|
11240
11231
|
const clearStateChar = () => {
|
11241
11232
|
if (stateChar) {
|
11242
11233
|
switch (stateChar) {
|
@@ -11274,10 +11265,6 @@ var require_minimatch2 = __commonJS({
|
|
11274
11265
|
return false;
|
11275
11266
|
}
|
11276
11267
|
case "\\":
|
11277
|
-
if (inClass && pattern.charAt(i + 1) === "-") {
|
11278
|
-
re += c;
|
11279
|
-
continue;
|
11280
|
-
}
|
11281
11268
|
clearStateChar();
|
11282
11269
|
escaping = true;
|
11283
11270
|
continue;
|
@@ -11300,7 +11287,7 @@ var require_minimatch2 = __commonJS({
|
|
11300
11287
|
if (options.noext)
|
11301
11288
|
clearStateChar();
|
11302
11289
|
continue;
|
11303
|
-
case "(":
|
11290
|
+
case "(":
|
11304
11291
|
if (inClass) {
|
11305
11292
|
re += "(";
|
11306
11293
|
continue;
|
@@ -11309,54 +11296,39 @@ var require_minimatch2 = __commonJS({
|
|
11309
11296
|
re += "\\(";
|
11310
11297
|
continue;
|
11311
11298
|
}
|
11312
|
-
|
11299
|
+
patternListStack.push({
|
11313
11300
|
type: stateChar,
|
11314
11301
|
start: i - 1,
|
11315
11302
|
reStart: re.length,
|
11316
11303
|
open: plTypes[stateChar].open,
|
11317
11304
|
close: plTypes[stateChar].close
|
11318
|
-
};
|
11319
|
-
|
11320
|
-
patternListStack.push(plEntry);
|
11321
|
-
re += plEntry.open;
|
11322
|
-
if (plEntry.start === 0 && plEntry.type !== "!") {
|
11323
|
-
dotTravAllowed = true;
|
11324
|
-
re += subPatternStart(pattern.slice(i + 1));
|
11325
|
-
}
|
11305
|
+
});
|
11306
|
+
re += stateChar === "!" ? "(?:(?!(?:" : "(?:";
|
11326
11307
|
this.debug("plType %j %j", stateChar, re);
|
11327
11308
|
stateChar = false;
|
11328
11309
|
continue;
|
11329
|
-
|
11330
|
-
|
11331
|
-
const plEntry = patternListStack[patternListStack.length - 1];
|
11332
|
-
if (inClass || !plEntry) {
|
11310
|
+
case ")":
|
11311
|
+
if (inClass || !patternListStack.length) {
|
11333
11312
|
re += "\\)";
|
11334
11313
|
continue;
|
11335
11314
|
}
|
11336
|
-
patternListStack.pop();
|
11337
11315
|
clearStateChar();
|
11338
11316
|
hasMagic = true;
|
11339
|
-
pl =
|
11317
|
+
pl = patternListStack.pop();
|
11340
11318
|
re += pl.close;
|
11341
11319
|
if (pl.type === "!") {
|
11342
|
-
negativeLists.push(
|
11320
|
+
negativeLists.push(pl);
|
11343
11321
|
}
|
11322
|
+
pl.reEnd = re.length;
|
11344
11323
|
continue;
|
11345
|
-
|
11346
|
-
|
11347
|
-
const plEntry = patternListStack[patternListStack.length - 1];
|
11348
|
-
if (inClass || !plEntry) {
|
11324
|
+
case "|":
|
11325
|
+
if (inClass || !patternListStack.length) {
|
11349
11326
|
re += "\\|";
|
11350
11327
|
continue;
|
11351
11328
|
}
|
11352
11329
|
clearStateChar();
|
11353
11330
|
re += "|";
|
11354
|
-
if (plEntry.start === 0 && plEntry.type !== "!") {
|
11355
|
-
dotTravAllowed = true;
|
11356
|
-
re += subPatternStart(pattern.slice(i + 1));
|
11357
|
-
}
|
11358
11331
|
continue;
|
11359
|
-
}
|
11360
11332
|
case "[":
|
11361
11333
|
clearStateChar();
|
11362
11334
|
if (inClass) {
|
@@ -11375,13 +11347,17 @@ var require_minimatch2 = __commonJS({
|
|
11375
11347
|
}
|
11376
11348
|
cs = pattern.substring(classStart + 1, i);
|
11377
11349
|
try {
|
11378
|
-
RegExp("[" +
|
11379
|
-
re += c;
|
11350
|
+
RegExp("[" + cs + "]");
|
11380
11351
|
} catch (er) {
|
11381
|
-
|
11352
|
+
sp = this.parse(cs, SUBPARSE);
|
11353
|
+
re = re.substr(0, reClassStart) + "\\[" + sp[0] + "\\]";
|
11354
|
+
hasMagic = hasMagic || sp[1];
|
11355
|
+
inClass = false;
|
11356
|
+
continue;
|
11382
11357
|
}
|
11383
11358
|
hasMagic = true;
|
11384
11359
|
inClass = false;
|
11360
|
+
re += c;
|
11385
11361
|
continue;
|
11386
11362
|
default:
|
11387
11363
|
clearStateChar();
|
@@ -11393,9 +11369,9 @@ var require_minimatch2 = __commonJS({
|
|
11393
11369
|
}
|
11394
11370
|
}
|
11395
11371
|
if (inClass) {
|
11396
|
-
cs = pattern.
|
11372
|
+
cs = pattern.substr(classStart + 1);
|
11397
11373
|
sp = this.parse(cs, SUBPARSE);
|
11398
|
-
re = re.
|
11374
|
+
re = re.substr(0, reClassStart) + "\\[" + sp[0];
|
11399
11375
|
hasMagic = hasMagic || sp[1];
|
11400
11376
|
}
|
11401
11377
|
for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
|
@@ -11424,28 +11400,24 @@ var require_minimatch2 = __commonJS({
|
|
11424
11400
|
const nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
|
11425
11401
|
let nlAfter = re.slice(nl.reEnd);
|
11426
11402
|
const nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + nlAfter;
|
11427
|
-
const
|
11428
|
-
const openParensBefore = nlBefore.split("(").length - closeParensBefore;
|
11403
|
+
const openParensBefore = nlBefore.split("(").length - 1;
|
11429
11404
|
let cleanAfter = nlAfter;
|
11430
11405
|
for (let i = 0; i < openParensBefore; i++) {
|
11431
11406
|
cleanAfter = cleanAfter.replace(/\)[+*?]?/, "");
|
11432
11407
|
}
|
11433
11408
|
nlAfter = cleanAfter;
|
11434
|
-
const dollar = nlAfter === "" && isSub !== SUBPARSE ? "
|
11409
|
+
const dollar = nlAfter === "" && isSub !== SUBPARSE ? "$" : "";
|
11435
11410
|
re = nlBefore + nlFirst + nlAfter + dollar + nlLast;
|
11436
11411
|
}
|
11437
11412
|
if (re !== "" && hasMagic) {
|
11438
11413
|
re = "(?=.)" + re;
|
11439
11414
|
}
|
11440
11415
|
if (addPatternStart) {
|
11441
|
-
re = patternStart
|
11416
|
+
re = patternStart + re;
|
11442
11417
|
}
|
11443
11418
|
if (isSub === SUBPARSE) {
|
11444
11419
|
return [re, hasMagic];
|
11445
11420
|
}
|
11446
|
-
if (options.nocase && !hasMagic) {
|
11447
|
-
hasMagic = pattern.toUpperCase() !== pattern.toLowerCase();
|
11448
|
-
}
|
11449
11421
|
if (!hasMagic) {
|
11450
11422
|
return globUnescape(pattern);
|
11451
11423
|
}
|
@@ -22573,6 +22545,7 @@ async function getLambdaOptionsFromFunction({
|
|
22573
22545
|
for (const [pattern, fn] of Object.entries(config.functions)) {
|
22574
22546
|
if (sourceFile === pattern || (0, import_minimatch.default)(sourceFile, pattern)) {
|
22575
22547
|
return {
|
22548
|
+
architecture: fn.architecture,
|
22576
22549
|
memory: fn.memory,
|
22577
22550
|
maxDuration: fn.maxDuration
|
22578
22551
|
};
|
@@ -23253,7 +23226,16 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
23253
23226
|
start: destPath,
|
23254
23227
|
filename: "package.json"
|
23255
23228
|
});
|
23256
|
-
|
23229
|
+
let packageJson;
|
23230
|
+
if (readPackageJson && pkgJsonPath) {
|
23231
|
+
try {
|
23232
|
+
packageJson = JSON.parse(await import_fs_extra7.default.readFile(pkgJsonPath, "utf8"));
|
23233
|
+
} catch (err) {
|
23234
|
+
throw new Error(
|
23235
|
+
`Could not read ${pkgJsonPath}: ${err.message}.`
|
23236
|
+
);
|
23237
|
+
}
|
23238
|
+
}
|
23257
23239
|
const {
|
23258
23240
|
paths: [
|
23259
23241
|
yarnLockPath,
|
@@ -23561,6 +23543,12 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion,
|
|
23561
23543
|
turboSupportsCorepackHome,
|
23562
23544
|
projectCreatedAt
|
23563
23545
|
});
|
23546
|
+
const maySeeDynamicRequireYarnBug = process.env?.ENABLE_EXPERIMENTAL_COREPACK && packageJson?.packageManager?.startsWith("yarn") && packageJson?.type === "module";
|
23547
|
+
if (maySeeDynamicRequireYarnBug) {
|
23548
|
+
console.warn(
|
23549
|
+
`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`
|
23550
|
+
);
|
23551
|
+
}
|
23564
23552
|
await runInstallCommand({
|
23565
23553
|
packageManager: cliType,
|
23566
23554
|
args,
|
@@ -24280,13 +24268,17 @@ var functionsSchema = {
|
|
24280
24268
|
type: "object",
|
24281
24269
|
additionalProperties: false,
|
24282
24270
|
properties: {
|
24271
|
+
architecture: {
|
24272
|
+
type: "string",
|
24273
|
+
enum: ["x86_64", "arm64"]
|
24274
|
+
},
|
24283
24275
|
runtime: {
|
24284
24276
|
type: "string",
|
24285
24277
|
maxLength: 256
|
24286
24278
|
},
|
24287
24279
|
memory: {
|
24288
24280
|
minimum: 128,
|
24289
|
-
maximum:
|
24281
|
+
maximum: 10240
|
24290
24282
|
},
|
24291
24283
|
maxDuration: {
|
24292
24284
|
type: "number",
|
package/dist/lambda.d.ts
CHANGED
@@ -77,5 +77,5 @@ export declare class Lambda {
|
|
77
77
|
*/
|
78
78
|
export declare function createLambda(opts: LambdaOptions): Promise<Lambda>;
|
79
79
|
export declare function createZip(files: Files): Promise<Buffer>;
|
80
|
-
export declare function getLambdaOptionsFromFunction({ sourceFile, config, }: GetLambdaOptionsFromFunctionOptions): Promise<Pick<LambdaOptions, 'memory' | 'maxDuration'>>;
|
80
|
+
export declare function getLambdaOptionsFromFunction({ sourceFile, config, }: GetLambdaOptionsFromFunctionOptions): Promise<Pick<LambdaOptions, 'architecture' | 'memory' | 'maxDuration'>>;
|
81
81
|
export {};
|
package/dist/lambda.js
CHANGED
@@ -214,6 +214,7 @@ async function getLambdaOptionsFromFunction({
|
|
214
214
|
for (const [pattern, fn] of Object.entries(config.functions)) {
|
215
215
|
if (sourceFile === pattern || (0, import_minimatch.default)(sourceFile, pattern)) {
|
216
216
|
return {
|
217
|
+
architecture: fn.architecture,
|
217
218
|
memory: fn.memory,
|
218
219
|
maxDuration: fn.maxDuration
|
219
220
|
};
|
package/dist/schemas.d.ts
CHANGED
package/dist/schemas.js
CHANGED
@@ -32,13 +32,17 @@ const functionsSchema = {
|
|
32
32
|
type: "object",
|
33
33
|
additionalProperties: false,
|
34
34
|
properties: {
|
35
|
+
architecture: {
|
36
|
+
type: "string",
|
37
|
+
enum: ["x86_64", "arm64"]
|
38
|
+
},
|
35
39
|
runtime: {
|
36
40
|
type: "string",
|
37
41
|
maxLength: 256
|
38
42
|
},
|
39
43
|
memory: {
|
40
44
|
minimum: 128,
|
41
|
-
maximum:
|
45
|
+
maximum: 10240
|
42
46
|
},
|
43
47
|
maxDuration: {
|
44
48
|
type: "number",
|
package/dist/types.d.ts
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
import type FileRef from './file-ref';
|
3
3
|
import type FileFsRef from './file-fs-ref';
|
4
4
|
import type FileBlob from './file-blob';
|
5
|
-
import type { Lambda } from './lambda';
|
5
|
+
import type { Lambda, LambdaArchitecture } from './lambda';
|
6
6
|
import type { Prerender } from './prerender';
|
7
7
|
import type { EdgeFunction } from './edge-function';
|
8
8
|
import type { Span } from './trace';
|
@@ -287,6 +287,7 @@ export interface PackageJson {
|
|
287
287
|
readonly private?: boolean;
|
288
288
|
readonly publishConfig?: PackageJson.PublishConfig;
|
289
289
|
readonly packageManager?: string;
|
290
|
+
readonly type?: string;
|
290
291
|
}
|
291
292
|
export interface ConstructorVersion {
|
292
293
|
/** major version number: 18 */
|
@@ -321,6 +322,7 @@ export interface Builder {
|
|
321
322
|
}
|
322
323
|
export interface BuilderFunctions {
|
323
324
|
[key: string]: {
|
325
|
+
architecture?: LambdaArchitecture;
|
324
326
|
memory?: number;
|
325
327
|
maxDuration?: number;
|
326
328
|
runtime?: string;
|