Socket
Socket
Sign inDemoInstall

@vercel/build-utils

Package Overview
Dependencies
Maintainers
85
Versions
317
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/build-utils - npm Package Compare versions

Comparing version 2.12.3-canary.21 to 2.12.3-canary.22

35

dist/convert-runtime-to-plugin.d.ts

@@ -14,2 +14,4 @@ import { Lambda } from './lambda';

regions?: string[];
trailingSlash?: boolean;
cleanUrls?: boolean;
};

@@ -34,7 +36,26 @@ workPath: string;

/**
* Will append routes to the `routes-manifest.json` file.
* If the file does not exist, it'll be created.
* Append routes to the `routes-manifest.json` file.
* If the file does not exist, it will be created.
*/
export declare function updateRoutesManifest({ workPath, dynamicRoutes, }: {
export declare function updateRoutesManifest({ workPath, redirects, rewrites, headers, dynamicRoutes, staticRoutes, }: {
workPath: string;
redirects?: {
source: string;
destination: string;
statusCode: number;
regex: string;
}[];
rewrites?: {
source: string;
destination: string;
regex: string;
}[];
headers?: {
source: string;
headers: {
key: string;
value: string;
}[];
regex: string;
}[];
dynamicRoutes?: {

@@ -48,2 +69,10 @@ page: string;

}[];
staticRoutes?: {
page: string;
regex: string;
namedRegex?: string;
routeKeys?: {
[named: string]: string;
};
}[];
}): Promise<void>;

@@ -11,2 +11,3 @@ "use strict";

const normalize_path_1 = require("./fs/normalize-path");
const detect_builders_1 = require("./detect-builders");
const lambda_1 = require("./lambda");

@@ -22,2 +23,3 @@ const minimatch_1 = __importDefault(require("minimatch"));

return async function build({ vercelConfig, workPath, }) {
var _a;
const opts = { cwd: workPath };

@@ -28,3 +30,3 @@ const files = await glob_1.default('**', opts);

const pages = {};
const { functions = {} } = vercelConfig;
const { functions = {}, cleanUrls, trailingSlash } = vercelConfig;
const traceDir = path_1.join(workPath, '.output', 'runtime-traced-files');

@@ -86,2 +88,49 @@ await fs_extra_1.default.ensureDir(traceDir);

await updateFunctionsManifest({ vercelConfig, workPath, pages });
const { warnings, errors,
//defaultRoutes,
redirectRoutes,
//rewriteRoutes,
dynamicRoutesWithKeys,
// errorRoutes, already handled by pages404
} = await detect_builders_1.detectBuilders(Object.keys(files), null, {
tag: 'latest',
functions: functions,
projectSettings: undefined,
featHandleMiss: true,
cleanUrls,
trailingSlash,
});
if (errors) {
throw new Error(errors[0].message);
}
if (warnings) {
warnings.forEach(warning => console.warn(warning.message, warning.link));
}
const redirects = (_a = redirectRoutes === null || redirectRoutes === void 0 ? void 0 : redirectRoutes.filter(r => r.src && 'headers' in r)) === null || _a === void 0 ? void 0 : _a.map(r => {
var _a;
return ({
source: r.src || '',
destination: 'headers' in r && ((_a = r.headers) === null || _a === void 0 ? void 0 : _a.Location) ? r.headers.Location : '',
statusCode: 'status' in r && r.status ? r.status : 307,
regex: r.src || '',
});
});
const dynamicRoutes = dynamicRoutesWithKeys === null || dynamicRoutesWithKeys === void 0 ? void 0 : dynamicRoutesWithKeys.map(r => {
const keys = Object.keys(r.routeKeys);
return {
page: '/' + r.fileName.slice(0, -ext.length),
regex: r.regex,
routeKeys: r.routeKeys,
namedRegex: r.regex
.split('([^/]+)')
.map((str, i) => str + (keys[i] ? `(?<${keys[i]}>[^/]+)` : ''))
.join(''),
};
});
await updateRoutesManifest({
workPath,
redirects,
rewrites: [],
dynamicRoutes,
});
};

@@ -140,12 +189,27 @@ }

/**
* Will append routes to the `routes-manifest.json` file.
* If the file does not exist, it'll be created.
* Append routes to the `routes-manifest.json` file.
* If the file does not exist, it will be created.
*/
async function updateRoutesManifest({ workPath, dynamicRoutes, }) {
async function updateRoutesManifest({ workPath, redirects, rewrites, headers, dynamicRoutes, staticRoutes, }) {
const routesManifestPath = path_1.join(workPath, '.output', 'routes-manifest.json');
const routesManifest = await readJson(routesManifestPath);
if (!routesManifest.version)
routesManifest.version = 1;
routesManifest.version = 3;
if (routesManifest.pages404 === undefined)
routesManifest.pages404 = true;
if (redirects) {
if (!routesManifest.redirects)
routesManifest.redirects = [];
routesManifest.redirects.push(...redirects);
}
if (rewrites) {
if (!routesManifest.rewrites)
routesManifest.rewrites = [];
routesManifest.rewrites.push(...rewrites);
}
if (headers) {
if (!routesManifest.headers)
routesManifest.headers = [];
routesManifest.headers.push(...headers);
}
if (dynamicRoutes) {

@@ -156,4 +220,9 @@ if (!routesManifest.dynamicRoutes)

}
if (staticRoutes) {
if (!routesManifest.staticRoutes)
routesManifest.staticRoutes = [];
routesManifest.staticRoutes.push(...staticRoutes);
}
await fs_extra_1.default.writeFile(routesManifestPath, JSON.stringify(routesManifest));
}
exports.updateRoutesManifest = updateRoutesManifest;

@@ -9,2 +9,9 @@ import { Route } from '@vercel/routing-utils';

}
interface DynamicRoutesWithKeys {
fileName: string;
regex: string;
routeKeys: {
[key: string]: string;
};
}
interface Options {

@@ -38,3 +45,4 @@ tag?: 'canary' | 'latest' | string;

errorRoutes: Route[] | null;
dynamicRoutesWithKeys: DynamicRoutesWithKeys[] | null;
}>;
export {};

@@ -69,2 +69,3 @@ "use strict";

errorRoutes: null,
dynamicRoutesWithKeys: null,
};

