You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@vercel/nestjs

Package Overview
Dependencies
Maintainers
327
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/nestjs - npm Package Compare versions

Comparing version
0.1.3
to
0.1.4
+17
-148
./dist/index.js
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;

@@ -20,10 +18,2 @@ var __export = (target, all) => {

};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

@@ -45,141 +35,20 @@

// src/build.ts
var import_node = require("@vercel/node");
var import_build_utils = require("@vercel/build-utils");
var import_node = require("@vercel/node");
var import_module = require("module");
var import_path = require("path");
var import_fs = __toESM(require("fs"));
var frameworkName = "nestjs";
var REGEX = /(?:from|require|import)\s*(?:\(\s*)?["']@nestjs\/core["']\s*(?:\))?/g;
var validFilenames = ["src/app", "src/main"];
var require_ = (0, import_module.createRequire)(__filename);
var validExtensions = ["js", "cjs", "mjs", "ts", "cts", "mts"];
var entrypointsForMessage = validFilenames.map((filename) => `- ${filename}.{${validExtensions.join(",")}}`).join("\n");
var build = async (args) => {
process.env.EXPERIMENTAL_NODE_TYPESCRIPT_ERRORS = "1";
const includeFiles = ["views/**/*"];
const includeFilesFromConfig = args.config.includeFiles;
if (includeFilesFromConfig) {
includeFiles.push(...includeFilesFromConfig);
}
const res = await (0, import_node.build)({
...args,
config: {
...args.config,
includeFiles
},
// this is package.json, but we'll replace it with the return value of the entrypointCallback
// after install and build scripts have had a chance to run
entrypoint: "package.json",
considerBuildCommand: true,
entrypointCallback: async () => {
return entrypointCallback(args);
}
});
res.output.framework = { slug: frameworkName };
return res;
};
var entrypointCallback = async (args) => {
const mainPackageEntrypoint = findMainPackageEntrypoint(args.files);
const entrypointGlob = `{${validFilenames.map((entrypoint) => `${entrypoint}`).join(",")}}.{${validExtensions.join(",")}}`;
const dir = args.config.projectSettings?.outputDirectory?.replace(
/^\/+|\/+$/g,
""
);
if (dir) {
const { entrypoint: entrypointFromOutputDir, entrypointsNotMatchingRegex: entrypointsNotMatchingRegex2 } = findEntrypoint(await (0, import_build_utils.glob)(entrypointGlob, (0, import_path.join)(args.workPath, dir)));
if (entrypointFromOutputDir) {
return (0, import_path.join)(dir, entrypointFromOutputDir);
}
if (entrypointsNotMatchingRegex2.length > 0) {
throw new Error(
`No entrypoint found which imports ${frameworkName}. Found possible ${pluralize("entrypoint", entrypointsNotMatchingRegex2.length)}: ${entrypointsNotMatchingRegex2.join(", ")}`
);
}
throw new Error(
`No entrypoint found in output directory: "${dir}". Searched for:
${entrypointsForMessage}`
);
}
const files = await (0, import_build_utils.glob)(entrypointGlob, args.workPath);
const { entrypoint: entrypointFromRoot, entrypointsNotMatchingRegex } = findEntrypoint(files);
if (entrypointFromRoot) {
return entrypointFromRoot;
}
if (mainPackageEntrypoint) {
const entrypointFromPackageJson = await (0, import_build_utils.glob)(
mainPackageEntrypoint,
args.workPath
);
if (entrypointFromPackageJson[mainPackageEntrypoint]) {
if (checkMatchesRegex(entrypointFromPackageJson[mainPackageEntrypoint])) {
return mainPackageEntrypoint;
}
}
}
if (entrypointsNotMatchingRegex.length > 0) {
throw new Error(
`No entrypoint found which imports ${frameworkName}. Found possible ${pluralize("entrypoint", entrypointsNotMatchingRegex.length)}: ${entrypointsNotMatchingRegex.join(", ")}`
);
}
throw new Error(
`No entrypoint found. Searched for:
${entrypointsForMessage}`
);
};
function pluralize(word, count) {
return count === 1 ? word : `${word}s`;
}
var findEntrypoint = (files) => {
const allEntrypoints = validFilenames.flatMap(
(filename) => validExtensions.map((extension) => `${filename}.${extension}`)
);
const possibleEntrypointsInFiles = allEntrypoints.filter((entrypoint2) => {
return files[entrypoint2] !== void 0;
});
const entrypointsMatchingRegex = possibleEntrypointsInFiles.filter(
(entrypoint2) => {
const file = files[entrypoint2];
return checkMatchesRegex(file);
}
);
const entrypointsNotMatchingRegex = possibleEntrypointsInFiles.filter(
(entrypoint2) => {
const file = files[entrypoint2];
return !checkMatchesRegex(file);
}
);
const entrypoint = entrypointsMatchingRegex[0];
if (entrypointsMatchingRegex.length > 1) {
console.warn(
`Multiple entrypoints found: ${entrypointsMatchingRegex.join(", ")}. Using ${entrypoint}.`
);
}
return {
entrypoint,
entrypointsNotMatchingRegex
};
};
var checkMatchesRegex = (file) => {
const content = import_fs.default.readFileSync(file.fsPath, "utf-8");
const matchesContent = content.match(REGEX);
return matchesContent !== null;
};
var findMainPackageEntrypoint = (files) => {
const packageJson = files["package.json"];
if (packageJson) {
if (packageJson.type === "FileFsRef") {
const packageJsonContent = import_fs.default.readFileSync(packageJson.fsPath, "utf-8");
let packageJsonJson;
try {
packageJsonJson = JSON.parse(packageJsonContent);
} catch (_e) {
packageJsonJson = {};
}
if ("main" in packageJsonJson && typeof packageJsonJson.main === "string") {
return packageJsonJson.main;
}
}
}
return null;
};
var { build, entrypointCallback, findEntrypoint, require_ } = (0, import_build_utils.generateNodeBuilderFunctions)(
"nestjs",
/(?:from|require|import)\s*(?:\(\s*)?["']@nestjs\/core["']\s*(?:\))?/g,
[
"src/main",
// default, so most common
"app",
"index",
"server",
"src/app",
"src/index",
"src/server"
],
["js", "cjs", "mjs", "ts", "cts", "mts"],
import_node.build
);

@@ -186,0 +55,0 @@ // src/index.ts

"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;

@@ -20,10 +18,2 @@ var __export = (target, all) => {

};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

@@ -45,141 +35,20 @@

// src/build.ts
var import_node = require("@vercel/node");
var import_build_utils = require("@vercel/build-utils");
var import_node = require("@vercel/node");
var import_module = require("module");
var import_path = require("path");
var import_fs = __toESM(require("fs"));
var frameworkName = "nestjs";
var REGEX = /(?:from|require|import)\s*(?:\(\s*)?["']@nestjs\/core["']\s*(?:\))?/g;
var validFilenames = ["src/app", "src/main"];
var require_ = (0, import_module.createRequire)(__filename);
var validExtensions = ["js", "cjs", "mjs", "ts", "cts", "mts"];
var entrypointsForMessage = validFilenames.map((filename) => `- ${filename}.{${validExtensions.join(",")}}`).join("\n");
var build = async (args) => {
process.env.EXPERIMENTAL_NODE_TYPESCRIPT_ERRORS = "1";
const includeFiles = ["views/**/*"];
const includeFilesFromConfig = args.config.includeFiles;
if (includeFilesFromConfig) {
includeFiles.push(...includeFilesFromConfig);
}
const res = await (0, import_node.build)({
...args,
config: {
...args.config,
includeFiles
},
// this is package.json, but we'll replace it with the return value of the entrypointCallback
// after install and build scripts have had a chance to run
entrypoint: "package.json",
considerBuildCommand: true,
entrypointCallback: async () => {
return entrypointCallback(args);
}
});
res.output.framework = { slug: frameworkName };
return res;
};
var entrypointCallback = async (args) => {
const mainPackageEntrypoint = findMainPackageEntrypoint(args.files);
const entrypointGlob = `{${validFilenames.map((entrypoint) => `${entrypoint}`).join(",")}}.{${validExtensions.join(",")}}`;
const dir = args.config.projectSettings?.outputDirectory?.replace(
/^\/+|\/+$/g,
""
);
if (dir) {
const { entrypoint: entrypointFromOutputDir, entrypointsNotMatchingRegex: entrypointsNotMatchingRegex2 } = findEntrypoint(await (0, import_build_utils.glob)(entrypointGlob, (0, import_path.join)(args.workPath, dir)));
if (entrypointFromOutputDir) {
return (0, import_path.join)(dir, entrypointFromOutputDir);
}
if (entrypointsNotMatchingRegex2.length > 0) {
throw new Error(
`No entrypoint found which imports ${frameworkName}. Found possible ${pluralize("entrypoint", entrypointsNotMatchingRegex2.length)}: ${entrypointsNotMatchingRegex2.join(", ")}`
);
}
throw new Error(
`No entrypoint found in output directory: "${dir}". Searched for:
${entrypointsForMessage}`
);
}
const files = await (0, import_build_utils.glob)(entrypointGlob, args.workPath);
const { entrypoint: entrypointFromRoot, entrypointsNotMatchingRegex } = findEntrypoint(files);
if (entrypointFromRoot) {
return entrypointFromRoot;
}
if (mainPackageEntrypoint) {
const entrypointFromPackageJson = await (0, import_build_utils.glob)(
mainPackageEntrypoint,
args.workPath
);
if (entrypointFromPackageJson[mainPackageEntrypoint]) {
if (checkMatchesRegex(entrypointFromPackageJson[mainPackageEntrypoint])) {
return mainPackageEntrypoint;
}
}
}
if (entrypointsNotMatchingRegex.length > 0) {
throw new Error(
`No entrypoint found which imports ${frameworkName}. Found possible ${pluralize("entrypoint", entrypointsNotMatchingRegex.length)}: ${entrypointsNotMatchingRegex.join(", ")}`
);
}
throw new Error(
`No entrypoint found. Searched for:
${entrypointsForMessage}`
);
};
function pluralize(word, count) {
return count === 1 ? word : `${word}s`;
}
var findEntrypoint = (files) => {
const allEntrypoints = validFilenames.flatMap(
(filename) => validExtensions.map((extension) => `${filename}.${extension}`)
);
const possibleEntrypointsInFiles = allEntrypoints.filter((entrypoint2) => {
return files[entrypoint2] !== void 0;
});
const entrypointsMatchingRegex = possibleEntrypointsInFiles.filter(
(entrypoint2) => {
const file = files[entrypoint2];
return checkMatchesRegex(file);
}
);
const entrypointsNotMatchingRegex = possibleEntrypointsInFiles.filter(
(entrypoint2) => {
const file = files[entrypoint2];
return !checkMatchesRegex(file);
}
);
const entrypoint = entrypointsMatchingRegex[0];
if (entrypointsMatchingRegex.length > 1) {
console.warn(
`Multiple entrypoints found: ${entrypointsMatchingRegex.join(", ")}. Using ${entrypoint}.`
);
}
return {
entrypoint,
entrypointsNotMatchingRegex
};
};
var checkMatchesRegex = (file) => {
const content = import_fs.default.readFileSync(file.fsPath, "utf-8");
const matchesContent = content.match(REGEX);
return matchesContent !== null;
};
var findMainPackageEntrypoint = (files) => {
const packageJson = files["package.json"];
if (packageJson) {
if (packageJson.type === "FileFsRef") {
const packageJsonContent = import_fs.default.readFileSync(packageJson.fsPath, "utf-8");
let packageJsonJson;
try {
packageJsonJson = JSON.parse(packageJsonContent);
} catch (_e) {
packageJsonJson = {};
}
if ("main" in packageJsonJson && typeof packageJsonJson.main === "string") {
return packageJsonJson.main;
}
}
}
return null;
};
var { build, entrypointCallback, findEntrypoint, require_ } = (0, import_build_utils.generateNodeBuilderFunctions)(
"nestjs",
/(?:from|require|import)\s*(?:\(\s*)?["']@nestjs\/core["']\s*(?:\))?/g,
[
"src/main",
// default, so most common
"app",
"index",
"server",
"src/app",
"src/index",
"src/server"
],
["js", "cjs", "mjs", "ts", "cts", "mts"],
import_node.build
);

@@ -186,0 +55,0 @@ // src/index.ts

+3
-3
{
"name": "@vercel/nestjs",
"version": "0.1.3",
"version": "0.1.4",
"license": "Apache-2.0",

@@ -21,3 +21,3 @@ "main": "./dist/index.js",

"@vercel/static-config": "3.1.2",
"@vercel/node": "5.3.25"
"@vercel/node": "5.3.26"
},

@@ -27,3 +27,3 @@ "devDependencies": {

"@types/node": "14.18.33",
"@vercel/build-utils": "12.1.1",
"@vercel/build-utils": "12.1.2",
"execa": "3.2.0",

@@ -30,0 +30,0 @@ "fs-extra": "11.1.0",