From 4f289cfded372695b904d40dc10db4bdfa2437cb Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Wed, 31 May 2023 09:49:44 -0500 Subject: [PATCH] feat(hybrid): unflag hybrid output --- .changeset/weak-wombats-swim.md | 10 +++++ packages/astro/src/@types/astro.ts | 38 ------------------- packages/astro/src/assets/generate.ts | 4 +- packages/astro/src/core/build/generate.ts | 8 ++-- .../src/core/build/plugins/plugin-ssr.ts | 5 +-- packages/astro/src/core/build/static-build.ts | 13 +++---- packages/astro/src/core/config/config.ts | 7 ---- packages/astro/src/core/config/schema.ts | 2 - packages/astro/src/core/config/settings.ts | 4 +- packages/astro/src/core/endpoint/index.ts | 4 +- .../astro/src/core/render/dev/environment.ts | 4 +- .../astro/src/core/routing/manifest/create.ts | 8 ++-- packages/astro/src/core/util.ts | 4 +- packages/astro/src/integrations/index.ts | 6 +-- packages/astro/src/prerender/utils.ts | 10 ++--- .../src/vite-plugin-astro-server/request.ts | 4 +- .../src/vite-plugin-astro-server/route.ts | 8 ++-- .../astro/src/vite-plugin-scanner/index.ts | 8 ++-- .../ssr-prerender-get-static-paths.test.js | 3 -- .../test/units/routing/route-matching.test.js | 3 -- .../cloudflare/test/prerender.test.js | 3 -- packages/integrations/image/src/index.ts | 4 +- .../integrations/image/src/utils/prerender.ts | 4 +- .../fixtures/prerender/astro.config.mjs | 7 ---- .../netlify/test/functions/prerender.test.js | 3 -- .../integrations/node/test/prerender.test.js | 6 --- .../integrations/vercel/src/lib/prerender.ts | 4 +- .../integrations/vercel/src/static/adapter.ts | 4 +- .../vercel/test/serverless-prerender.test.js | 3 -- 29 files changed, 61 insertions(+), 130 deletions(-) create mode 100644 .changeset/weak-wombats-swim.md diff --git a/.changeset/weak-wombats-swim.md b/.changeset/weak-wombats-swim.md new file mode 100644 index 000000000000..b26399ac8728 --- /dev/null +++ b/.changeset/weak-wombats-swim.md @@ -0,0 +1,10 @@ +--- +'astro': minor +'@astrojs/image': minor +'@astrojs/cloudflare': patch +'@astrojs/netlify': patch +'@astrojs/node': patch +'@astrojs/vercel': patch +--- + +Unflags support for `output: 'hybrid'` mode, which enables pre-rendering by default. The additional `experimental.hybridOutput` flag can be safely removed from your configuration. diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index c3372ec25db5..1766968c0955 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1141,44 +1141,6 @@ export interface AstroUserConfig { * ``` */ middleware?: boolean; - - /** - * @docs - * @name experimental.hybridOutput - * @type {boolean} - * @default `false` - * @version 2.5.0 - * @description - * Enable experimental support for hybrid SSR with pre-rendering enabled by default. - * - * To enable this feature, first set `experimental.hybridOutput` to `true` in your Astro config, and set `output` to `hybrid`. - * - * ```js - * { - * output: 'hybrid', - * experimental: { - * hybridOutput: true, - * }, - * } - * ``` - * Then add `export const prerender = false` to any page or endpoint you want to opt-out of pre-rendering. - * ```astro - * --- - * // pages/contact.astro - * export const prerender = false - * - * if (Astro.request.method === 'POST') { - * // handle form submission - * } - * --- - *
- * - * - * - *
- * ``` - */ - hybridOutput?: boolean; }; // Legacy options to be removed diff --git a/packages/astro/src/assets/generate.ts b/packages/astro/src/assets/generate.ts index a7a9ddd2d395..d6cb02e560f3 100644 --- a/packages/astro/src/assets/generate.ts +++ b/packages/astro/src/assets/generate.ts @@ -3,7 +3,7 @@ import { basename, join } from 'node:path/posix'; import type { StaticBuildOptions } from '../core/build/types.js'; import { warn } from '../core/logger/core.js'; import { prependForwardSlash } from '../core/path.js'; -import { isHybridOutput } from '../prerender/utils.js'; +import { isServerLikeOutput } from '../prerender/utils.js'; import { getConfiguredImageService, isESMImportedImage } from './internal.js'; import type { LocalImageService } from './services/service.js'; import type { ImageTransform } from './types.js'; @@ -47,7 +47,7 @@ export async function generateImage( } let serverRoot: URL, clientRoot: URL; - if (buildOpts.settings.config.output === 'server' || isHybridOutput(buildOpts.settings.config)) { + if (isServerLikeOutput(buildOpts.settings.config)) { serverRoot = buildOpts.settings.config.build.server; clientRoot = buildOpts.settings.config.build.client; } else { diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index a12313987bcf..056b91263aba 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -31,7 +31,7 @@ import { removeTrailingForwardSlash, } from '../../core/path.js'; import { runHookBuildGenerated } from '../../integrations/index.js'; -import { isHybridOutput } from '../../prerender/utils.js'; +import { isServerLikeOutput } from '../../prerender/utils.js'; import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js'; import { callEndpoint, createAPIContext, throwIfRedirectNotAllowed } from '../endpoint/index.js'; import { AstroError } from '../errors/index.js'; @@ -94,7 +94,7 @@ export function chunkIsPage( export async function generatePages(opts: StaticBuildOptions, internals: BuildInternals) { const timer = performance.now(); - const ssr = opts.settings.config.output === 'server' || isHybridOutput(opts.settings.config); // hybrid mode is essentially SSR with prerender by default + const ssr = isServerLikeOutput(opts.settings.config); const serverEntry = opts.buildConfig.serverEntry; const outFolder = ssr ? opts.buildConfig.server : getOutDirWithinCwd(opts.settings.config.outDir); @@ -237,7 +237,7 @@ async function getPathsForRoute( route: pageData.route, isValidate: false, logging: opts.logging, - ssr: opts.settings.config.output === 'server' || isHybridOutput(opts.settings.config), + ssr: isServerLikeOutput(opts.settings.config), }) .then((_result) => { const label = _result.staticPaths.length === 1 ? 'page' : 'pages'; @@ -413,7 +413,7 @@ async function generatePath( } } - const ssr = settings.config.output === 'server' || isHybridOutput(settings.config); + const ssr = isServerLikeOutput(settings.config); const url = getUrlForPath( pathname, opts.settings.config.base, diff --git a/packages/astro/src/core/build/plugins/plugin-ssr.ts b/packages/astro/src/core/build/plugins/plugin-ssr.ts index accdd01ad6a9..062fab77b0cf 100644 --- a/packages/astro/src/core/build/plugins/plugin-ssr.ts +++ b/packages/astro/src/core/build/plugins/plugin-ssr.ts @@ -3,7 +3,7 @@ import { fileURLToPath } from 'url'; import type { Plugin as VitePlugin } from 'vite'; import type { AstroAdapter } from '../../../@types/astro'; import { runHookBuildSsr } from '../../../integrations/index.js'; -import { isHybridOutput } from '../../../prerender/utils.js'; +import { isServerLikeOutput } from '../../../prerender/utils.js'; import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from '../../../vite-plugin-scripts/index.js'; import type { SerializedRouteInfo, SerializedSSRManifest } from '../../app/types'; import { joinPaths, prependForwardSlash } from '../../path.js'; @@ -272,8 +272,7 @@ export function pluginSSR( options: StaticBuildOptions, internals: BuildInternals ): AstroBuildPlugin { - const ssr = - options.settings.config.output === 'server' || isHybridOutput(options.settings.config); + const ssr = isServerLikeOutput(options.settings.config); return { build: 'ssr', hooks: { diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index cceaa036136d..4ada4f9a8a1f 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -15,7 +15,7 @@ import { emptyDir, removeEmptyDirs } from '../../core/fs/index.js'; import { appendForwardSlash, prependForwardSlash } from '../../core/path.js'; import { isModeServerWithNoAdapter } from '../../core/util.js'; import { runHookBuildSetup } from '../../integrations/index.js'; -import { isHybridOutput } from '../../prerender/utils.js'; +import { isServerLikeOutput } from '../../prerender/utils.js'; import { PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js'; import { AstroError, AstroErrorData } from '../errors/index.js'; import { info } from '../logger/core.js'; @@ -117,7 +117,6 @@ export async function viteBuild(opts: StaticBuildOptions) { export async function staticBuild(opts: StaticBuildOptions, internals: BuildInternals) { const { settings } = opts; - const hybridOutput = isHybridOutput(settings.config); switch (true) { case settings.config.output === 'static': { settings.timer.start('Static generate'); @@ -126,7 +125,7 @@ export async function staticBuild(opts: StaticBuildOptions, internals: BuildInte settings.timer.end('Static generate'); return; } - case settings.config.output === 'server' || hybridOutput: { + case isServerLikeOutput(settings.config): { settings.timer.start('Server generate'); await generatePages(opts, internals); await cleanStaticOutput(opts, internals); @@ -145,7 +144,7 @@ async function ssrBuild( container: AstroBuildPluginContainer ) { const { settings, viteConfig } = opts; - const ssr = settings.config.output === 'server' || isHybridOutput(settings.config); + const ssr = isServerLikeOutput(settings.config); const out = ssr ? opts.buildConfig.server : getOutDirWithinCwd(settings.config.outDir); const { lastVitePlugins, vitePlugins } = container.runBeforeHook('ssr', input); @@ -225,7 +224,7 @@ async function clientBuild( ) { const { settings, viteConfig } = opts; const timer = performance.now(); - const ssr = settings.config.output === 'server' || isHybridOutput(settings.config); + const ssr = isServerLikeOutput(settings.config); const out = ssr ? opts.buildConfig.client : getOutDirWithinCwd(settings.config.outDir); // Nothing to do if there is no client-side JS. @@ -291,7 +290,7 @@ async function runPostBuildHooks( const buildConfig = container.options.settings.config.build; for (const [fileName, mutation] of mutations) { const root = - config.output === 'server' || isHybridOutput(config) + isServerLikeOutput(config) ? mutation.build === 'server' ? buildConfig.server : buildConfig.client @@ -312,7 +311,7 @@ async function cleanStaticOutput(opts: StaticBuildOptions, internals: BuildInter if (pageData.route.prerender) allStaticFiles.add(internals.pageToBundleMap.get(pageData.moduleSpecifier)); } - const ssr = opts.settings.config.output === 'server' || isHybridOutput(opts.settings.config); + const ssr = isServerLikeOutput(opts.settings.config); const out = ssr ? opts.buildConfig.server : getOutDirWithinCwd(opts.settings.config.outDir); // The SSR output is all .mjs files, the client output is not. const files = await glob('**/*.mjs', { diff --git a/packages/astro/src/core/config/config.ts b/packages/astro/src/core/config/config.ts index 0ca13a220936..9915ed162b31 100644 --- a/packages/astro/src/core/config/config.ts +++ b/packages/astro/src/core/config/config.ts @@ -6,7 +6,6 @@ import * as colors from 'kleur/colors'; import path from 'path'; import { fileURLToPath, pathToFileURL } from 'url'; import { mergeConfig as mergeViteConfig } from 'vite'; -import { isHybridMalconfigured } from '../../prerender/utils.js'; import { AstroError, AstroErrorData } from '../errors/index.js'; import type { LogOptions } from '../logger/core.js'; import { arraify, isObject, isURL } from '../util.js'; @@ -224,12 +223,6 @@ export async function openConfig(configOptions: LoadConfigOptions): Promise = new Set(['.js', '.ts']); const localFs = fsMod ?? nodeFs; - const isPrerenderDefault = isHybridOutput(settings.config); + const prerender = getPrerenderDefault(settings.config); const foundInvalidFileExtensions: Set = new Set(); @@ -341,7 +341,7 @@ export function createRouteManifest( component, generate, pathname: pathname || undefined, - prerender: isPrerenderDefault, + prerender, }); } }); @@ -417,7 +417,7 @@ export function createRouteManifest( component, generate, pathname: pathname || void 0, - prerender: isPrerenderDefault, + prerender, }); }); diff --git a/packages/astro/src/core/util.ts b/packages/astro/src/core/util.ts index c12bd03add34..67f5590d3a31 100644 --- a/packages/astro/src/core/util.ts +++ b/packages/astro/src/core/util.ts @@ -4,7 +4,7 @@ import slash from 'slash'; import { fileURLToPath } from 'url'; import { normalizePath } from 'vite'; import type { AstroConfig, AstroSettings, RouteType } from '../@types/astro'; -import { isHybridOutput } from '../prerender/utils.js'; +import { isServerLikeOutput } from '../prerender/utils.js'; import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './constants.js'; import type { ModuleLoader } from './module-loader'; import { prependForwardSlash, removeTrailingForwardSlash } from './path.js'; @@ -140,7 +140,7 @@ export function isEndpoint(file: URL, settings: AstroSettings): boolean { export function isModeServerWithNoAdapter(settings: AstroSettings): boolean { return ( - (settings.config.output === 'server' || isHybridOutput(settings.config)) && !settings.adapter + isServerLikeOutput(settings.config) && !settings.adapter ); } diff --git a/packages/astro/src/integrations/index.ts b/packages/astro/src/integrations/index.ts index 5d88a1196bf3..6beb8e7b8398 100644 --- a/packages/astro/src/integrations/index.ts +++ b/packages/astro/src/integrations/index.ts @@ -18,7 +18,7 @@ import type { PageBuildData } from '../core/build/types'; import { buildClientDirectiveEntrypoint } from '../core/client-directive/index.js'; import { mergeConfig } from '../core/config/config.js'; import { info, type LogOptions } from '../core/logger/core.js'; -import { isHybridOutput } from '../prerender/utils.js'; +import { isServerLikeOutput } from '../prerender/utils.js'; import { mdxContentEntryType } from '../vite-plugin-markdown/content-entry-type.js'; async function withTakingALongTimeMsg({ @@ -340,7 +340,7 @@ export async function runHookBuildGenerated({ logging: LogOptions; }) { const dir = - config.output === 'server' || isHybridOutput(config) ? buildConfig.client : config.outDir; + isServerLikeOutput(config) ? buildConfig.client : config.outDir; for (const integration of config.integrations) { if (integration?.hooks?.['astro:build:generated']) { @@ -367,7 +367,7 @@ export async function runHookBuildDone({ logging: LogOptions; }) { const dir = - config.output === 'server' || isHybridOutput(config) ? buildConfig.client : config.outDir; + isServerLikeOutput(config) ? buildConfig.client : config.outDir; await fs.promises.mkdir(dir, { recursive: true }); for (const integration of config.integrations) { diff --git a/packages/astro/src/prerender/utils.ts b/packages/astro/src/prerender/utils.ts index 40066035cf66..bd6e367ad56d 100644 --- a/packages/astro/src/prerender/utils.ts +++ b/packages/astro/src/prerender/utils.ts @@ -1,11 +1,9 @@ -// TODO: remove after the experimetal phase when - import type { AstroConfig } from '../@types/astro'; -export function isHybridMalconfigured(config: AstroConfig) { - return config.experimental.hybridOutput ? config.output !== 'hybrid' : config.output === 'hybrid'; +export function isServerLikeOutput(config: AstroConfig) { + return config.output === 'server' || config.output === 'hybrid'; } -export function isHybridOutput(config: AstroConfig) { - return config.experimental.hybridOutput && config.output === 'hybrid'; +export function getPrerenderDefault(config: AstroConfig) { + return config.output === 'hybrid'; } diff --git a/packages/astro/src/vite-plugin-astro-server/request.ts b/packages/astro/src/vite-plugin-astro-server/request.ts index 865c5b401319..adf4199d1638 100644 --- a/packages/astro/src/vite-plugin-astro-server/request.ts +++ b/packages/astro/src/vite-plugin-astro-server/request.ts @@ -9,7 +9,7 @@ import { error } from '../core/logger/core.js'; import * as msg from '../core/messages.js'; import { removeTrailingForwardSlash } from '../core/path.js'; import { eventError, telemetry } from '../events/index.js'; -import { isHybridOutput } from '../prerender/utils.js'; +import { isServerLikeOutput } from '../prerender/utils.js'; import { runWithErrorHandling } from './controller.js'; import { handle500Response } from './response.js'; import { handleRoute, matchRoute } from './route.js'; @@ -25,7 +25,7 @@ export async function handleRequest( const { settings, loader: moduleLoader } = env; const { config } = settings; const origin = `${moduleLoader.isHttps() ? 'https' : 'http'}://${req.headers.host}`; - const buildingToSSR = config.output === 'server' || isHybridOutput(config); + const buildingToSSR = isServerLikeOutput(config); const url = new URL(origin + req.url); let pathname: string; diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts index dae4162296f6..1e6d1b87d1ca 100644 --- a/packages/astro/src/vite-plugin-astro-server/route.ts +++ b/packages/astro/src/vite-plugin-astro-server/route.ts @@ -17,7 +17,7 @@ import { getParamsAndProps, GetParamsAndPropsError } from '../core/render/index. import { createRequest } from '../core/request.js'; import { matchAllRoutes } from '../core/routing/index.js'; import { getSortedPreloadedMatches } from '../prerender/routing.js'; -import { isHybridOutput } from '../prerender/utils.js'; +import { isServerLikeOutput } from '../prerender/utils.js'; import { log404 } from './common.js'; import { handle404Response, writeSSRResult, writeWebResponse } from './response.js'; @@ -59,7 +59,7 @@ export async function matchRoute( routeCache, pathname: pathname, logging, - ssr: settings.config.output === 'server' || isHybridOutput(settings.config), + ssr: isServerLikeOutput(settings.config), }); if (paramsAndPropsRes !== GetParamsAndPropsError.NoMatchingStaticPath) { @@ -132,7 +132,7 @@ export async function handleRoute( const { config } = settings; const filePath: URL | undefined = matchedRoute.filePath; const { route, preloadedComponent, mod } = matchedRoute; - const buildingToSSR = config.output === 'server' || isHybridOutput(config); + const buildingToSSR = isServerLikeOutput(config); // Headers are only available when using SSR. const request = createRequest({ @@ -158,7 +158,7 @@ export async function handleRoute( routeCache: env.routeCache, pathname: pathname, logging, - ssr: config.output === 'server' || isHybridOutput(config), + ssr: isServerLikeOutput(config), }); const options: SSROptions = { diff --git a/packages/astro/src/vite-plugin-scanner/index.ts b/packages/astro/src/vite-plugin-scanner/index.ts index a349e7fa6af4..465ff74ed6c4 100644 --- a/packages/astro/src/vite-plugin-scanner/index.ts +++ b/packages/astro/src/vite-plugin-scanner/index.ts @@ -2,7 +2,7 @@ import { normalizePath, type Plugin as VitePlugin } from 'vite'; import type { AstroSettings } from '../@types/astro.js'; import { isEndpoint, isPage } from '../core/util.js'; -import { isHybridOutput } from '../prerender/utils.js'; +import { getPrerenderDefault } from '../prerender/utils.js'; import { scan } from './scan.js'; export default function astroScannerPlugin({ settings }: { settings: AstroSettings }): VitePlugin { @@ -25,11 +25,11 @@ export default function astroScannerPlugin({ settings }: { settings: AstroSettin const fileIsPage = isPage(fileURL, settings); const fileIsEndpoint = isEndpoint(fileURL, settings); if (!(fileIsPage || fileIsEndpoint)) return; - const hybridOutput = isHybridOutput(settings.config); - const pageOptions = await scan(code, id, hybridOutput); + const defaultPrerender = getPrerenderDefault(settings.config); + const pageOptions = await scan(code, id, settings.config.output === 'hybrid'); if (typeof pageOptions.prerender === 'undefined') { - pageOptions.prerender = hybridOutput ? true : false; + pageOptions.prerender = defaultPrerender; } const { meta = {} } = this.getModuleInfo(id) ?? {}; diff --git a/packages/astro/test/ssr-prerender-get-static-paths.test.js b/packages/astro/test/ssr-prerender-get-static-paths.test.js index 1a1712304168..6316561d6cad 100644 --- a/packages/astro/test/ssr-prerender-get-static-paths.test.js +++ b/packages/astro/test/ssr-prerender-get-static-paths.test.js @@ -144,9 +144,6 @@ describe('Prerender', () => { adapter: testAdapter(), base: '/blog', output: 'hybrid', - experimental: { - hybridOutput: true, - }, vite: { plugins: [vitePluginRemovePrerenderExport()], }, diff --git a/packages/astro/test/units/routing/route-matching.test.js b/packages/astro/test/units/routing/route-matching.test.js index 692518382836..46536176533f 100644 --- a/packages/astro/test/units/routing/route-matching.test.js +++ b/packages/astro/test/units/routing/route-matching.test.js @@ -133,9 +133,6 @@ describe('Route matching', () => { userConfig: { trailingSlash: 'never', output: 'hybrid', - experimental: { - hybridOutput: true, - }, adapter: testAdapter(), }, disableTelemetry: true, diff --git a/packages/integrations/cloudflare/test/prerender.test.js b/packages/integrations/cloudflare/test/prerender.test.js index 5d3ff9f10a18..526f8a4ac5e0 100644 --- a/packages/integrations/cloudflare/test/prerender.test.js +++ b/packages/integrations/cloudflare/test/prerender.test.js @@ -38,9 +38,6 @@ describe('Hybrid rendering', () => { fixture = await loadFixture({ root: './fixtures/prerender/', output: 'hybrid', - experimental: { - hybridOutput: true, - }, }); await fixture.build(); }); diff --git a/packages/integrations/image/src/index.ts b/packages/integrations/image/src/index.ts index b2bc11447751..fb6496c0c067 100644 --- a/packages/integrations/image/src/index.ts +++ b/packages/integrations/image/src/index.ts @@ -3,7 +3,7 @@ import { ssgBuild } from './build/ssg.js'; import type { ImageService, SSRImageService, TransformOptions } from './loaders/index.js'; import type { LoggerLevel } from './utils/logger.js'; import { joinPaths, prependForwardSlash, propsToFilename } from './utils/paths.js'; -import { isHybridOutput } from './utils/prerender.js'; +import { isServerLikeOutput } from './utils/prerender.js'; import { createPlugin } from './vite-plugin-astro-image.js'; export { getImage } from './lib/get-image.js'; @@ -85,7 +85,7 @@ export default function integration(options: IntegrationOptions = {}): AstroInte vite: getViteConfiguration(command === 'dev'), }); - if (command === 'dev' || config.output === 'server' || isHybridOutput(config)) { + if (command === 'dev' || isServerLikeOutput(config)) { injectRoute({ pattern: ROUTE_PATTERN, entryPoint: '@astrojs/image/endpoint', diff --git a/packages/integrations/image/src/utils/prerender.ts b/packages/integrations/image/src/utils/prerender.ts index 9265c80bf0fc..f69f3b5d470c 100644 --- a/packages/integrations/image/src/utils/prerender.ts +++ b/packages/integrations/image/src/utils/prerender.ts @@ -1,5 +1,5 @@ import type { AstroConfig } from 'astro'; -export function isHybridOutput(config: AstroConfig) { - return config.experimental.hybridOutput && config.output === 'hybrid'; +export function isServerLikeOutput(config: AstroConfig) { + return config.output === 'server' || config.output === 'hybrid'; } diff --git a/packages/integrations/netlify/test/edge-functions/fixtures/prerender/astro.config.mjs b/packages/integrations/netlify/test/edge-functions/fixtures/prerender/astro.config.mjs index c579d74eff31..d049599e595e 100644 --- a/packages/integrations/netlify/test/edge-functions/fixtures/prerender/astro.config.mjs +++ b/packages/integrations/netlify/test/edge-functions/fixtures/prerender/astro.config.mjs @@ -6,13 +6,6 @@ const isHybridMode = process.env.PRERENDER === "false"; /** @type {import('astro').AstroConfig} */ const partialConfig = { output: isHybridMode ? "hybrid" : "server", - ...(isHybridMode - ? ({ - experimental: { - hybridOutput: true, - }, - }) - : ({})), }; export default defineConfig({ diff --git a/packages/integrations/netlify/test/functions/prerender.test.js b/packages/integrations/netlify/test/functions/prerender.test.js index 9718df083c95..a571dd76e432 100644 --- a/packages/integrations/netlify/test/functions/prerender.test.js +++ b/packages/integrations/netlify/test/functions/prerender.test.js @@ -46,9 +46,6 @@ describe('Mixed Hybrid rendering with SSR', () => { fixture = await loadFixture({ root: new URL('./fixtures/prerender/', import.meta.url).toString(), output: 'hybrid', - experimental: { - hybridOutput: true, - }, adapter: netlifyAdapter({ dist: new URL('./fixtures/prerender/dist/', import.meta.url), }), diff --git a/packages/integrations/node/test/prerender.test.js b/packages/integrations/node/test/prerender.test.js index 751ed2ae718f..4b5522a31903 100644 --- a/packages/integrations/node/test/prerender.test.js +++ b/packages/integrations/node/test/prerender.test.js @@ -140,9 +140,6 @@ describe('Hybrid rendering', () => { base: '/some-base', root: './fixtures/prerender/', output: 'hybrid', - experimental: { - hybridOutput: true, - }, adapter: nodejs({ mode: 'standalone' }), }); await fixture.build(); @@ -199,9 +196,6 @@ describe('Hybrid rendering', () => { fixture = await loadFixture({ root: './fixtures/prerender/', output: 'hybrid', - experimental: { - hybridOutput: true, - }, adapter: nodejs({ mode: 'standalone' }), }); await fixture.build(); diff --git a/packages/integrations/vercel/src/lib/prerender.ts b/packages/integrations/vercel/src/lib/prerender.ts index 9265c80bf0fc..f69f3b5d470c 100644 --- a/packages/integrations/vercel/src/lib/prerender.ts +++ b/packages/integrations/vercel/src/lib/prerender.ts @@ -1,5 +1,5 @@ import type { AstroConfig } from 'astro'; -export function isHybridOutput(config: AstroConfig) { - return config.experimental.hybridOutput && config.output === 'hybrid'; +export function isServerLikeOutput(config: AstroConfig) { + return config.output === 'server' || config.output === 'hybrid'; } diff --git a/packages/integrations/vercel/src/static/adapter.ts b/packages/integrations/vercel/src/static/adapter.ts index 0b3579cdd11d..ccbf26e570f4 100644 --- a/packages/integrations/vercel/src/static/adapter.ts +++ b/packages/integrations/vercel/src/static/adapter.ts @@ -8,7 +8,7 @@ import { } from '../image/shared.js'; import { exposeEnv } from '../lib/env.js'; import { emptyDir, getVercelOutput, writeJson } from '../lib/fs.js'; -import { isHybridOutput } from '../lib/prerender.js'; +import { isServerLikeOutput } from '../lib/prerender.js'; import { getRedirects } from '../lib/redirects.js'; const PACKAGE_NAME = '@astrojs/vercel/static'; @@ -55,7 +55,7 @@ export default function vercelStatic({ setAdapter(getAdapter()); _config = config; - if (config.output === 'server' || isHybridOutput(config)) { + if (isServerLikeOutput(config)) { throw new Error(`${PACKAGE_NAME} should be used with output: 'static'`); } }, diff --git a/packages/integrations/vercel/test/serverless-prerender.test.js b/packages/integrations/vercel/test/serverless-prerender.test.js index 94d9081f4198..18b16534047a 100644 --- a/packages/integrations/vercel/test/serverless-prerender.test.js +++ b/packages/integrations/vercel/test/serverless-prerender.test.js @@ -27,9 +27,6 @@ describe('Serverless hybrid rendering', () => { fixture = await loadFixture({ root: './fixtures/serverless-prerender/', output: 'hybrid', - experimental: { - hybridOutput: true, - }, }); });