@@ -103,2 +104,3 @@ }

const dynamicRoutes = [];
const dynamicRoutesWithKeys = [];
// API

@@ -108,3 +110,3 @@ for (const fileName of sortedFiles) {

if (apiBuilder) {
const { routeError, apiRoute, isDynamic } = getApiRoute(fileName, apiSortedFiles, options, absolutePathCache);
const { routeError, apiRoute, isDynamic, routeKeys } = getApiRoute(fileName, apiSortedFiles, options, absolutePathCache);
if (routeError) {

@@ -119,2 +121,3 @@ return {

errorRoutes: null,
dynamicRoutesWithKeys: null,
};

@@ -126,2 +129,7 @@ }

dynamicRoutes.push(apiRoute);
dynamicRoutesWithKeys.push({
fileName,
regex: apiRoute.src,
routeKeys,
});
}

@@ -175,2 +183,3 @@ }

errorRoutes: null,
dynamicRoutesWithKeys: null,
};

@@ -212,2 +221,3 @@ }

errorRoutes: null,
dynamicRoutesWithKeys: null,
};

@@ -240,2 +250,3 @@ }

errorRoutes: routesResult.errorRoutes,
dynamicRoutesWithKeys,
};

@@ -495,2 +506,3 @@ }

isDynamic: false,
routeKeys: {},
routeError: {

@@ -510,2 +522,3 @@ code: 'conflicting_path_segment',

isDynamic: false,
routeKeys: {},
routeError: {

@@ -523,2 +536,3 @@ code: 'conflicting_file_path',

isDynamic: out.isDynamic,
routeKeys: out.routeKeys,
routeError: null,

@@ -633,2 +647,3 @@ };

const query = [];
const routeKeys = {};
let isDynamic = false;

@@ -641,2 +656,3 @@ const srcParts = parts.map((segment, i) => {

query.push(`${name}=$${counter++}`);
routeKeys[name] = name;
isDynamic = true;

@@ -684,3 +700,3 @@ return `([^/]+)`;

}
return { route, isDynamic };
return { route, isDynamic, routeKeys };
}

@@ -687,0 +703,0 @@ function getRouteResult(apiRoutes, dynamicRoutes, outputDirectory, apiBuilders, frontendBuilder, options) {

4

package.json
{
"name": "@vercel/build-utils",
"version": "2.12.3-canary.21",
"version": "2.12.3-canary.22",
"license": "MIT",

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

},
"gitHead": "cc7b2691c1d43ecb19f1dd6e88f29137d85da61a"
"gitHead": "0cacb1bdace342133fad4bd7a98354e5b2948df0"
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc