Removes warnings / flags for integrations and ssr (#3992)
This commit is contained in:
parent
4dd341c8a1
commit
ccae431426
8 changed files with 8 additions and 102 deletions
5
.changeset/loud-apes-flash.md
Normal file
5
.changeset/loud-apes-flash.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': minor
|
||||
---
|
||||
|
||||
Removes warnings for integrations/ssr
|
|
@ -69,8 +69,6 @@ export interface CLIFlags {
|
|||
host?: string | boolean;
|
||||
port?: number;
|
||||
config?: string;
|
||||
experimentalSsr?: boolean;
|
||||
experimentalIntegrations?: boolean;
|
||||
drafts?: boolean;
|
||||
}
|
||||
|
||||
|
@ -684,20 +682,6 @@ export interface AstroUserConfig {
|
|||
*/
|
||||
vite?: ViteUserConfig;
|
||||
|
||||
experimental?: {
|
||||
/**
|
||||
* Enable support for 3rd-party integrations.
|
||||
* Default: false
|
||||
*/
|
||||
integrations?: boolean;
|
||||
|
||||
/**
|
||||
* Enable support for 3rd-party SSR adapters.
|
||||
* Default: false
|
||||
*/
|
||||
ssr?: boolean;
|
||||
};
|
||||
|
||||
// Legacy options to be removed
|
||||
|
||||
/** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */
|
||||
|
@ -720,8 +704,6 @@ export interface AstroUserConfig {
|
|||
buildOptions?: never;
|
||||
/** @deprecated `devOptions` has been renamed to `server` */
|
||||
devOptions?: never;
|
||||
/** @deprecated `experimentalIntegrations` has been renamed to `experimental: { integrations: true }` */
|
||||
experimentalIntegrations?: never;
|
||||
}
|
||||
|
||||
// NOTE(fks): We choose to keep our hand-generated AstroUserConfig interface so that
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
} from '../../integrations/index.js';
|
||||
import { createVite, ViteConfigWithSSR } from '../create-vite.js';
|
||||
import { fixViteErrorMessage } from '../errors.js';
|
||||
import { debug, info, levels, timerMessage, warnIfUsingExperimentalSSR } from '../logger/core.js';
|
||||
import { debug, info, levels, timerMessage } from '../logger/core.js';
|
||||
import { apply as applyPolyfill } from '../polyfill.js';
|
||||
import { RouteCache } from '../render/route-cache.js';
|
||||
import { createRouteManifest } from '../routing/index.js';
|
||||
|
@ -80,7 +80,6 @@ class AstroBuilder {
|
|||
{ astroConfig: this.config, logging, mode: 'build' }
|
||||
);
|
||||
await runHookConfigDone({ config: this.config });
|
||||
warnIfUsingExperimentalSSR(logging, this.config);
|
||||
const viteServer = await vite.createServer(viteConfig);
|
||||
debug('build', timerMessage('Vite started', this.timer.viteStart));
|
||||
return { viteConfig, viteServer };
|
||||
|
|
|
@ -50,10 +50,6 @@ const ASTRO_CONFIG_DEFAULTS: AstroUserConfig & any = {
|
|||
rehypePlugins: [],
|
||||
},
|
||||
vite: {},
|
||||
experimental: {
|
||||
ssr: false,
|
||||
integrations: false,
|
||||
},
|
||||
};
|
||||
|
||||
async function resolvePostcssConfig(inlineOptions: any, root: URL): Promise<PostCSSConfigResult> {
|
||||
|
@ -90,7 +86,6 @@ export const LEGACY_ASTRO_CONFIG_KEYS = new Set([
|
|||
'markdownOptions',
|
||||
'buildOptions',
|
||||
'devOptions',
|
||||
'experimentalIntegrations',
|
||||
]);
|
||||
|
||||
export const AstroConfigSchema = z.object({
|
||||
|
@ -221,13 +216,6 @@ export const AstroConfigSchema = z.object({
|
|||
vite: z
|
||||
.custom<ViteUserConfig>((data) => data instanceof Object && !Array.isArray(data))
|
||||
.default(ASTRO_CONFIG_DEFAULTS.vite),
|
||||
experimental: z
|
||||
.object({
|
||||
ssr: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.ssr),
|
||||
integrations: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.integrations),
|
||||
})
|
||||
.optional()
|
||||
.default({}),
|
||||
});
|
||||
|
||||
/** Turn raw config values into normalized values */
|
||||
|
@ -354,22 +342,6 @@ export async function validateConfig(
|
|||
(result._ctx.renderers as any[]).unshift(jsxRenderer);
|
||||
}
|
||||
|
||||
// Final-Pass Validation (perform checks that require the full config object)
|
||||
if (
|
||||
!result.experimental?.integrations &&
|
||||
!result.integrations.every((int) => int.name.startsWith('@astrojs/'))
|
||||
) {
|
||||
throw new Error(
|
||||
[
|
||||
`Astro integrations are still experimental.`,
|
||||
``,
|
||||
`Only official "@astrojs/*" integrations are currently supported.`,
|
||||
`To enable 3rd-party integrations, use the "--experimental-integrations" flag.`,
|
||||
`Breaking changes may occur in this API before Astro v1.0 is released.`,
|
||||
``,
|
||||
].join('\n')
|
||||
);
|
||||
}
|
||||
// If successful, return the result as a verified AstroConfig object.
|
||||
return result;
|
||||
}
|
||||
|
@ -383,11 +355,6 @@ function resolveFlags(flags: Partial<Flags>): CLIFlags {
|
|||
config: typeof flags.config === 'string' ? flags.config : undefined,
|
||||
host:
|
||||
typeof flags.host === 'string' || typeof flags.host === 'boolean' ? flags.host : undefined,
|
||||
experimentalSsr: typeof flags.experimentalSsr === 'boolean' ? flags.experimentalSsr : undefined,
|
||||
experimentalIntegrations:
|
||||
typeof flags.experimentalIntegrations === 'boolean'
|
||||
? flags.experimentalIntegrations
|
||||
: undefined,
|
||||
drafts: typeof flags.drafts === 'boolean' ? flags.drafts : false,
|
||||
};
|
||||
}
|
||||
|
@ -395,13 +362,8 @@ function resolveFlags(flags: Partial<Flags>): CLIFlags {
|
|||
/** Merge CLI flags & user config object (CLI flags take priority) */
|
||||
function mergeCLIFlags(astroConfig: AstroUserConfig, flags: CLIFlags, cmd: string) {
|
||||
astroConfig.server = astroConfig.server || {};
|
||||
astroConfig.experimental = astroConfig.experimental || {};
|
||||
astroConfig.markdown = astroConfig.markdown || {};
|
||||
if (typeof flags.site === 'string') astroConfig.site = flags.site;
|
||||
if (typeof flags.experimentalSsr === 'boolean')
|
||||
astroConfig.experimental.ssr = flags.experimentalSsr;
|
||||
if (typeof flags.experimentalIntegrations === 'boolean')
|
||||
astroConfig.experimental.integrations = flags.experimentalIntegrations;
|
||||
if (typeof flags.drafts === 'boolean') astroConfig.markdown.drafts = flags.drafts;
|
||||
if (typeof flags.port === 'number') {
|
||||
// @ts-expect-error astroConfig.server may be a function, but TS doesn't like attaching properties to a function.
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
runHookServerStart,
|
||||
} from '../../integrations/index.js';
|
||||
import { createVite } from '../create-vite.js';
|
||||
import { info, LogOptions, warn, warnIfUsingExperimentalSSR } from '../logger/core.js';
|
||||
import { info, LogOptions, warn } from '../logger/core.js';
|
||||
import * as msg from '../messages.js';
|
||||
import { apply as applyPolyfill } from '../polyfill.js';
|
||||
|
||||
|
@ -58,7 +58,6 @@ export default async function dev(config: AstroConfig, options: DevOptions): Pro
|
|||
{ astroConfig: config, logging: options.logging, mode: 'dev' }
|
||||
);
|
||||
await runHookConfigDone({ config });
|
||||
warnIfUsingExperimentalSSR(options.logging, config);
|
||||
const viteServer = await vite.createServer(viteConfig);
|
||||
runHookServerSetup({ config, server: viteServer });
|
||||
await viteServer.listen(port);
|
||||
|
|
|
@ -127,17 +127,3 @@ export function timerMessage(message: string, startTime: number = Date.now()) {
|
|||
timeDiff < 750 ? `${Math.round(timeDiff)}ms` : `${(timeDiff / 1000).toFixed(1)}s`;
|
||||
return `${message} ${dim(timeDisplay)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* A warning that SSR is experimental. Remove when we can.
|
||||
*/
|
||||
export function warnIfUsingExperimentalSSR(opts: LogOptions, config: AstroConfig) {
|
||||
if (config._ctx.adapter?.serverEntrypoint) {
|
||||
warn(
|
||||
opts,
|
||||
'warning',
|
||||
bold(`Warning:`),
|
||||
`SSR support is still experimental and subject to API changes. If using in production, pin your dependencies to prevent accidental breakage.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,20 +187,7 @@ export function isBuildingToSSR(config: AstroConfig): boolean {
|
|||
if (!adapter) return false;
|
||||
|
||||
if (typeof adapter.serverEntrypoint === 'string') {
|
||||
if (!adapter.name.startsWith('@astrojs/') && !config.experimental.ssr) {
|
||||
throw new Error(
|
||||
[
|
||||
`Server-side rendering (SSR) is still experimental.`,
|
||||
``,
|
||||
`Only official "@astrojs/*" adapters are currently supported.`,
|
||||
`To enable SSR for 3rd-party adapters, use the "--experimental-ssr" flag.`,
|
||||
`Breaking changes may occur in this API before Astro v1.0 is released.`,
|
||||
``,
|
||||
].join('\n')
|
||||
);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -61,14 +61,6 @@ describe('Config Validation', () => {
|
|||
{ name: '@astrojs/c', hooks: {} },
|
||||
]);
|
||||
});
|
||||
it('blocks third-party "integration" values', async () => {
|
||||
const configError = await validateConfig(
|
||||
{ integrations: [{ name: '@my-plugin/a' }] },
|
||||
process.cwd()
|
||||
).catch((err) => err);
|
||||
expect(configError).to.be.instanceOf(Error);
|
||||
expect(configError.message).to.include('Astro integrations are still experimental.');
|
||||
});
|
||||
it('ignores null or falsy "integration" values', async () => {
|
||||
const configError = await validateConfig(
|
||||
{ integrations: [null, undefined, false, '', ``] },
|
||||
|
@ -76,10 +68,4 @@ describe('Config Validation', () => {
|
|||
).catch((err) => err);
|
||||
expect(configError).to.be.not.instanceOf(Error);
|
||||
});
|
||||
it('allows third-party "integration" values with the --experimental-integrations flag', async () => {
|
||||
await validateConfig(
|
||||
{ integrations: [{ name: '@my-plugin/a' }], experimental: { integrations: true } },
|
||||
process.cwd()
|
||||
).catch((err) => err);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue