@vercel/build-utils 14.9.2 → 14.10.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/build.mjs +23 -2
- package/dist/fs/find-package-json.d.ts +36 -0
- package/dist/fs/find-package-json.js +95 -0
- package/dist/fs/run-user-scripts.d.ts +2 -36
- package/dist/fs/run-user-scripts.js +10 -59
- package/dist/index.d.ts +9 -8
- package/dist/index.js +144 -41196
- package/dist/types.d.ts +8 -2
- package/lazy-entry.mjs +39 -0
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -560,6 +560,10 @@ export interface BuildResultBuildOutput {
|
|
|
560
560
|
* @example "/path/to/.vercel/output"
|
|
561
561
|
*/
|
|
562
562
|
buildOutputPath: string;
|
|
563
|
+
framework?: {
|
|
564
|
+
slug: string;
|
|
565
|
+
version: string;
|
|
566
|
+
};
|
|
563
567
|
}
|
|
564
568
|
export interface Cron {
|
|
565
569
|
path: string;
|
|
@@ -568,8 +572,8 @@ export interface Cron {
|
|
|
568
572
|
export interface ScheduleExpression {
|
|
569
573
|
/** Cron expression describing when the schedule fires (REQUIRED) */
|
|
570
574
|
cron: string;
|
|
571
|
-
/** Maximum random delay applied to each firing,
|
|
572
|
-
jitter?:
|
|
575
|
+
/** Maximum random delay applied to each firing, from 1 to 15 whole minutes (OPTIONAL) */
|
|
576
|
+
jitter?: number;
|
|
573
577
|
}
|
|
574
578
|
export type ScheduleTarget = {
|
|
575
579
|
/** Build output path of the function to invoke, e.g. "api/cron" */
|
|
@@ -582,6 +586,8 @@ export interface Schedule {
|
|
|
582
586
|
/** Unique name of the schedule within the deployment (REQUIRED) */
|
|
583
587
|
name: string;
|
|
584
588
|
expression: ScheduleExpression;
|
|
589
|
+
/** IANA timezone for cron evaluation, e.g. "America/New_York". Defaults to UTC. */
|
|
590
|
+
timezone?: string;
|
|
585
591
|
target: ScheduleTarget;
|
|
586
592
|
/** Payload delivered with each firing (OPTIONAL) */
|
|
587
593
|
payload?: unknown;
|
package/lazy-entry.mjs
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { transform } from 'esbuild';
|
|
3
|
+
|
|
4
|
+
// Keep the public CommonJS barrel's getters, but initialize each re-exported
|
|
5
|
+
// module on first use. All exports still share one bundled module cache.
|
|
6
|
+
export function lazyEntryPlugin() {
|
|
7
|
+
return {
|
|
8
|
+
name: 'lazy-build-utils-entry',
|
|
9
|
+
setup(build) {
|
|
10
|
+
build.onLoad(
|
|
11
|
+
{ filter: /[/\\]build-utils[/\\]src[/\\]index\.ts$/ },
|
|
12
|
+
async args => {
|
|
13
|
+
const source = await readFile(args.path, 'utf8');
|
|
14
|
+
let { code } = await transform(source, {
|
|
15
|
+
loader: 'ts',
|
|
16
|
+
format: 'cjs',
|
|
17
|
+
});
|
|
18
|
+
const imports = [];
|
|
19
|
+
code = code.replace(
|
|
20
|
+
/^var (import_\w+) = (.+);$/gm,
|
|
21
|
+
(_, name, initializer) => {
|
|
22
|
+
imports.push(name);
|
|
23
|
+
return `var ${name};\nvar load_${name} = () => ${name} ??= ${initializer};`;
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
if (imports.length === 0) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
'Expected CommonJS imports in the build-utils barrel'
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
for (const name of imports) {
|
|
32
|
+
code = code.replaceAll(`() => ${name}.`, `() => load_${name}().`);
|
|
33
|
+
}
|
|
34
|
+
return { contents: code, loader: 'js' };
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|