@vercel/node 5.7.6 → 5.7.8
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/bundling-handler.js +24 -4
- package/dist/index.js +9 -2
- package/package.json +3 -3
package/dist/bundling-handler.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
//
|
|
2
2
|
// Unified Lambda handler for bundled vanilla API routes.
|
|
3
|
-
// All bundleable lambdas share this
|
|
3
|
+
// All bundleable lambdas share this handler (same handler digest).
|
|
4
4
|
// It reads x-matched-path to determine which entrypoint to invoke.
|
|
5
5
|
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
6
|
+
// At build time the builder replaces the VERCEL_ENTRYPOINT_PREFIX env lookup
|
|
7
|
+
// with the actual prefix string. The x-matched-path header is set by
|
|
8
8
|
// route rules injected by the builder.
|
|
9
9
|
//
|
|
10
10
|
// This runs at Lambda runtime where the handler is invoked with (req, res).
|
|
@@ -35,6 +35,19 @@ const HTTP_METHODS = [
|
|
|
35
35
|
|
|
36
36
|
const handlerCache = Object.create(null);
|
|
37
37
|
|
|
38
|
+
// At build time the builder replaces the token below with the actual prefix.
|
|
39
|
+
const entrypointPrefix = process.env.VERCEL_ENTRYPOINT_PREFIX;
|
|
40
|
+
|
|
41
|
+
function getEntrypointCandidates(entrypoint) {
|
|
42
|
+
const candidates = [entrypoint];
|
|
43
|
+
|
|
44
|
+
if (typeof entrypointPrefix === 'string' && entrypointPrefix) {
|
|
45
|
+
candidates.push(entrypointPrefix + '/' + entrypoint);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return candidates;
|
|
49
|
+
}
|
|
50
|
+
|
|
38
51
|
/**
|
|
39
52
|
* Resolve an extensionless entrypoint to an actual file path.
|
|
40
53
|
* Tries common JS extensions in order, returning the first match.
|
|
@@ -240,7 +253,14 @@ module.exports = async (req, res) => {
|
|
|
240
253
|
const entrypoint = matchedPath.replace(/^\//, '') || 'index';
|
|
241
254
|
|
|
242
255
|
if (!handlerCache[entrypoint]) {
|
|
243
|
-
|
|
256
|
+
let filePath = null;
|
|
257
|
+
for (const candidate of getEntrypointCandidates(entrypoint)) {
|
|
258
|
+
filePath = resolveEntrypoint(candidate);
|
|
259
|
+
if (filePath) {
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
244
264
|
if (!filePath) {
|
|
245
265
|
res.statusCode = 404;
|
|
246
266
|
res.end('No handler found for ' + entrypoint);
|
package/dist/index.js
CHANGED
|
@@ -85119,8 +85119,15 @@ var build = async ({
|
|
|
85119
85119
|
const enableBundling = process.env.VERCEL_API_FUNCTION_BUNDLING === "1" && config.zeroConfig === true && !isMiddleware && !isEdgeFunction;
|
|
85120
85120
|
if (enableBundling) {
|
|
85121
85121
|
const bundledHandlerName = "___vc_bundled_api_handler.js";
|
|
85122
|
-
|
|
85123
|
-
|
|
85122
|
+
const entrypointPrefix = (0, import_path3.relative)(baseDir, workPath).split(import_path3.sep).join("/");
|
|
85123
|
+
preparedFiles[bundledHandlerName] = new import_build_utils3.FileBlob({
|
|
85124
|
+
data: (0, import_fs.readFileSync)(
|
|
85125
|
+
(0, import_path3.join)((0, import_path3.dirname)(__filename), "bundling-handler.js"),
|
|
85126
|
+
"utf8"
|
|
85127
|
+
).replace(
|
|
85128
|
+
"process.env.VERCEL_ENTRYPOINT_PREFIX",
|
|
85129
|
+
JSON.stringify(entrypointPrefix)
|
|
85130
|
+
)
|
|
85124
85131
|
});
|
|
85125
85132
|
handler = bundledHandlerName;
|
|
85126
85133
|
if (!bundlingRoutesEmitted) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/node",
|
|
3
|
-
"version": "5.7.
|
|
3
|
+
"version": "5.7.8",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"tsx": "4.21.0",
|
|
33
33
|
"typescript": "npm:typescript@5.9.3",
|
|
34
34
|
"undici": "5.28.4",
|
|
35
|
+
"@vercel/build-utils": "13.17.1",
|
|
35
36
|
"@vercel/error-utils": "2.0.3",
|
|
36
|
-
"@vercel/static-config": "3.2.0"
|
|
37
|
-
"@vercel/build-utils": "13.16.0"
|
|
37
|
+
"@vercel/static-config": "3.2.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@babel/core": "7.24.4",
|