aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexander Niebuhr <alexander@nbhr.io> 2024-08-29 08:17:42 +0200
committerGravatar Alexander Niebuhr <alexander@nbhr.io> 2024-08-29 08:17:42 +0200
commita73afb7f43f4cfd4da70f10091702500fdef229c (patch)
tree51f4967fbf3a5b409e221e8a3d591f1a88a7b433
parent6446ea1092753db02244216d5fdbab861bade4df (diff)
downloadastro-a73afb7f43f4cfd4da70f10091702500fdef229c.tar.gz
astro-a73afb7f43f4cfd4da70f10091702500fdef229c.tar.zst
astro-a73afb7f43f4cfd4da70f10091702500fdef229c.zip
chore: supress linting
-rw-r--r--packages/integrations/vercel/CHANGELOG.md2
-rw-r--r--packages/integrations/vercel/package.json18
-rw-r--r--packages/integrations/vercel/src/image/build-service.ts1
-rw-r--r--packages/integrations/vercel/src/image/shared-dev-service.ts5
-rw-r--r--packages/integrations/vercel/src/image/shared.ts5
-rw-r--r--packages/integrations/vercel/src/lib/nft.ts10
-rw-r--r--packages/integrations/vercel/src/lib/redirects.ts33
-rw-r--r--packages/integrations/vercel/src/lib/speed-insights.ts1
-rw-r--r--packages/integrations/vercel/src/lib/web-analytics.ts1
-rw-r--r--packages/integrations/vercel/src/serverless/adapter.ts118
-rw-r--r--packages/integrations/vercel/src/serverless/entrypoint.ts2
-rw-r--r--packages/integrations/vercel/src/serverless/middleware.ts13
-rw-r--r--packages/integrations/vercel/src/speed-insights.ts3
-rw-r--r--packages/integrations/vercel/src/static/adapter.ts40
-rw-r--r--packages/integrations/vercel/test/edge-middleware.test.js12
-rw-r--r--packages/integrations/vercel/test/hosted/hosted.test.js3
-rw-r--r--packages/integrations/vercel/test/isr.test.js2
-rw-r--r--packages/integrations/vercel/test/max-duration.test.js2
-rw-r--r--packages/integrations/vercel/test/redirects.test.js2
-rw-r--r--packages/integrations/vercel/test/server-islands.test.js2
-rw-r--r--packages/integrations/vercel/test/serverless-prerender.test.js6
-rw-r--r--packages/integrations/vercel/test/serverless-with-dynamic-routes.test.js4
-rw-r--r--packages/integrations/vercel/test/split.test.js2
-rw-r--r--packages/integrations/vercel/test/streaming.test.js2
-rw-r--r--packages/integrations/vercel/tsconfig.json4
25 files changed, 161 insertions, 132 deletions
diff --git a/packages/integrations/vercel/CHANGELOG.md b/packages/integrations/vercel/CHANGELOG.md
index 4a8d6343a..0d6b8778b 100644
--- a/packages/integrations/vercel/CHANGELOG.md
+++ b/packages/integrations/vercel/CHANGELOG.md
@@ -1234,7 +1234,7 @@
{ darkMode: true },
{
expires: '1 month',
- },
+ }
);
const prefs = Astro.cookies.get<Prefs>('prefs').json();
diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json
index 0b6ed9e68..494af148e 100644
--- a/packages/integrations/vercel/package.json
+++ b/packages/integrations/vercel/package.json
@@ -10,10 +10,7 @@
"url": "https://github.com/withastro/astro.git",
"directory": "packages/integrations/vercel"
},
- "keywords": [
- "withastro",
- "astro-adapter"
- ],
+ "keywords": ["withastro", "astro-adapter"],
"bugs": "https://github.com/withastro/astro/issues",
"homepage": "https://docs.astro.build/en/guides/integrations-guide/vercel/",
"exports": {
@@ -31,18 +28,11 @@
},
"typesVersions": {
"*": {
- "serverless": [
- "dist/serverless/adapter.d.ts"
- ],
- "static": [
- "dist/static/adapter.d.ts"
- ]
+ "serverless": ["dist/serverless/adapter.d.ts"],
+ "static": ["dist/static/adapter.d.ts"]
}
},
- "files": [
- "dist",
- "types.d.ts"
- ],
+ "files": ["dist", "types.d.ts"],
"scripts": {
"build": "tsc",
"test": "astro-scripts test --timeout 50000 \"test/**/!(hosted).test.js\"",
diff --git a/packages/integrations/vercel/src/image/build-service.ts b/packages/integrations/vercel/src/image/build-service.ts
index e793b896e..ab2a49e0e 100644
--- a/packages/integrations/vercel/src/image/build-service.ts
+++ b/packages/integrations/vercel/src/image/build-service.ts
@@ -53,6 +53,7 @@ const service: ExternalImageService = {
options.width && searchParams.append('w', options.width.toString());
options.quality && searchParams.append('q', options.quality.toString());
+ // biome-ignore lint/style/useTemplate: <explanation>
return '/_vercel/image?' + searchParams;
},
};
diff --git a/packages/integrations/vercel/src/image/shared-dev-service.ts b/packages/integrations/vercel/src/image/shared-dev-service.ts
index 8ca87e99a..4edf11d3a 100644
--- a/packages/integrations/vercel/src/image/shared-dev-service.ts
+++ b/packages/integrations/vercel/src/image/shared-dev-service.ts
@@ -15,6 +15,7 @@ export const baseDevService: Omit<LocalImageService, 'transform'> = {
options.width && searchParams.append('w', options.width.toString());
options.quality && searchParams.append('q', options.quality.toString());
+ // biome-ignore lint/style/useTemplate: <explanation>
return '/_image?' + searchParams;
},
parseURL(url) {
@@ -25,8 +26,10 @@ export const baseDevService: Omit<LocalImageService, 'transform'> = {
}
const transform = {
+ // biome-ignore lint/style/noNonNullAssertion: <explanation>
src: params.get('href')!,
- width: params.has('w') ? parseInt(params.get('w')!) : undefined,
+ // biome-ignore lint/style/noNonNullAssertion: <explanation>
+ width: params.has('w') ? Number.parseInt(params.get('w')!) : undefined,
quality: params.get('q'),
};
diff --git a/packages/integrations/vercel/src/image/shared.ts b/packages/integrations/vercel/src/image/shared.ts
index da9342f29..dfae0d06f 100644
--- a/packages/integrations/vercel/src/image/shared.ts
+++ b/packages/integrations/vercel/src/image/shared.ts
@@ -68,7 +68,7 @@ export function getAstroImageConfig(
imagesConfig: VercelImageConfig | undefined,
command: string,
devImageService: DevImageService,
- astroImageConfig: AstroConfig['image'],
+ astroImageConfig: AstroConfig['image']
) {
let devService = '@astrojs/vercel/dev-image-service';
@@ -105,7 +105,7 @@ export function getAstroImageConfig(
export function sharedValidateOptions(
options: ImageTransform,
serviceConfig: Record<string, any>,
- mode: 'development' | 'production',
+ mode: 'development' | 'production'
) {
const vercelImageOptions = serviceConfig as VercelImageConfig;
@@ -145,6 +145,7 @@ export function sharedValidateOptions(
} else {
if (!configuredWidths.includes(options.width)) {
const nearestWidth = configuredWidths.reduce((prev, curr) => {
+ // biome-ignore lint/style/noNonNullAssertion: <explanation>
return Math.abs(curr - options.width!) < Math.abs(prev - options.width!) ? curr : prev;
});
diff --git a/packages/integrations/vercel/src/lib/nft.ts b/packages/integrations/vercel/src/lib/nft.ts
index 7f21f3f27..61dcd8f9e 100644
--- a/packages/integrations/vercel/src/lib/nft.ts
+++ b/packages/integrations/vercel/src/lib/nft.ts
@@ -18,7 +18,7 @@ export async function copyDependenciesToFunction(
logger: AstroIntegrationLogger;
},
// we want to pass the caching by reference, and not by value
- cache: object,
+ cache: object
): Promise<{ handler: string }> {
const entryPath = fileURLToPath(entry);
logger.info(`Bundling function ${relativePath(fileURLToPath(outDir), entryPath)}`);
@@ -44,6 +44,7 @@ export async function copyDependenciesToFunction(
for (const error of result.warnings) {
if (error.message.startsWith('Failed to resolve dependency')) {
+ // biome-ignore lint/style/noNonNullAssertion: <explanation>
const [, module, file] = /Cannot find module '(.+?)' loaded from (.+)/.exec(error.message)!;
// The import(astroRemark) sometimes fails to resolve, but it's not a problem
@@ -54,11 +55,11 @@ export async function copyDependenciesToFunction(
if (entryPath === file) {
logger.debug(
- `[@astrojs/vercel] The module "${module}" couldn't be resolved. This may not be a problem, but it's worth checking.`,
+ `[@astrojs/vercel] The module "${module}" couldn't be resolved. This may not be a problem, but it's worth checking.`
);
} else {
logger.debug(
- `[@astrojs/vercel] The module "${module}" inside the file "${file}" couldn't be resolved. This may not be a problem, but it's worth checking.`,
+ `[@astrojs/vercel] The module "${module}" inside the file "${file}" couldn't be resolved. This may not be a problem, but it's worth checking.`
);
}
}
@@ -66,6 +67,7 @@ export async function copyDependenciesToFunction(
// such as this html file in "main" meant for nw instead of node:
// https://github.com/vercel/nft/issues/311
else if (error.message.startsWith('Failed to parse')) {
+ // biome-ignore lint/correctness/noUnnecessaryContinue: <explanation>
continue;
} else {
throw error;
@@ -75,7 +77,7 @@ export async function copyDependenciesToFunction(
const commonAncestor = await copyFilesToFolder(
[...result.fileList].map((file) => new URL(file, base)).concat(includeFiles),
outDir,
- excludeFiles,
+ excludeFiles
);
return {
diff --git a/packages/integrations/vercel/src/lib/redirects.ts b/packages/integrations/vercel/src/lib/redirects.ts
index 1e476cb1f..54c883b3c 100644
--- a/packages/integrations/vercel/src/lib/redirects.ts
+++ b/packages/integrations/vercel/src/lib/redirects.ts
@@ -49,19 +49,19 @@ function getMatchPattern(segments: RoutePart[][]) {
return segment[0].spread
? '(?:\\/(.*?))?'
: segment
- .map((part) => {
- if (part)
- return part.dynamic
- ? '([^/]+?)'
- : part.content
- .normalize()
- .replace(/\?/g, '%3F')
- .replace(/#/g, '%23')
- .replace(/%5B/g, '[')
- .replace(/%5D/g, ']')
- .replace(/[*+?^${}()|[\]\\]/g, '\\$&');
- })
- .join('');
+ .map((part) => {
+ if (part)
+ return part.dynamic
+ ? '([^/]+?)'
+ : part.content
+ .normalize()
+ .replace(/\?/g, '%3F')
+ .replace(/#/g, '%23')
+ .replace(/%5B/g, '[')
+ .replace(/%5D/g, ']')
+ .replace(/[*+?^${}()|[\]\\]/g, '\\$&');
+ })
+ .join('');
})
.join('/');
}
@@ -72,6 +72,7 @@ function getReplacePattern(segments: RoutePart[][]) {
for (const segment of segments) {
for (const part of segment) {
+ // biome-ignore lint/style/useTemplate: <explanation>
if (part.dynamic) result += '$' + ++n;
else result += part.content;
}
@@ -89,8 +90,10 @@ function getRedirectLocation(route: RouteData, config: AstroConfig): string {
const pattern = getReplacePattern(route.redirectRoute.segments);
const path = config.trailingSlash === 'always' ? appendForwardSlash(pattern) : pattern;
return pathJoin(config.base, path);
+ // biome-ignore lint/style/noUselessElse: <explanation>
} else if (typeof route.redirect === 'object') {
return pathJoin(config.base, route.redirect.destination);
+ // biome-ignore lint/style/noUselessElse: <explanation>
} else {
return pathJoin(config.base, route.redirect || '');
}
@@ -114,7 +117,7 @@ export function escapeRegex(content: string) {
}
export function getRedirects(routes: RouteData[], config: AstroConfig): VercelRoute[] {
- let redirects: VercelRoute[] = [];
+ const redirects: VercelRoute[] = [];
for (const route of routes) {
if (route.type === 'redirect') {
@@ -127,11 +130,13 @@ export function getRedirects(routes: RouteData[], config: AstroConfig): VercelRo
if (config.trailingSlash === 'always') {
redirects.push({
src: config.base + getMatchPattern(route.segments),
+ // biome-ignore lint/style/useTemplate: <explanation>
headers: { Location: config.base + getReplacePattern(route.segments) + '/' },
status: 308,
});
} else if (config.trailingSlash === 'never') {
redirects.push({
+ // biome-ignore lint/style/useTemplate: <explanation>
src: config.base + getMatchPattern(route.segments) + '/',
headers: { Location: config.base + getReplacePattern(route.segments) },
status: 308,
diff --git a/packages/integrations/vercel/src/lib/speed-insights.ts b/packages/integrations/vercel/src/lib/speed-insights.ts
index 8e3639536..033a705c5 100644
--- a/packages/integrations/vercel/src/lib/speed-insights.ts
+++ b/packages/integrations/vercel/src/lib/speed-insights.ts
@@ -19,6 +19,7 @@ export function getSpeedInsightsViteConfig(enabled?: boolean) {
export function exposeEnv(envs: string[]): Record<string, unknown> {
const mapped: Record<string, unknown> = {};
+ // biome-ignore lint/complexity/noForEach: <explanation>
envs
.filter((env) => process.env[env])
.forEach((env) => {
diff --git a/packages/integrations/vercel/src/lib/web-analytics.ts b/packages/integrations/vercel/src/lib/web-analytics.ts
index d6ee4d78d..e994ab652 100644
--- a/packages/integrations/vercel/src/lib/web-analytics.ts
+++ b/packages/integrations/vercel/src/lib/web-analytics.ts
@@ -7,6 +7,7 @@ export async function getInjectableWebAnalyticsContent({
}: {
mode: 'development' | 'production';
}) {
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
const base = `window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };`;
if (mode === 'development') {
diff --git a/packages/integrations/vercel/src/serverless/adapter.ts b/packages/integrations/vercel/src/serverless/adapter.ts
index 364d2c861..1d7e64de4 100644
--- a/packages/integrations/vercel/src/serverless/adapter.ts
+++ b/packages/integrations/vercel/src/serverless/adapter.ts
@@ -194,9 +194,11 @@ export default function vercelServerless({
}: VercelServerlessConfig = {}): AstroIntegration {
if (maxDuration) {
if (typeof maxDuration !== 'number') {
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
throw new TypeError(`maxDuration must be a number`, { cause: maxDuration });
}
if (maxDuration <= 0) {
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
throw new TypeError(`maxDuration must be a positive number`, { cause: maxDuration });
}
}
@@ -217,10 +219,11 @@ export default function vercelServerless({
'astro:config:setup': async ({ command, config, updateConfig, injectScript, logger }) => {
if (maxDuration && maxDuration > 900) {
logger.warn(
- `maxDuration is set to ${maxDuration} seconds, which is longer than the maximum allowed duration of 900 seconds.`,
+ `maxDuration is set to ${maxDuration} seconds, which is longer than the maximum allowed duration of 900 seconds.`
);
logger.warn(
- `Please make sure that your plan allows for this duration. See https://vercel.com/docs/functions/serverless-functions/runtimes#maxduration for more information.`,
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
+ `Please make sure that your plan allows for this duration. See https://vercel.com/docs/functions/serverless-functions/runtimes#maxduration for more information.`
);
}
@@ -229,7 +232,7 @@ export default function vercelServerless({
'head-inline',
await getInjectableWebAnalyticsContent({
mode: command === 'dev' ? 'development' : 'production',
- }),
+ })
);
}
if (command === 'build' && speedInsights?.enabled) {
@@ -243,9 +246,10 @@ export default function vercelServerless({
if (vercelConfig.trailingSlash === true && config.trailingSlash === 'always') {
logger.warn(
'\n' +
- `\tYour "vercel.json" \`trailingSlash\` configuration (set to \`true\`) will conflict with your Astro \`trailinglSlash\` configuration (set to \`"always"\`).\n` +
- `\tThis would cause infinite redirects under certain conditions and throw an \`ERR_TOO_MANY_REDIRECTS\` error.\n` +
- `\tTo prevent this, your Astro configuration is updated to \`"ignore"\` during builds.\n`,
+ `\tYour "vercel.json" \`trailingSlash\` configuration (set to \`true\`) will conflict with your Astro \`trailinglSlash\` configuration (set to \`"always"\`).\n` +
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
+ `\tThis would cause infinite redirects under certain conditions and throw an \`ERR_TOO_MANY_REDIRECTS\` error.\n` +
+ `\tTo prevent this, your Astro configuration is updated to \`"ignore"\` during builds.\n`
);
updateConfig({
trailingSlash: 'ignore',
@@ -277,27 +281,32 @@ export default function vercelServerless({
imagesConfig,
command,
devImageService,
- config.image,
+ config.image
),
});
},
'astro:config:done': ({ setAdapter, config, logger }) => {
if (functionPerRoute === true) {
logger.warn(
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
`\n` +
- `\tVercel's hosting plans might have limits to the number of functions you can create.\n` +
- `\tMake sure to check your plan carefully to avoid incurring additional costs.\n` +
- `\tYou can set functionPerRoute: false to prevent surpassing the limit.\n`,
+ `\tVercel's hosting plans might have limits to the number of functions you can create.\n` +
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
+ `\tMake sure to check your plan carefully to avoid incurring additional costs.\n` +
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
+ `\tYou can set functionPerRoute: false to prevent surpassing the limit.\n`
);
logger.warn(
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
`\n` +
- `\t\`functionPerRoute\` is deprecated and will be removed in a future version of the adapter.\n`,
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
+ `\t\`functionPerRoute\` is deprecated and will be removed in a future version of the adapter.\n`
);
}
setAdapter(
- getAdapter({ functionPerRoute, edgeMiddleware, middlewareSecret, skewProtection }),
+ getAdapter({ functionPerRoute, edgeMiddleware, middlewareSecret, skewProtection })
);
_config = config;
@@ -306,13 +315,13 @@ export default function vercelServerless({
if (config.output === 'static') {
throw new AstroError(
- '`output: "server"` or `output: "hybrid"` is required to use the serverless adapter.',
+ '`output: "server"` or `output: "hybrid"` is required to use the serverless adapter.'
);
}
},
'astro:build:ssr': async ({ entryPoints, middlewareEntryPoint }) => {
_entryPoints = new Map(
- Array.from(entryPoints).filter(([routeData]) => !routeData.prerender),
+ Array.from(entryPoints).filter(([routeData]) => !routeData.prerender)
);
_middlewareEntryPoint = middlewareEntryPoint;
},
@@ -397,12 +406,13 @@ export default function vercelServerless({
await builder.buildMiddlewareFolder(
_middlewareEntryPoint,
MIDDLEWARE_PATH,
- middlewareSecret,
+ middlewareSecret
);
}
const fourOhFourRoute = routes.find((route) => route.pathname === '/404');
// Output configuration
// https://vercel.com/docs/build-output-api/v3#build-output-configuration
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
await writeJson(new URL(`./config.json`, _config.outDir), {
version: 3,
routes: [
@@ -416,31 +426,31 @@ export default function vercelServerless({
...routeDefinitions,
...(fourOhFourRoute
? [
- {
- src: '/.*',
- dest: fourOhFourRoute.prerender
- ? '/404.html'
- : _middlewareEntryPoint
- ? MIDDLEWARE_PATH
- : NODE_PATH,
- status: 404,
- },
- ]
+ {
+ src: '/.*',
+ dest: fourOhFourRoute.prerender
+ ? '/404.html'
+ : _middlewareEntryPoint
+ ? MIDDLEWARE_PATH
+ : NODE_PATH,
+ status: 404,
+ },
+ ]
: []),
],
...(imageService || imagesConfig
? {
- images: imagesConfig
- ? {
- ...imagesConfig,
- domains: [...imagesConfig.domains, ..._config.image.domains],
- remotePatterns: [
- ...(imagesConfig.remotePatterns ?? []),
- ..._config.image.remotePatterns,
- ],
- }
- : getDefaultImageConfig(_config.image),
- }
+ images: imagesConfig
+ ? {
+ ...imagesConfig,
+ domains: [...imagesConfig.domains, ..._config.image.domains],
+ remotePatterns: [
+ ...(imagesConfig.remotePatterns ?? []),
+ ..._config.image.remotePatterns,
+ ],
+ }
+ : getDefaultImageConfig(_config.image),
+ }
: {}),
});
@@ -472,8 +482,8 @@ class VercelBuilder {
readonly includeFiles: URL[],
readonly logger: AstroIntegrationLogger,
readonly maxDuration?: number,
- readonly runtime = getRuntime(process, logger),
- ) {}
+ readonly runtime = getRuntime(process, logger)
+ ) { }
async buildServerlessFolder(entry: URL, functionName: string) {
const { config, includeFiles, excludeFiles, logger, NTF_CACHE, runtime, maxDuration } = this;
@@ -491,7 +501,7 @@ class VercelBuilder {
excludeFiles,
logger,
},
- NTF_CACHE,
+ NTF_CACHE
);
// Enable ESM
@@ -513,7 +523,7 @@ class VercelBuilder {
await this.buildServerlessFolder(entry, functionName);
const prerenderConfig = new URL(
`./functions/${functionName}.prerender-config.json`,
- this.config.outDir,
+ this.config.outDir
);
// https://vercel.com/docs/build-output-api/v3/primitives#prerender-configuration-file
await writeJson(prerenderConfig, {
@@ -533,9 +543,10 @@ class VercelBuilder {
new URL(VERCEL_EDGE_MIDDLEWARE_FILE, this.config.srcDir),
new URL('./middleware.mjs', functionFolder),
middlewareSecret,
- this.logger,
+ this.logger
);
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
await writeJson(new URL(`./.vc-config.json`, functionFolder), {
runtime: 'edge',
entrypoint: 'middleware.mjs',
@@ -549,10 +560,14 @@ function getRuntime(process: NodeJS.Process, logger: AstroIntegrationLogger): Ru
const support = SUPPORTED_NODE_VERSIONS[major];
if (support === undefined) {
logger.warn(
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
+ // biome-ignore lint/style/useTemplate: <explanation>
`\n` +
- `\tThe local Node.js version (${major}) is not supported by Vercel Serverless Functions.\n` +
- `\tYour project will use Node.js 18 as the runtime instead.\n` +
- `\tConsider switching your local version to 18.\n`,
+ `\tThe local Node.js version (${major}) is not supported by Vercel Serverless Functions.\n` +
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
+ `\tYour project will use Node.js 18 as the runtime instead.\n` +
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
+ `\tConsider switching your local version to 18.\n`
);
return 'nodejs18.x';
}
@@ -562,26 +577,29 @@ function getRuntime(process: NodeJS.Process, logger: AstroIntegrationLogger): Ru
if (support.status === 'retiring') {
if (support.warnDate && new Date() >= support.warnDate) {
logger.warn(
- `Your project is being built for Node.js ${major} as the runtime, which is retiring by ${support.removal}.`,
+ `Your project is being built for Node.js ${major} as the runtime, which is retiring by ${support.removal}.`
);
}
return `nodejs${major}.x`;
}
if (support.status === 'beta') {
logger.warn(
- `Your project is being built for Node.js ${major} as the runtime, which is currently in beta for Vercel Serverless Functions.`,
+ `Your project is being built for Node.js ${major} as the runtime, which is currently in beta for Vercel Serverless Functions.`
);
return `nodejs${major}.x`;
}
if (support.status === 'deprecated') {
const removeDate = new Intl.DateTimeFormat(undefined, { dateStyle: 'long' }).format(
- support.removal,
+ support.removal
);
logger.warn(
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
+ // biome-ignore lint/style/useTemplate: <explanation>
`\n` +
- `\tYour project is being built for Node.js ${major} as the runtime.\n` +
- `\tThis version is deprecated by Vercel Serverless Functions, and scheduled to be disabled on ${removeDate}.\n` +
- `\tConsider upgrading your local version to 18.\n`,
+ `\tYour project is being built for Node.js ${major} as the runtime.\n` +
+ `\tThis version is deprecated by Vercel Serverless Functions, and scheduled to be disabled on ${removeDate}.\n` +
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
+ `\tConsider upgrading your local version to 18.\n`
);
return `nodejs${major}.x`;
}
diff --git a/packages/integrations/vercel/src/serverless/entrypoint.ts b/packages/integrations/vercel/src/serverless/entrypoint.ts
index a881d701a..31f78bb8a 100644
--- a/packages/integrations/vercel/src/serverless/entrypoint.ts
+++ b/packages/integrations/vercel/src/serverless/entrypoint.ts
@@ -19,7 +19,7 @@ await import('astro/env/setup')
export const createExports = (
manifest: SSRManifest,
- { middlewareSecret, skewProtection }: { middlewareSecret: string; skewProtection: boolean },
+ { middlewareSecret, skewProtection }: { middlewareSecret: string; skewProtection: boolean }
) => {
const app = new NodeApp(manifest);
const handler = async (req: IncomingMessage, res: ServerResponse) => {
diff --git a/packages/integrations/vercel/src/serverless/middleware.ts b/packages/integrations/vercel/src/serverless/middleware.ts
index 07d0843bf..ca84bff33 100644
--- a/packages/integrations/vercel/src/serverless/middleware.ts
+++ b/packages/integrations/vercel/src/serverless/middleware.ts
@@ -26,13 +26,13 @@ export async function generateEdgeMiddleware(
vercelEdgeMiddlewareHandlerPath: URL,
outPath: URL,
middlewareSecret: string,
- logger: AstroIntegrationLogger,
+ logger: AstroIntegrationLogger
): Promise<URL> {
const code = edgeMiddlewareTemplate(
astroMiddlewareEntryPointPath,
vercelEdgeMiddlewareHandlerPath,
middlewareSecret,
- logger,
+ logger
);
// https://vercel.com/docs/concepts/functions/edge-middleware#create-edge-middleware
const bundledFilePath = fileURLToPath(outPath);
@@ -57,6 +57,7 @@ export async function generateEdgeMiddleware(
name: 'esbuild-namespace-node-built-in-modules',
setup(build) {
const filter = new RegExp(builtinModules.map((mod) => `(^${mod}$)`).join('|'));
+ // biome-ignore lint/style/useTemplate: <explanation>
build.onResolve({ filter }, (args) => ({ path: 'node:' + args.path, external: true }));
},
},
@@ -69,20 +70,22 @@ function edgeMiddlewareTemplate(
astroMiddlewareEntryPointPath: URL,
vercelEdgeMiddlewareHandlerPath: URL,
middlewareSecret: string,
- logger: AstroIntegrationLogger,
+ logger: AstroIntegrationLogger
) {
const middlewarePath = JSON.stringify(
- fileURLToPath(astroMiddlewareEntryPointPath).replace(/\\/g, '/'),
+ fileURLToPath(astroMiddlewareEntryPointPath).replace(/\\/g, '/')
);
const filePathEdgeMiddleware = fileURLToPath(vercelEdgeMiddlewareHandlerPath);
let handlerTemplateImport = '';
let handlerTemplateCall = '{}';
+ // biome-ignore lint/style/useTemplate: <explanation>
if (existsSync(filePathEdgeMiddleware + '.js') || existsSync(filePathEdgeMiddleware + '.ts')) {
logger.warn(
- 'Usage of `vercel-edge-middleware.js` is deprecated. You can now use the `waitUntil(promise)` function directly as `ctx.locals.waitUntil(promise)`.',
+ 'Usage of `vercel-edge-middleware.js` is deprecated. You can now use the `waitUntil(promise)` function directly as `ctx.locals.waitUntil(promise)`.'
);
const stringified = JSON.stringify(filePathEdgeMiddleware.replace(/\\/g, '/'));
handlerTemplateImport = `import handler from ${stringified}`;
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
handlerTemplateCall = `await handler({ request, context })`;
} else {
}
diff --git a/packages/integrations/vercel/src/speed-insights.ts b/packages/integrations/vercel/src/speed-insights.ts
index cd2ae7fe8..e8634a270 100644
--- a/packages/integrations/vercel/src/speed-insights.ts
+++ b/packages/integrations/vercel/src/speed-insights.ts
@@ -7,8 +7,11 @@ type Options = { path: string; analyticsId: string };
const getConnectionSpeed = () => {
return 'connection' in navigator &&
+ // biome-ignore lint/complexity/useLiteralKeys: <explanation>
navigator['connection'] &&
+ // biome-ignore lint/complexity/useLiteralKeys: <explanation>
'effectiveType' in (navigator['connection'] as unknown as { effectiveType: string })
+ // biome-ignore lint/complexity/useLiteralKeys: <explanation>
? (navigator['connection'] as unknown as { effectiveType: string })['effectiveType']
: '';
};
diff --git a/packages/integrations/vercel/src/static/adapter.ts b/packages/integrations/vercel/src/static/adapter.ts
index efe3d2da5..bb5762993 100644
--- a/packages/integrations/vercel/src/static/adapter.ts
+++ b/packages/integrations/vercel/src/static/adapter.ts
@@ -74,7 +74,7 @@ export default function vercelStatic({
'head-inline',
await getInjectableWebAnalyticsContent({
mode: command === 'dev' ? 'development' : 'production',
- }),
+ })
);
}
if (command === 'build' && speedInsights?.enabled) {
@@ -95,7 +95,7 @@ export default function vercelStatic({
imagesConfig,
command,
devImageService,
- config.image,
+ config.image
),
});
},
@@ -128,27 +128,29 @@ export default function vercelStatic({
{ handle: 'filesystem' },
...(routes.find((route) => route.pathname === '/404')
? [
- {
- src: `/.*`,
- dest: `/404.html`,
- status: 404,
- },
- ]
+ {
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
+ src: `/.*`,
+ // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
+ dest: `/404.html`,
+ status: 404,
+ },
+ ]
: []),
],
...(imageService || imagesConfig
? {
- images: imagesConfig
- ? {
- ...imagesConfig,
- domains: [...imagesConfig.domains, ..._config.image.domains],
- remotePatterns: [
- ...(imagesConfig.remotePatterns ?? []),
- ..._config.image.remotePatterns,
- ],
- }
- : getDefaultImageConfig(_config.image),
- }
+ images: imagesConfig
+ ? {
+ ...imagesConfig,
+ domains: [...imagesConfig.domains, ..._config.image.domains],
+ remotePatterns: [
+ ...(imagesConfig.remotePatterns ?? []),
+ ..._config.image.remotePatterns,
+ ],
+ }
+ : getDefaultImageConfig(_config.image),
+ }
: {}),
});
},
diff --git a/packages/integrations/vercel/test/edge-middleware.test.js b/packages/integrations/vercel/test/edge-middleware.test.js
index 9ae583a11..4e67433d0 100644
--- a/packages/integrations/vercel/test/edge-middleware.test.js
+++ b/packages/integrations/vercel/test/edge-middleware.test.js
@@ -14,7 +14,7 @@ describe('Vercel edge middleware', () => {
it('an edge function is created', async () => {
const contents = await build.readFile(
- '../.vercel/output/functions/_middleware.func/.vc-config.json',
+ '../.vercel/output/functions/_middleware.func/.vc-config.json'
);
const contentsJSON = JSON.parse(contents);
assert.equal(contentsJSON.runtime, 'edge');
@@ -26,14 +26,14 @@ describe('Vercel edge middleware', () => {
const { routes } = JSON.parse(contents);
assert.equal(
routes.some((route) => route.dest === '_middleware'),
- true,
+ true
);
});
it('edge sets Set-Cookie headers', async () => {
- let entry = new URL(
+ const entry = new URL(
'../.vercel/output/functions/_middleware.func/middleware.mjs',
- build.config.outDir,
+ build.config.outDir
);
const module = await import(entry);
const request = new Request('http://example.com/foo');
@@ -50,7 +50,7 @@ describe('Vercel edge middleware', () => {
await fixture.build();
const contents = await fixture.readFile(
// this is abysmal...
- '../.vercel/output/functions/render.func/www/withastro/astro/packages/integrations/vercel/test/fixtures/middleware-with-edge-file/dist/middleware.mjs',
+ '../.vercel/output/functions/render.func/www/withastro/astro/packages/integrations/vercel/test/fixtures/middleware-with-edge-file/dist/middleware.mjs'
);
console.log(contents);
// assert.equal(contents.includes('title:')).to.be.true;
@@ -66,7 +66,7 @@ describe('Vercel edge middleware', () => {
await fixture.build();
const contents = await fixture.readFile(
// this is abysmal...
- '../.vercel/output/functions/render.func/www/withastro/astro/packages/integrations/vercel/test/fixtures/middleware-without-edge-file/dist/middleware.mjs',
+ '../.vercel/output/functions/render.func/www/withastro/astro/packages/integrations/vercel/test/fixtures/middleware-without-edge-file/dist/middleware.mjs'
);
console.log(contents);
// assert.equal(contents.includes('title:')).to.be.false;
diff --git a/packages/integrations/vercel/test/hosted/hosted.test.js b/packages/integrations/vercel/test/hosted/hosted.test.js
index e090188a7..d7c2ece20 100644
--- a/packages/integrations/vercel/test/hosted/hosted.test.js
+++ b/packages/integrations/vercel/test/hosted/hosted.test.js
@@ -6,7 +6,8 @@ const VERCEL_TEST_URL = 'https://astro-vercel-image-test.vercel.app';
describe('Hosted Vercel Tests', () => {
it('Image endpoint works', async () => {
const image = await fetch(
- VERCEL_TEST_URL + '/_image?href=%2F_astro%2Fpenguin.e9c64733.png&w=300&f=webp',
+ // biome-ignore lint/style/useTemplate: <explanation>
+ VERCEL_TEST_URL + '/_image?href=%2F_astro%2Fpenguin.e9c64733.png&w=300&f=webp'
);
assert.equal(image.status, 200);
diff --git a/packages/integrations/vercel/test/isr.test.js b/packages/integrations/vercel/test/isr.test.js
index fb957aa78..a8df2c0ef 100644
--- a/packages/integrations/vercel/test/isr.test.js
+++ b/packages/integrations/vercel/test/isr.test.js
@@ -15,7 +15,7 @@ describe('ISR', () => {
it('generates expected prerender config', async () => {
const vcConfig = JSON.parse(
- await fixture.readFile('../.vercel/output/functions/_isr.prerender-config.json'),
+ await fixture.readFile('../.vercel/output/functions/_isr.prerender-config.json')
);
assert.deepEqual(vcConfig, {
expiration: 120,
diff --git a/packages/integrations/vercel/test/max-duration.test.js b/packages/integrations/vercel/test/max-duration.test.js
index d5e26fc1a..2a7698663 100644
--- a/packages/integrations/vercel/test/max-duration.test.js
+++ b/packages/integrations/vercel/test/max-duration.test.js
@@ -15,7 +15,7 @@ describe('maxDuration', () => {
it('makes it to vercel function configuration', async () => {
const vcConfig = JSON.parse(
- await fixture.readFile('../.vercel/output/functions/_render.func/.vc-config.json'),
+ await fixture.readFile('../.vercel/output/functions/_render.func/.vc-config.json')
);
assert.equal(vcConfig.maxDuration, 60);
});
diff --git a/packages/integrations/vercel/test/redirects.test.js b/packages/integrations/vercel/test/redirects.test.js
index 9d4f9499e..57de308e2 100644
--- a/packages/integrations/vercel/test/redirects.test.js
+++ b/packages/integrations/vercel/test/redirects.test.js
@@ -77,7 +77,7 @@ describe('Redirects', () => {
const config = await getConfig();
assert.equal(
config.routes.find((r) => r.src === '/'),
- undefined,
+ undefined
);
});
});
diff --git a/packages/integrations/vercel/test/server-islands.test.js b/packages/integrations/vercel/test/server-islands.test.js
index 0306bb8b2..f4f176707 100644
--- a/packages/integrations/vercel/test/server-islands.test.js
+++ b/packages/integrations/vercel/test/server-islands.test.js
@@ -16,7 +16,7 @@ describe('Server Islands', () => {
it('server islands route is in the config', async () => {
const config = JSON.parse(await fixture.readFile('../.vercel/output/config.json'));
let found = null;
- for (let route of config.routes) {
+ for (const route of config.routes) {
if (route.src?.includes('_server-islands')) {
found = route;
break;
diff --git a/packages/integrations/vercel/test/serverless-prerender.test.js b/packages/integrations/vercel/test/serverless-prerender.test.js
index 61e239300..5b75418c9 100644
--- a/packages/integrations/vercel/test/serverless-prerender.test.js
+++ b/packages/integrations/vercel/test/serverless-prerender.test.js
@@ -20,7 +20,7 @@ describe('Serverless prerender', () => {
it('outDir is tree-shaken if not needed', async () => {
const [file] = await fixture.glob(
- '../.vercel/output/functions/_render.func/packages/integrations/vercel/test/fixtures/serverless-prerender/.vercel/output/_functions/pages/_image.astro.mjs',
+ '../.vercel/output/functions/_render.func/packages/integrations/vercel/test/fixtures/serverless-prerender/.vercel/output/_functions/pages/_image.astro.mjs'
);
const contents = await fixture.readFile(file);
assert.ok(!contents.includes('const outDir ='), "outDir is tree-shaken if it's not imported");
@@ -30,8 +30,8 @@ describe('Serverless prerender', () => {
it.skip('includeFiles work', async () => {
assert.ok(
await fixture.readFile(
- '../.vercel/output/functions/render.func/packages/integrations/vercel/test/fixtures/serverless-prerender/dist/middleware.mjs',
- ),
+ '../.vercel/output/functions/render.func/packages/integrations/vercel/test/fixtures/serverless-prerender/dist/middleware.mjs'
+ )
);
});
});
diff --git a/packages/integrations/vercel/test/serverless-with-dynamic-routes.test.js b/packages/integrations/vercel/test/serverless-with-dynamic-routes.test.js
index 3f9613834..0967f864b 100644
--- a/packages/integrations/vercel/test/serverless-with-dynamic-routes.test.js
+++ b/packages/integrations/vercel/test/serverless-with-dynamic-routes.test.js
@@ -18,10 +18,10 @@ describe('Serverless with dynamic routes', () => {
it('build successful', async () => {
assert.ok(await fixture.readFile('../.vercel/output/static/index.html'));
assert.ok(
- await fixture.readFile('../.vercel/output/functions/[id]/index.astro.func/.vc-config.json'),
+ await fixture.readFile('../.vercel/output/functions/[id]/index.astro.func/.vc-config.json')
);
assert.ok(
- await fixture.readFile('../.vercel/output/functions/api/[id].js.func/.vc-config.json'),
+ await fixture.readFile('../.vercel/output/functions/api/[id].js.func/.vc-config.json')
);
});
});
diff --git a/packages/integrations/vercel/test/split.test.js b/packages/integrations/vercel/test/split.test.js
index 4105db7fc..e64a4dc60 100644
--- a/packages/integrations/vercel/test/split.test.js
+++ b/packages/integrations/vercel/test/split.test.js
@@ -26,7 +26,7 @@ describe('build: split', () => {
assert.equal(config.routes.length, 5);
assert.equal(
config.routes.some((route) => route.dest === 'prerender.astro'),
- false,
+ false
);
});
});
diff --git a/packages/integrations/vercel/test/streaming.test.js b/packages/integrations/vercel/test/streaming.test.js
index 1e4b0f111..a0172a7e6 100644
--- a/packages/integrations/vercel/test/streaming.test.js
+++ b/packages/integrations/vercel/test/streaming.test.js
@@ -15,7 +15,7 @@ describe('streaming', () => {
it('makes it to vercel function configuration', async () => {
const vcConfig = JSON.parse(
- await fixture.readFile('../.vercel/output/functions/_render.func/.vc-config.json'),
+ await fixture.readFile('../.vercel/output/functions/_render.func/.vc-config.json')
);
assert.equal(vcConfig.supportsResponseStreaming, true);
});
diff --git a/packages/integrations/vercel/tsconfig.json b/packages/integrations/vercel/tsconfig.json
index b9feb9b9b..18443cddf 100644
--- a/packages/integrations/vercel/tsconfig.json
+++ b/packages/integrations/vercel/tsconfig.json
@@ -1,8 +1,6 @@
{
"extends": "../../tsconfig.base.json",
- "include": [
- "src"
- ],
+ "include": ["src"],
"compilerOptions": {
"outDir": "./dist"
}