@vercel/backends 0.8.37 → 0.8.39
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 +21 -7
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { builtinModules, createRequire } from "node:module";
|
|
2
2
|
import { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { delimiter as delimiter$1, dirname as dirname$1, join as join$1 } from "path";
|
|
4
|
-
import { FileBlob, FileFsRef, NodejsLambda, NowBuildError, Span, cloneEnv, createDiagnostics, debug, defaultCachePathGlob, download, execCommand, generateProjectManifest, getEnvForPackageManager, getInternalServiceCronPath, getLambdaOptionsFromFunction, getNodeBinPaths, getNodeVersion, getReportedServiceType, glob, isBackendFramework, isBunVersion, isExperimentalBackendsWithoutIntrospectionEnabled, isScheduleTriggeredService, runNpmInstall, runPackageJsonScript, scanParentDirs } from "@vercel/build-utils";
|
|
4
|
+
import { FileBlob, FileFsRef, NodejsLambda, NowBuildError, Span, cloneEnv, createDiagnostics, debug, defaultCachePathGlob, download, execCommand, generateProjectManifest, getEnvForPackageManager, getInternalServiceCronPath, getLambdaOptionsFromFunction, getNodeBinPaths, getNodeVersion, getOrCreateBunBinary, getReportedServiceType, glob, isBackendFramework, isBunVersion, isExperimentalBackendsWithoutIntrospectionEnabled, isScheduleTriggeredService, runNpmInstall, runPackageJsonScript, scanParentDirs } from "@vercel/build-utils";
|
|
5
5
|
import { getConfig } from "@vercel/static-config";
|
|
6
6
|
import { Project } from "ts-morph";
|
|
7
7
|
import { createWriteStream, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -25,11 +25,13 @@ async function downloadInstallAndBundle(args) {
|
|
|
25
25
|
const { entrypoint, files, workPath, meta, config, repoRootPath } = args;
|
|
26
26
|
await download(files, workPath, meta);
|
|
27
27
|
const entrypointFsDirname = join$1(workPath, dirname$1(entrypoint));
|
|
28
|
+
const nodeVersion = await getNodeVersion(workPath, void 0, config, meta);
|
|
28
29
|
const { cliType, lockfilePath, lockfileVersion, packageJsonPackageManager, turboSupportsCorepackHome } = await scanParentDirs(entrypointFsDirname, true, repoRootPath);
|
|
29
30
|
const spawnEnv = getEnvForPackageManager({
|
|
30
31
|
cliType,
|
|
31
32
|
lockfileVersion,
|
|
32
33
|
packageJsonPackageManager,
|
|
34
|
+
nodeVersion,
|
|
33
35
|
env: process.env,
|
|
34
36
|
turboSupportsCorepackHome,
|
|
35
37
|
projectCreatedAt: config.projectSettings?.createdAt
|
|
@@ -48,7 +50,8 @@ async function downloadInstallAndBundle(args) {
|
|
|
48
50
|
spawnEnv,
|
|
49
51
|
cliType,
|
|
50
52
|
lockfilePath,
|
|
51
|
-
lockfileVersion
|
|
53
|
+
lockfileVersion,
|
|
54
|
+
nodeVersion
|
|
52
55
|
};
|
|
53
56
|
}
|
|
54
57
|
async function maybeExecBuildCommand(args, { spawnEnv }) {
|
|
@@ -2062,12 +2065,21 @@ async function spawnSrvx(opts) {
|
|
|
2062
2065
|
PORT: String(port)
|
|
2063
2066
|
});
|
|
2064
2067
|
if (!env.NODE_ENV) env.NODE_ENV = "development";
|
|
2065
|
-
const
|
|
2068
|
+
const args = [
|
|
2066
2069
|
`--port=${port}`,
|
|
2067
2070
|
"--host=127.0.0.1",
|
|
2068
2071
|
`--static=${resolve(opts.workPath, opts.publicDir)}`,
|
|
2069
2072
|
opts.entrypoint
|
|
2070
|
-
]
|
|
2073
|
+
];
|
|
2074
|
+
const child = opts.runtime === "bun" ? spawn(await getOrCreateBunBinary(), ["--bun", opts.entrypoint], {
|
|
2075
|
+
cwd: opts.workPath,
|
|
2076
|
+
env,
|
|
2077
|
+
stdio: [
|
|
2078
|
+
"ignore",
|
|
2079
|
+
"pipe",
|
|
2080
|
+
"pipe"
|
|
2081
|
+
]
|
|
2082
|
+
}) : fork(srvxBinPath, args, {
|
|
2071
2083
|
cwd: opts.workPath,
|
|
2072
2084
|
env,
|
|
2073
2085
|
execArgv: ["--import", tsxPath],
|
|
@@ -2175,8 +2187,9 @@ const shouldServe = (opts) => {
|
|
|
2175
2187
|
};
|
|
2176
2188
|
const startDevServer = async (opts) => {
|
|
2177
2189
|
if (opts.service) return null;
|
|
2178
|
-
const key = `${opts.workPath}::${opts.entrypoint ?? "<detect>"}`;
|
|
2179
2190
|
const entrypoint = await findEntrypointWithHintOrThrow(opts.workPath, opts.entrypoint);
|
|
2191
|
+
const runtime = isBunVersion(await getNodeVersion(opts.workPath, void 0, opts.config, opts.meta)) ? "bun" : "node";
|
|
2192
|
+
const key = `${opts.workPath}::${opts.entrypoint ?? "<detect>"}::${runtime}`;
|
|
2180
2193
|
const env = { ...opts.meta?.env };
|
|
2181
2194
|
installCleanupHandlers();
|
|
2182
2195
|
while (!shuttingDown) {
|
|
@@ -2212,7 +2225,8 @@ const startDevServer = async (opts) => {
|
|
|
2212
2225
|
env,
|
|
2213
2226
|
signal: controller.signal,
|
|
2214
2227
|
onStdout: opts.onStdout,
|
|
2215
|
-
onStderr: opts.onStderr
|
|
2228
|
+
onStderr: opts.onStderr,
|
|
2229
|
+
runtime
|
|
2216
2230
|
}).then(async (result) => {
|
|
2217
2231
|
const server = {
|
|
2218
2232
|
files,
|
|
@@ -2264,7 +2278,7 @@ function hasExplicitBuildCommand(config) {
|
|
|
2264
2278
|
const build = async (args) => {
|
|
2265
2279
|
if (typeof args.config?.handlerFunction === "string") throw new Error(`Named-function entrypoints are not supported for JavaScript services (got "${args.entrypoint}:${args.config.handlerFunction}"). Put each handler in its own file with a default export.`);
|
|
2266
2280
|
const downloadResult = await downloadInstallAndBundle(args);
|
|
2267
|
-
const nodeVersion =
|
|
2281
|
+
const { nodeVersion } = downloadResult;
|
|
2268
2282
|
const isBun = isBunVersion(nodeVersion);
|
|
2269
2283
|
const builderName = "@vercel/backends";
|
|
2270
2284
|
const span = args.span ?? new Span({ name: builderName });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/backends",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.39",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"homepage": "https://vercel.com/docs",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"ts-morph": "12.0.0",
|
|
38
38
|
"tsx": "4.21.0",
|
|
39
39
|
"zod": "3.22.4",
|
|
40
|
-
"@vercel/build-utils": "14.
|
|
40
|
+
"@vercel/build-utils": "14.2.0",
|
|
41
41
|
"@vercel/static-config": "3.4.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|