@vercel/backends 0.0.29 → 0.0.31
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/dist/index.mjs +35 -10
- package/dist/rolldown/index.d.mts +1 -1
- package/dist/rolldown/index.mjs +50 -8
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { builtinModules, createRequire } from "node:module";
|
|
2
2
|
import { delimiter, dirname, extname, join } from "path";
|
|
3
|
-
import { FileBlob, FileFsRef, NodejsLambda, Span, debug, defaultCachePathGlob, download, execCommand, getEnvForPackageManager, getNodeBinPaths, getNodeVersion, glob, isBackendFramework, isExperimentalBackendsWithoutIntrospectionEnabled, runNpmInstall, runPackageJsonScript, scanParentDirs } from "@vercel/build-utils";
|
|
3
|
+
import { FileBlob, FileFsRef, NodejsLambda, Span, debug, defaultCachePathGlob, download, execCommand, getEnvForPackageManager, getNodeBinPaths, getNodeVersion, glob, isBackendFramework, isBunVersion, isExperimentalBackendsWithoutIntrospectionEnabled, runNpmInstall, runPackageJsonScript, scanParentDirs } from "@vercel/build-utils";
|
|
4
4
|
import { createWriteStream, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
|
-
import { lstat, readFile, rm } from "node:fs/promises";
|
|
5
|
+
import { lstat, readFile, rm, stat } from "node:fs/promises";
|
|
6
6
|
import { dirname as dirname$1, extname as extname$1, isAbsolute, join as join$1, relative } from "node:path";
|
|
7
7
|
import { build as build$2 } from "rolldown";
|
|
8
8
|
import { exports } from "resolve.exports";
|
|
@@ -678,12 +678,14 @@ const resolveEntrypointAndFormat = async (args) => {
|
|
|
678
678
|
const nft = async (args) => {
|
|
679
679
|
const nftSpan = args.span.child("vc.builder.backends.nft");
|
|
680
680
|
const runNft = async () => {
|
|
681
|
+
const ignorePatterns = [...args.ignoreNodeModules ? ["**/node_modules/**"] : [], ...args.ignore ? Array.isArray(args.ignore) ? args.ignore : [args.ignore] : []];
|
|
681
682
|
const nftResult = await nodeFileTrace$1(Array.from(args.localBuildFiles), {
|
|
682
683
|
base: args.repoRootPath,
|
|
683
684
|
processCwd: args.workPath,
|
|
684
685
|
ts: true,
|
|
685
686
|
mixedModules: true,
|
|
686
|
-
|
|
687
|
+
conditions: args.conditions,
|
|
688
|
+
ignore: ignorePatterns.length > 0 ? ignorePatterns : void 0,
|
|
687
689
|
async readFile(fsPath) {
|
|
688
690
|
try {
|
|
689
691
|
let source = await readFile(fsPath);
|
|
@@ -701,11 +703,13 @@ const nft = async (args) => {
|
|
|
701
703
|
const outputPath = file;
|
|
702
704
|
if (args.localBuildFiles.has(join$1(args.repoRootPath, outputPath))) continue;
|
|
703
705
|
if (stats.isSymbolicLink() || stats.isFile()) if (args.ignoreNodeModules) {
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
706
|
+
if ((stats.isSymbolicLink() ? await stat(absolutePath) : stats).isFile()) {
|
|
707
|
+
const content = await readFile(absolutePath, "utf-8");
|
|
708
|
+
args.files[outputPath] = new FileBlob({
|
|
709
|
+
data: content,
|
|
710
|
+
mode: stats.mode
|
|
711
|
+
});
|
|
712
|
+
}
|
|
709
713
|
} else args.files[outputPath] = new FileFsRef({
|
|
710
714
|
fsPath: absolutePath,
|
|
711
715
|
mode: stats.mode
|
|
@@ -783,6 +787,9 @@ const rolldown = async (args) => {
|
|
|
783
787
|
const normalizedId = id.includes(":") ? id.split(":")[1] : id;
|
|
784
788
|
return builtinModules.includes(normalizedId);
|
|
785
789
|
};
|
|
790
|
+
const isBunBuiltin = (id) => {
|
|
791
|
+
return id === "bun" || id.startsWith("bun:");
|
|
792
|
+
};
|
|
786
793
|
const isLocalImport = (id) => {
|
|
787
794
|
return !id.startsWith("node:") && !id.includes("node_modules");
|
|
788
795
|
};
|
|
@@ -801,6 +808,10 @@ const rolldown = async (args) => {
|
|
|
801
808
|
id: id.startsWith("node:") ? id : `node:${id}`,
|
|
802
809
|
external: true
|
|
803
810
|
};
|
|
811
|
+
if (isBunBuiltin(id)) return {
|
|
812
|
+
id,
|
|
813
|
+
external: true
|
|
814
|
+
};
|
|
804
815
|
if (resolved?.id && isLocalImport(resolved.id)) localBuildFiles.add(resolved.id);
|
|
805
816
|
else if (!resolved) localBuildFiles.add(join$1(args.workPath, id));
|
|
806
817
|
if (importer?.startsWith(CJS_SHIM_PREFIX) && isBareImport(id)) return {
|
|
@@ -900,9 +911,11 @@ module.exports = requireFromContext('${pkgName}');
|
|
|
900
911
|
localBuildFiles,
|
|
901
912
|
files,
|
|
902
913
|
span: rolldownSpan ?? new Span({ name: "vc.builder.backends.nft" }),
|
|
903
|
-
ignoreNodeModules: true
|
|
914
|
+
ignoreNodeModules: true,
|
|
915
|
+
ignore: args.config.excludeFiles
|
|
904
916
|
});
|
|
905
917
|
if (!handler) throw new Error(`Unable to resolve build handler for entrypoint: ${args.entrypoint}`);
|
|
918
|
+
console.log(Colors.gray(`${Colors.bold(Colors.cyan("✓"))} Build complete`));
|
|
906
919
|
return {
|
|
907
920
|
files,
|
|
908
921
|
handler,
|
|
@@ -1408,7 +1421,8 @@ const getFramework = (args) => {
|
|
|
1408
1421
|
const version = 2;
|
|
1409
1422
|
const build = async (args) => {
|
|
1410
1423
|
const downloadResult = await downloadInstallAndBundle(args);
|
|
1411
|
-
const nodeVersion = await getNodeVersion(args.workPath);
|
|
1424
|
+
const nodeVersion = await getNodeVersion(args.workPath, void 0, args.config, args.meta);
|
|
1425
|
+
const isBun = isBunVersion(nodeVersion);
|
|
1412
1426
|
const builderName = "@vercel/backends";
|
|
1413
1427
|
const span = args.span ?? new Span({ name: builderName });
|
|
1414
1428
|
span.setAttributes({ "builder.name": builderName });
|
|
@@ -1418,6 +1432,11 @@ const build = async (args) => {
|
|
|
1418
1432
|
debug("Entrypoint", entrypoint);
|
|
1419
1433
|
args.entrypoint = entrypoint;
|
|
1420
1434
|
const userBuildResult = await maybeDoBuildCommand(args, downloadResult);
|
|
1435
|
+
const functionConfig = args.config.functions?.[entrypoint];
|
|
1436
|
+
if (functionConfig) {
|
|
1437
|
+
args.config.includeFiles = [...normalizeArray(args.config.includeFiles), ...normalizeArray(functionConfig.includeFiles)];
|
|
1438
|
+
args.config.excludeFiles = [...normalizeArray(args.config.excludeFiles), ...normalizeArray(functionConfig.excludeFiles)];
|
|
1439
|
+
}
|
|
1421
1440
|
const rolldownResult = await rolldown({
|
|
1422
1441
|
...args,
|
|
1423
1442
|
span: buildSpan
|
|
@@ -1443,8 +1462,13 @@ const build = async (args) => {
|
|
|
1443
1462
|
localBuildFiles,
|
|
1444
1463
|
files,
|
|
1445
1464
|
ignoreNodeModules: false,
|
|
1465
|
+
ignore: args.config.excludeFiles,
|
|
1466
|
+
conditions: isBun ? ["bun"] : void 0,
|
|
1446
1467
|
span: buildSpan
|
|
1447
1468
|
});
|
|
1469
|
+
const baseDir = args.repoRootPath || args.workPath;
|
|
1470
|
+
const includeResults = await Promise.all(normalizeArray(args.config.includeFiles).map((pattern) => glob(pattern, baseDir)));
|
|
1471
|
+
for (const matched of includeResults) for (const [relPath, entry] of Object.entries(matched)) files[relPath] = entry;
|
|
1448
1472
|
const introspectionResult = await introspectionPromise;
|
|
1449
1473
|
await typescriptPromise;
|
|
1450
1474
|
const lambda = new NodejsLambda({
|
|
@@ -1479,6 +1503,7 @@ const build = async (args) => {
|
|
|
1479
1503
|
const prepareCache = ({ repoRootPath, workPath }) => {
|
|
1480
1504
|
return glob(defaultCachePathGlob, repoRootPath || workPath);
|
|
1481
1505
|
};
|
|
1506
|
+
const normalizeArray = (value) => Array.isArray(value) ? value : value ? [value] : [];
|
|
1482
1507
|
|
|
1483
1508
|
//#endregion
|
|
1484
1509
|
export { build, build$1 as cervelBuild, serve as cervelServe, findEntrypoint, findEntrypointOrThrow, getBuildSummary, introspectApp, nodeFileTrace, prepareCache, srvxOptions, version };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BuildOptions, Files, Span } from "@vercel/build-utils";
|
|
2
2
|
|
|
3
3
|
//#region src/rolldown/index.d.ts
|
|
4
|
-
declare const rolldown: (args: Pick<BuildOptions, 'entrypoint' | 'workPath' | 'repoRootPath'> & {
|
|
4
|
+
declare const rolldown: (args: Pick<BuildOptions, 'entrypoint' | 'workPath' | 'repoRootPath' | 'config'> & {
|
|
5
5
|
span?: Span;
|
|
6
6
|
}) => Promise<{
|
|
7
7
|
files: Files;
|
package/dist/rolldown/index.mjs
CHANGED
|
@@ -2,13 +2,42 @@ import { builtinModules } from "node:module";
|
|
|
2
2
|
import { FileBlob, FileFsRef, Span, isBackendFramework } from "@vercel/build-utils";
|
|
3
3
|
import { dirname, extname, join, relative } from "node:path";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
|
-
import { lstat, readFile } from "node:fs/promises";
|
|
5
|
+
import { lstat, readFile, stat } from "node:fs/promises";
|
|
6
6
|
import { build } from "rolldown";
|
|
7
7
|
import { nodeFileTrace } from "@vercel/nft";
|
|
8
8
|
import { isNativeError } from "node:util/types";
|
|
9
9
|
import { transform } from "oxc-transform";
|
|
10
10
|
import { exports } from "resolve.exports";
|
|
11
11
|
|
|
12
|
+
//#region src/cervel/utils.ts
|
|
13
|
+
const noColor = globalThis.process?.env?.NO_COLOR === "1" || globalThis.process?.env?.TERM === "dumb";
|
|
14
|
+
const resets = {
|
|
15
|
+
1: 22,
|
|
16
|
+
31: 39,
|
|
17
|
+
32: 39,
|
|
18
|
+
33: 39,
|
|
19
|
+
34: 39,
|
|
20
|
+
35: 39,
|
|
21
|
+
36: 39,
|
|
22
|
+
90: 39
|
|
23
|
+
};
|
|
24
|
+
const _c = (c) => (text) => {
|
|
25
|
+
if (noColor) return text;
|
|
26
|
+
return `\u001B[${c}m${text}\u001B[${resets[c] ?? 0}m`;
|
|
27
|
+
};
|
|
28
|
+
const Colors = {
|
|
29
|
+
bold: _c(1),
|
|
30
|
+
red: _c(31),
|
|
31
|
+
green: _c(32),
|
|
32
|
+
yellow: _c(33),
|
|
33
|
+
blue: _c(34),
|
|
34
|
+
magenta: _c(35),
|
|
35
|
+
cyan: _c(36),
|
|
36
|
+
gray: _c(90),
|
|
37
|
+
url: (title, url) => noColor ? `[${title}](${url})` : `\u001B]8;;${url}\u001B\\${title}\u001B]8;;\u001B\\`
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
12
41
|
//#region src/rolldown/resolve-format.ts
|
|
13
42
|
const resolveEntrypointAndFormat = async (args) => {
|
|
14
43
|
const extension = extname(args.entrypoint);
|
|
@@ -64,12 +93,14 @@ const resolveEntrypointAndFormat = async (args) => {
|
|
|
64
93
|
const nft = async (args) => {
|
|
65
94
|
const nftSpan = args.span.child("vc.builder.backends.nft");
|
|
66
95
|
const runNft = async () => {
|
|
96
|
+
const ignorePatterns = [...args.ignoreNodeModules ? ["**/node_modules/**"] : [], ...args.ignore ? Array.isArray(args.ignore) ? args.ignore : [args.ignore] : []];
|
|
67
97
|
const nftResult = await nodeFileTrace(Array.from(args.localBuildFiles), {
|
|
68
98
|
base: args.repoRootPath,
|
|
69
99
|
processCwd: args.workPath,
|
|
70
100
|
ts: true,
|
|
71
101
|
mixedModules: true,
|
|
72
|
-
|
|
102
|
+
conditions: args.conditions,
|
|
103
|
+
ignore: ignorePatterns.length > 0 ? ignorePatterns : void 0,
|
|
73
104
|
async readFile(fsPath) {
|
|
74
105
|
try {
|
|
75
106
|
let source = await readFile(fsPath);
|
|
@@ -87,11 +118,13 @@ const nft = async (args) => {
|
|
|
87
118
|
const outputPath = file;
|
|
88
119
|
if (args.localBuildFiles.has(join(args.repoRootPath, outputPath))) continue;
|
|
89
120
|
if (stats.isSymbolicLink() || stats.isFile()) if (args.ignoreNodeModules) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
121
|
+
if ((stats.isSymbolicLink() ? await stat(absolutePath) : stats).isFile()) {
|
|
122
|
+
const content = await readFile(absolutePath, "utf-8");
|
|
123
|
+
args.files[outputPath] = new FileBlob({
|
|
124
|
+
data: content,
|
|
125
|
+
mode: stats.mode
|
|
126
|
+
});
|
|
127
|
+
}
|
|
95
128
|
} else args.files[outputPath] = new FileFsRef({
|
|
96
129
|
fsPath: absolutePath,
|
|
97
130
|
mode: stats.mode
|
|
@@ -169,6 +202,9 @@ const rolldown = async (args) => {
|
|
|
169
202
|
const normalizedId = id.includes(":") ? id.split(":")[1] : id;
|
|
170
203
|
return builtinModules.includes(normalizedId);
|
|
171
204
|
};
|
|
205
|
+
const isBunBuiltin = (id) => {
|
|
206
|
+
return id === "bun" || id.startsWith("bun:");
|
|
207
|
+
};
|
|
172
208
|
const isLocalImport = (id) => {
|
|
173
209
|
return !id.startsWith("node:") && !id.includes("node_modules");
|
|
174
210
|
};
|
|
@@ -187,6 +223,10 @@ const rolldown = async (args) => {
|
|
|
187
223
|
id: id.startsWith("node:") ? id : `node:${id}`,
|
|
188
224
|
external: true
|
|
189
225
|
};
|
|
226
|
+
if (isBunBuiltin(id)) return {
|
|
227
|
+
id,
|
|
228
|
+
external: true
|
|
229
|
+
};
|
|
190
230
|
if (resolved?.id && isLocalImport(resolved.id)) localBuildFiles.add(resolved.id);
|
|
191
231
|
else if (!resolved) localBuildFiles.add(join(args.workPath, id));
|
|
192
232
|
if (importer?.startsWith(CJS_SHIM_PREFIX) && isBareImport(id)) return {
|
|
@@ -286,9 +326,11 @@ module.exports = requireFromContext('${pkgName}');
|
|
|
286
326
|
localBuildFiles,
|
|
287
327
|
files,
|
|
288
328
|
span: rolldownSpan ?? new Span({ name: "vc.builder.backends.nft" }),
|
|
289
|
-
ignoreNodeModules: true
|
|
329
|
+
ignoreNodeModules: true,
|
|
330
|
+
ignore: args.config.excludeFiles
|
|
290
331
|
});
|
|
291
332
|
if (!handler) throw new Error(`Unable to resolve build handler for entrypoint: ${args.entrypoint}`);
|
|
333
|
+
console.log(Colors.gray(`${Colors.bold(Colors.cyan("✓"))} Build complete`));
|
|
292
334
|
return {
|
|
293
335
|
files,
|
|
294
336
|
handler,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/backends",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"homepage": "https://vercel.com/docs",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"srvx": "0.8.9",
|
|
35
35
|
"tsx": "4.21.0",
|
|
36
36
|
"zod": "3.22.4",
|
|
37
|
-
"@vercel/build-utils": "13.3.
|
|
37
|
+
"@vercel/build-utils": "13.3.4"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"typescript": "^4.0.0 || ^5.0.0"
|