@vercel/backends 0.0.30 → 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 +29 -8
- package/dist/rolldown/index.d.mts +1 -1
- package/dist/rolldown/index.mjs +19 -8
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { builtinModules, createRequire } from "node:module";
|
|
|
2
2
|
import { delimiter, dirname, extname, join } from "path";
|
|
3
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,13 +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,
|
|
687
|
-
ignore:
|
|
688
|
+
ignore: ignorePatterns.length > 0 ? ignorePatterns : void 0,
|
|
688
689
|
async readFile(fsPath) {
|
|
689
690
|
try {
|
|
690
691
|
let source = await readFile(fsPath);
|
|
@@ -702,11 +703,13 @@ const nft = async (args) => {
|
|
|
702
703
|
const outputPath = file;
|
|
703
704
|
if (args.localBuildFiles.has(join$1(args.repoRootPath, outputPath))) continue;
|
|
704
705
|
if (stats.isSymbolicLink() || stats.isFile()) if (args.ignoreNodeModules) {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
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
|
+
}
|
|
710
713
|
} else args.files[outputPath] = new FileFsRef({
|
|
711
714
|
fsPath: absolutePath,
|
|
712
715
|
mode: stats.mode
|
|
@@ -784,6 +787,9 @@ const rolldown = async (args) => {
|
|
|
784
787
|
const normalizedId = id.includes(":") ? id.split(":")[1] : id;
|
|
785
788
|
return builtinModules.includes(normalizedId);
|
|
786
789
|
};
|
|
790
|
+
const isBunBuiltin = (id) => {
|
|
791
|
+
return id === "bun" || id.startsWith("bun:");
|
|
792
|
+
};
|
|
787
793
|
const isLocalImport = (id) => {
|
|
788
794
|
return !id.startsWith("node:") && !id.includes("node_modules");
|
|
789
795
|
};
|
|
@@ -802,6 +808,10 @@ const rolldown = async (args) => {
|
|
|
802
808
|
id: id.startsWith("node:") ? id : `node:${id}`,
|
|
803
809
|
external: true
|
|
804
810
|
};
|
|
811
|
+
if (isBunBuiltin(id)) return {
|
|
812
|
+
id,
|
|
813
|
+
external: true
|
|
814
|
+
};
|
|
805
815
|
if (resolved?.id && isLocalImport(resolved.id)) localBuildFiles.add(resolved.id);
|
|
806
816
|
else if (!resolved) localBuildFiles.add(join$1(args.workPath, id));
|
|
807
817
|
if (importer?.startsWith(CJS_SHIM_PREFIX) && isBareImport(id)) return {
|
|
@@ -901,7 +911,8 @@ module.exports = requireFromContext('${pkgName}');
|
|
|
901
911
|
localBuildFiles,
|
|
902
912
|
files,
|
|
903
913
|
span: rolldownSpan ?? new Span({ name: "vc.builder.backends.nft" }),
|
|
904
|
-
ignoreNodeModules: true
|
|
914
|
+
ignoreNodeModules: true,
|
|
915
|
+
ignore: args.config.excludeFiles
|
|
905
916
|
});
|
|
906
917
|
if (!handler) throw new Error(`Unable to resolve build handler for entrypoint: ${args.entrypoint}`);
|
|
907
918
|
console.log(Colors.gray(`${Colors.bold(Colors.cyan("✓"))} Build complete`));
|
|
@@ -1421,6 +1432,11 @@ const build = async (args) => {
|
|
|
1421
1432
|
debug("Entrypoint", entrypoint);
|
|
1422
1433
|
args.entrypoint = entrypoint;
|
|
1423
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
|
+
}
|
|
1424
1440
|
const rolldownResult = await rolldown({
|
|
1425
1441
|
...args,
|
|
1426
1442
|
span: buildSpan
|
|
@@ -1446,9 +1462,13 @@ const build = async (args) => {
|
|
|
1446
1462
|
localBuildFiles,
|
|
1447
1463
|
files,
|
|
1448
1464
|
ignoreNodeModules: false,
|
|
1465
|
+
ignore: args.config.excludeFiles,
|
|
1449
1466
|
conditions: isBun ? ["bun"] : void 0,
|
|
1450
1467
|
span: buildSpan
|
|
1451
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;
|
|
1452
1472
|
const introspectionResult = await introspectionPromise;
|
|
1453
1473
|
await typescriptPromise;
|
|
1454
1474
|
const lambda = new NodejsLambda({
|
|
@@ -1483,6 +1503,7 @@ const build = async (args) => {
|
|
|
1483
1503
|
const prepareCache = ({ repoRootPath, workPath }) => {
|
|
1484
1504
|
return glob(defaultCachePathGlob, repoRootPath || workPath);
|
|
1485
1505
|
};
|
|
1506
|
+
const normalizeArray = (value) => Array.isArray(value) ? value : value ? [value] : [];
|
|
1486
1507
|
|
|
1487
1508
|
//#endregion
|
|
1488
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,7 +2,7 @@ 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";
|
|
@@ -93,13 +93,14 @@ const resolveEntrypointAndFormat = async (args) => {
|
|
|
93
93
|
const nft = async (args) => {
|
|
94
94
|
const nftSpan = args.span.child("vc.builder.backends.nft");
|
|
95
95
|
const runNft = async () => {
|
|
96
|
+
const ignorePatterns = [...args.ignoreNodeModules ? ["**/node_modules/**"] : [], ...args.ignore ? Array.isArray(args.ignore) ? args.ignore : [args.ignore] : []];
|
|
96
97
|
const nftResult = await nodeFileTrace(Array.from(args.localBuildFiles), {
|
|
97
98
|
base: args.repoRootPath,
|
|
98
99
|
processCwd: args.workPath,
|
|
99
100
|
ts: true,
|
|
100
101
|
mixedModules: true,
|
|
101
102
|
conditions: args.conditions,
|
|
102
|
-
ignore:
|
|
103
|
+
ignore: ignorePatterns.length > 0 ? ignorePatterns : void 0,
|
|
103
104
|
async readFile(fsPath) {
|
|
104
105
|
try {
|
|
105
106
|
let source = await readFile(fsPath);
|
|
@@ -117,11 +118,13 @@ const nft = async (args) => {
|
|
|
117
118
|
const outputPath = file;
|
|
118
119
|
if (args.localBuildFiles.has(join(args.repoRootPath, outputPath))) continue;
|
|
119
120
|
if (stats.isSymbolicLink() || stats.isFile()) if (args.ignoreNodeModules) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
+
}
|
|
125
128
|
} else args.files[outputPath] = new FileFsRef({
|
|
126
129
|
fsPath: absolutePath,
|
|
127
130
|
mode: stats.mode
|
|
@@ -199,6 +202,9 @@ const rolldown = async (args) => {
|
|
|
199
202
|
const normalizedId = id.includes(":") ? id.split(":")[1] : id;
|
|
200
203
|
return builtinModules.includes(normalizedId);
|
|
201
204
|
};
|
|
205
|
+
const isBunBuiltin = (id) => {
|
|
206
|
+
return id === "bun" || id.startsWith("bun:");
|
|
207
|
+
};
|
|
202
208
|
const isLocalImport = (id) => {
|
|
203
209
|
return !id.startsWith("node:") && !id.includes("node_modules");
|
|
204
210
|
};
|
|
@@ -217,6 +223,10 @@ const rolldown = async (args) => {
|
|
|
217
223
|
id: id.startsWith("node:") ? id : `node:${id}`,
|
|
218
224
|
external: true
|
|
219
225
|
};
|
|
226
|
+
if (isBunBuiltin(id)) return {
|
|
227
|
+
id,
|
|
228
|
+
external: true
|
|
229
|
+
};
|
|
220
230
|
if (resolved?.id && isLocalImport(resolved.id)) localBuildFiles.add(resolved.id);
|
|
221
231
|
else if (!resolved) localBuildFiles.add(join(args.workPath, id));
|
|
222
232
|
if (importer?.startsWith(CJS_SHIM_PREFIX) && isBareImport(id)) return {
|
|
@@ -316,7 +326,8 @@ module.exports = requireFromContext('${pkgName}');
|
|
|
316
326
|
localBuildFiles,
|
|
317
327
|
files,
|
|
318
328
|
span: rolldownSpan ?? new Span({ name: "vc.builder.backends.nft" }),
|
|
319
|
-
ignoreNodeModules: true
|
|
329
|
+
ignoreNodeModules: true,
|
|
330
|
+
ignore: args.config.excludeFiles
|
|
320
331
|
});
|
|
321
332
|
if (!handler) throw new Error(`Unable to resolve build handler for entrypoint: ${args.entrypoint}`);
|
|
322
333
|
console.log(Colors.gray(`${Colors.bold(Colors.cyan("✓"))} Build complete`));
|
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"
|