@vercel/node 5.3.19 → 5.3.21

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.
@@ -1301,6 +1301,29 @@ async function onDevRequest(req, res) {
1301
1301
  if (handlerEventError) {
1302
1302
  process.exit(1);
1303
1303
  }
1304
+ const publicDir = process.env.VERCEL_DEV_PUBLIC_DIR;
1305
+ if (publicDir && req.url) {
1306
+ const { join: join2 } = await import("path");
1307
+ const { existsSync, statSync } = await import("fs");
1308
+ const { readFile: readFile2 } = await import("fs/promises");
1309
+ const staticPath = join2(process.cwd(), publicDir, req.url);
1310
+ if (existsSync(staticPath) && statSync(staticPath).isFile()) {
1311
+ try {
1312
+ const content = await readFile2(staticPath);
1313
+ const { extname: extname2 } = await import("path");
1314
+ const { contentType } = await import("mime-types");
1315
+ const url = new URL(req.url || "/", "http://localhost");
1316
+ const ext = extname2(url.pathname);
1317
+ const mimeType = contentType(ext) || "application/octet-stream";
1318
+ res.setHeader("Content-Type", mimeType);
1319
+ res.setHeader("Content-Length", content.length);
1320
+ res.statusCode = 200;
1321
+ res.end(content);
1322
+ return;
1323
+ } catch (error) {
1324
+ }
1325
+ }
1326
+ }
1304
1327
  if (!handleEvent) {
1305
1328
  res.statusCode = 500;
1306
1329
  res.end("Bridge is not ready, please try again");
package/dist/index.js CHANGED
@@ -70098,6 +70098,9 @@ var build = async ({
70098
70098
  config.projectSettings?.createdAt
70099
70099
  );
70100
70100
  }
70101
+ if (entrypointCallback) {
70102
+ entrypointPath = (0, import_path3.join)(entrypointFsDirname, await entrypointCallback());
70103
+ }
70101
70104
  const isMiddleware = config.middleware === true;
70102
70105
  let isEdgeFunction = isMiddleware;
70103
70106
  const project = new import_ts_morph.Project();
@@ -70107,25 +70110,6 @@ var build = async ({
70107
70110
  if (runtime) {
70108
70111
  isEdgeFunction = isEdgeRuntime(runtime);
70109
70112
  }
70110
- if (config.projectSettings?.outputDirectory) {
70111
- const outputDirFiles = await (0, import_build_utils3.glob)(
70112
- "**/*",
70113
- (0, import_path3.join)(workPath, config.projectSettings.outputDirectory)
70114
- );
70115
- const outputDirEntrypoint = entrypointCallback?.(outputDirFiles);
70116
- if (outputDirEntrypoint) {
70117
- const outputDirEntrypointPath = (0, import_path3.join)(
70118
- workPath,
70119
- config.projectSettings.outputDirectory,
70120
- outputDirEntrypoint
70121
- );
70122
- entrypointPath = outputDirEntrypointPath;
70123
- } else {
70124
- console.warn(
70125
- `No entrypoint found in output directory ${config.projectSettings.outputDirectory}. Using the original entrypoint of ${entrypoint}.`
70126
- );
70127
- }
70128
- }
70129
70113
  (0, import_build_utils3.debug)("Tracing input files...");
70130
70114
  const traceTime = Date.now();
70131
70115
  const { preparedFiles, shouldAddSourcemapSupport } = await compile2(
@@ -70276,6 +70260,7 @@ function forkDevServer(options) {
70276
70260
  VERCEL_DEV_ENTRYPOINT: options.entrypoint,
70277
70261
  VERCEL_DEV_CONFIG: JSON.stringify(options.config),
70278
70262
  VERCEL_DEV_BUILD_ENV: JSON.stringify(options.meta.buildEnv || {}),
70263
+ VERCEL_DEV_PUBLIC_DIR: options.publicDir || "",
70279
70264
  TS_NODE_TRANSPILE_ONLY: "1",
70280
70265
  TS_NODE_COMPILER_OPTIONS: options.tsConfig?.compilerOptions ? JSON.stringify(options.tsConfig.compilerOptions) : void 0,
70281
70266
  NODE_OPTIONS: nodeOptions
@@ -70320,7 +70305,7 @@ var require_3 = (0, import_module3.createRequire)(__filename);
70320
70305
  var treeKill = (0, import_util.promisify)(import_tree_kill.default);
70321
70306
  var tscPath = (0, import_path5.resolve)((0, import_path5.dirname)(require_3.resolve("typescript")), "../bin/tsc");
70322
70307
  var startDevServer = async (opts) => {
70323
- const { entrypoint, workPath, config, meta = {} } = opts;
70308
+ const { entrypoint, workPath, config, meta = {}, publicDir } = opts;
70324
70309
  const entrypointPath = (0, import_path5.join)(workPath, entrypoint);
70325
70310
  if (config.middleware === true && typeof meta.requestUrl === "string") {
70326
70311
  const project = new import_ts_morph2.Project();
@@ -70403,7 +70388,8 @@ var startDevServer = async (opts) => {
70403
70388
  isTypeScript,
70404
70389
  maybeTranspile,
70405
70390
  meta,
70406
- tsConfig
70391
+ tsConfig,
70392
+ publicDir
70407
70393
  });
70408
70394
  const { pid } = child;
70409
70395
  const message = await readMessage(child);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/node",
3
- "version": "5.3.19",
3
+ "version": "5.3.21",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
@@ -17,7 +17,7 @@
17
17
  "@edge-runtime/primitives": "4.1.0",
18
18
  "@edge-runtime/vm": "3.2.0",
19
19
  "@types/node": "16.18.11",
20
- "@vercel/build-utils": "12.0.0",
20
+ "@vercel/build-utils": "12.1.0",
21
21
  "@vercel/error-utils": "2.0.3",
22
22
  "@vercel/nft": "0.30.1",
23
23
  "@vercel/static-config": "3.1.2",
@@ -27,6 +27,7 @@
27
27
  "es-module-lexer": "1.4.1",
28
28
  "esbuild": "0.14.47",
29
29
  "etag": "1.8.1",
30
+ "mime-types": "2.1.35",
30
31
  "node-fetch": "2.6.9",
31
32
  "path-to-regexp-updated": "npm:path-to-regexp@6.3.0",
32
33
  "path-to-regexp": "6.1.0",
@@ -45,6 +46,7 @@
45
46
  "@types/cookie": "0.3.3",
46
47
  "@types/etag": "1.8.0",
47
48
  "@types/jest": "29.5.0",
49
+ "@types/mime-types": "2.1.4",
48
50
  "@vitest/expect": "1.4.0",
49
51
  "content-type": "1.0.5",
50
52
  "cookie": "0.7.0",