mirror of
https://github.com/withastro/astro.git
synced 2025-03-10 23:01:26 -05:00
chore: supress linting
This commit is contained in:
parent
8ebe280b89
commit
fccd6d5cde
23 changed files with 91 additions and 63 deletions
|
@ -1282,7 +1282,7 @@
|
|||
{ darkMode: true },
|
||||
{
|
||||
expires: '1 month',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const prefs = Astro.cookies.get<Prefs>('prefs').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": {
|
||||
|
@ -30,18 +27,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\"",
|
||||
|
|
|
@ -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;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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,7 +26,10 @@ export const baseDevService: Omit<LocalImageService, 'transform'> = {
|
|||
}
|
||||
|
||||
const transform = {
|
||||
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
||||
src: params.get('href')!,
|
||||
// biome-ignore lint/style/useNumberNamespace: <explanation>
|
||||
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
||||
width: params.has('w') ? parseInt(params.get('w')!) : undefined,
|
||||
quality: params.get('q'),
|
||||
};
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
@ -102,7 +102,7 @@ export function getAstroImageConfig(
|
|||
export function sharedValidateOptions(
|
||||
options: ImageTransform,
|
||||
serviceConfig: Record<string, any>,
|
||||
mode: 'development' | 'production',
|
||||
mode: 'development' | 'production'
|
||||
) {
|
||||
const vercelImageOptions = serviceConfig as VercelImageConfig;
|
||||
|
||||
|
@ -142,6 +142,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;
|
||||
});
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,6 +117,7 @@ export function escapeRegex(content: string) {
|
|||
}
|
||||
|
||||
export function getRedirects(routes: RouteData[], config: AstroConfig): VercelRoute[] {
|
||||
// biome-ignore lint/style/useConst: <explanation>
|
||||
let redirects: VercelRoute[] = [];
|
||||
|
||||
for (const route of routes) {
|
||||
|
@ -127,11 +131,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,
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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') {
|
||||
|
|
|
@ -183,9 +183,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 });
|
||||
}
|
||||
}
|
||||
|
@ -206,10 +208,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.`
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -218,7 +221,7 @@ export default function vercelServerless({
|
|||
'head-inline',
|
||||
await getInjectableWebAnalyticsContent({
|
||||
mode: command === 'dev' ? 'development' : 'production',
|
||||
}),
|
||||
})
|
||||
);
|
||||
}
|
||||
if (command === 'build' && speedInsights?.enabled) {
|
||||
|
@ -233,8 +236,9 @@ export default function vercelServerless({
|
|||
logger.warn(
|
||||
'\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`,
|
||||
`\tTo prevent this, your Astro configuration is updated to \`"ignore"\` during builds.\n`
|
||||
);
|
||||
updateConfig({
|
||||
trailingSlash: 'ignore',
|
||||
|
@ -266,7 +270,7 @@ export default function vercelServerless({
|
|||
imagesConfig,
|
||||
command,
|
||||
devImageService,
|
||||
config.image,
|
||||
config.image
|
||||
),
|
||||
});
|
||||
},
|
||||
|
@ -279,13 +283,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;
|
||||
},
|
||||
|
@ -370,12 +374,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: [
|
||||
|
@ -445,7 +450,7 @@ 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) {
|
||||
|
@ -464,7 +469,7 @@ class VercelBuilder {
|
|||
excludeFiles,
|
||||
logger,
|
||||
},
|
||||
NTF_CACHE,
|
||||
NTF_CACHE
|
||||
);
|
||||
|
||||
// Enable ESM
|
||||
|
@ -486,7 +491,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, {
|
||||
|
@ -506,9 +511,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',
|
||||
|
@ -522,10 +528,14 @@ function getRuntime(process: NodeJS.Process, logger: AstroIntegrationLogger): Ru
|
|||
const support = SUPPORTED_NODE_VERSIONS[major];
|
||||
if (support === undefined) {
|
||||
logger.warn(
|
||||
// biome-ignore lint/style/useTemplate: <explanation>
|
||||
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
|
||||
`\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` +
|
||||
`\tConsider switching your local version to 18.\n`,
|
||||
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
|
||||
`\tConsider switching your local version to 18.\n`
|
||||
);
|
||||
return 'nodejs18.x';
|
||||
}
|
||||
|
@ -535,26 +545,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/useTemplate: <explanation>
|
||||
// biome-ignore lint/style/noUnusedTemplateLiteral: <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`,
|
||||
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
|
||||
`\tConsider upgrading your local version to 18.\n`
|
||||
);
|
||||
return `nodejs${major}.x`;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ setGetEnv((key) => process.env[key]);
|
|||
|
||||
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) => {
|
||||
|
|
|
@ -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 {
|
||||
}
|
||||
|
|
|
@ -7,9 +7,12 @@ 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 })
|
||||
? (navigator['connection'] as unknown as { effectiveType: string })['effectiveType']
|
||||
? // biome-ignore lint/complexity/useLiteralKeys: <explanation>
|
||||
(navigator['connection'] as unknown as { effectiveType: string })['effectiveType']
|
||||
: '';
|
||||
};
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ export default function vercelStatic({
|
|||
'head-inline',
|
||||
await getInjectableWebAnalyticsContent({
|
||||
mode: command === 'dev' ? 'development' : 'production',
|
||||
}),
|
||||
})
|
||||
);
|
||||
}
|
||||
if (command === 'build' && speedInsights?.enabled) {
|
||||
|
@ -93,7 +93,7 @@ export default function vercelStatic({
|
|||
imagesConfig,
|
||||
command,
|
||||
devImageService,
|
||||
config.image,
|
||||
config.image
|
||||
),
|
||||
});
|
||||
},
|
||||
|
@ -127,7 +127,9 @@ export default function vercelStatic({
|
|||
...(routes.find((route) => route.pathname === '/404')
|
||||
? [
|
||||
{
|
||||
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
|
||||
src: `/.*`,
|
||||
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
|
||||
dest: `/404.html`,
|
||||
status: 404,
|
||||
},
|
||||
|
|
|
@ -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,15 @@ 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 () => {
|
||||
// biome-ignore lint/style/useConst: <explanation>
|
||||
let 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 +51,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 +67,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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -77,7 +77,7 @@ describe('Redirects', () => {
|
|||
const config = await getConfig();
|
||||
assert.equal(
|
||||
config.routes.find((r) => r.src === '/'),
|
||||
undefined,
|
||||
undefined
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -16,6 +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;
|
||||
// biome-ignore lint/style/useConst: <explanation>
|
||||
for (let route of config.routes) {
|
||||
if (route.src?.includes('_server-islands')) {
|
||||
found = route;
|
||||
|
|
|
@ -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'
|
||||
)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"include": [
|
||||
"src"
|
||||
],
|
||||
"include": ["src"],
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue