@vercel/node 5.3.16 → 5.3.17

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.
@@ -1092,6 +1092,7 @@ import { isAbsolute } from "path";
1092
1092
  import { pathToFileURL } from "url";
1093
1093
  import { buildToHeaders as buildToHeaders2 } from "@edge-runtime/node-utils";
1094
1094
  import { promisify } from "util";
1095
+ import http from "http";
1095
1096
  var toHeaders2 = buildToHeaders2({ Headers: Headers3 });
1096
1097
  var HTTP_METHODS = [
1097
1098
  "GET",
@@ -1103,7 +1104,12 @@ var HTTP_METHODS = [
1103
1104
  "PATCH"
1104
1105
  ];
1105
1106
  async function createServerlessServer(userCode) {
1106
- const server = createServer(userCode);
1107
+ let server;
1108
+ if (typeof userCode === "function") {
1109
+ server = createServer(userCode);
1110
+ } else {
1111
+ server = userCode;
1112
+ }
1107
1113
  return {
1108
1114
  url: await listen(server, { host: "127.0.0.1", port: 0 }),
1109
1115
  onExit: promisify(server.close.bind(server))
@@ -1111,7 +1117,15 @@ async function createServerlessServer(userCode) {
1111
1117
  }
1112
1118
  async function compileUserCode2(entrypointPath, awaiter, options) {
1113
1119
  const id = isAbsolute(entrypointPath) ? pathToFileURL(entrypointPath).href : entrypointPath;
1120
+ let server = null;
1121
+ const originalListen = http.Server.prototype.listen;
1122
+ http.Server.prototype.listen = function() {
1123
+ server = this;
1124
+ http.Server.prototype.listen = originalListen;
1125
+ return this;
1126
+ };
1114
1127
  let listener = await import(id);
1128
+ http.Server.prototype.listen = originalListen;
1115
1129
  for (let i = 0; i < 5; i++) {
1116
1130
  if (listener.default)
1117
1131
  listener = listener.default;
@@ -1141,6 +1155,9 @@ async function compileUserCode2(entrypointPath, awaiter, options) {
1141
1155
  }
1142
1156
  return getWebExportsHandler(handler, HTTP_METHODS);
1143
1157
  }
1158
+ if (server) {
1159
+ return server;
1160
+ }
1144
1161
  return async (req, res) => {
1145
1162
  if (options.shouldAddHelpers && typeof listener.listen !== "function") {
1146
1163
  await addHelpers(req, res);
package/dist/index.js CHANGED
@@ -69503,7 +69503,18 @@ function register(opts = {}) {
69503
69503
  getCurrentDirectory: () => cwd,
69504
69504
  getCompilationSettings: () => config.options,
69505
69505
  getDefaultLibFileName: () => ts.getDefaultLibFilePath(config.options),
69506
- getCustomTransformers: () => transformers
69506
+ getCustomTransformers: () => transformers,
69507
+ resolveModuleNames: (moduleNames, containingFile) => {
69508
+ return moduleNames.map((moduleName) => {
69509
+ const result = ts.resolveModuleName(
69510
+ moduleName,
69511
+ containingFile,
69512
+ config.options,
69513
+ ts.sys
69514
+ );
69515
+ return result.resolvedModule;
69516
+ });
69517
+ }
69507
69518
  };
69508
69519
  const registry = ts.createDocumentRegistry(
69509
69520
  ts.sys.useCaseSensitiveFileNames,
@@ -69780,6 +69791,21 @@ async function downloadInstallAndBundle({
69780
69791
  meta
69781
69792
  );
69782
69793
  const spawnOpts = (0, import_build_utils3.getSpawnOptions)(meta, nodeVersion);
69794
+ const {
69795
+ cliType,
69796
+ lockfileVersion,
69797
+ packageJsonPackageManager,
69798
+ turboSupportsCorepackHome
69799
+ } = await (0, import_build_utils3.scanParentDirs)(entrypointFsDirname, true);
69800
+ spawnOpts.env = (0, import_build_utils3.getEnvForPackageManager)({
69801
+ cliType,
69802
+ lockfileVersion,
69803
+ packageJsonPackageManager,
69804
+ nodeVersion,
69805
+ env: spawnOpts.env || {},
69806
+ turboSupportsCorepackHome,
69807
+ projectCreatedAt: config.projectSettings?.createdAt
69808
+ });
69783
69809
  const installCommand = config.projectSettings?.installCommand;
69784
69810
  if (typeof installCommand === "string" && considerBuildCommand) {
69785
69811
  if (installCommand.trim()) {
@@ -69814,6 +69840,9 @@ function renameTStoJS(path) {
69814
69840
  if (path.endsWith(".mts")) {
69815
69841
  return path.slice(0, -4) + ".mjs";
69816
69842
  }
69843
+ if (path.endsWith(".cts")) {
69844
+ return path.slice(0, -4) + ".cjs";
69845
+ }
69817
69846
  return path;
69818
69847
  }
69819
69848
  async function compile2(workPath, baseDir, entrypointPath, config, meta, nodeVersion, isEdgeFunction) {
@@ -69907,7 +69936,7 @@ async function compile2(workPath, baseDir, entrypointPath, config, meta, nodeVer
69907
69936
  }
69908
69937
  }
69909
69938
  }
69910
- if (fsPath.endsWith(".ts") && !fsPath.endsWith(".d.ts") || fsPath.endsWith(".tsx") || fsPath.endsWith(".mts")) {
69939
+ if (fsPath.endsWith(".ts") && !fsPath.endsWith(".d.ts") || fsPath.endsWith(".tsx") || fsPath.endsWith(".mts") || fsPath.endsWith(".cts")) {
69911
69940
  source = compileTypeScript(fsPath, source.toString());
69912
69941
  }
69913
69942
  if (!entry) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/node",
3
- "version": "5.3.16",
3
+ "version": "5.3.17",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",