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;
|
host?: string | boolean;
|
||||||
port?: number;
|
port?: number;
|
||||||
config?: string;
|
config?: string;
|
||||||
experimentalSsr?: boolean;
|
|
||||||
experimentalIntegrations?: boolean;
|
|
||||||
drafts?: boolean;
|
drafts?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,20 +682,6 @@ export interface AstroUserConfig {
|
||||||
*/
|
*/
|
||||||
vite?: ViteUserConfig;
|
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
|
// Legacy options to be removed
|
||||||
|
|
||||||
/** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */
|
/** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */
|
||||||
|
@ -720,8 +704,6 @@ export interface AstroUserConfig {
|
||||||
buildOptions?: never;
|
buildOptions?: never;
|
||||||
/** @deprecated `devOptions` has been renamed to `server` */
|
/** @deprecated `devOptions` has been renamed to `server` */
|
||||||
devOptions?: never;
|
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
|
// NOTE(fks): We choose to keep our hand-generated AstroUserConfig interface so that
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
} from '../../integrations/index.js';
|
} from '../../integrations/index.js';
|
||||||
import { createVite, ViteConfigWithSSR } from '../create-vite.js';
|
import { createVite, ViteConfigWithSSR } from '../create-vite.js';
|
||||||
import { fixViteErrorMessage } from '../errors.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 { apply as applyPolyfill } from '../polyfill.js';
|
||||||
import { RouteCache } from '../render/route-cache.js';
|
import { RouteCache } from '../render/route-cache.js';
|
||||||
import { createRouteManifest } from '../routing/index.js';
|
import { createRouteManifest } from '../routing/index.js';
|
||||||
|
@ -80,7 +80,6 @@ class AstroBuilder {
|
||||||
{ astroConfig: this.config, logging, mode: 'build' }
|
{ astroConfig: this.config, logging, mode: 'build' }
|
||||||
);
|
);
|
||||||
await runHookConfigDone({ config: this.config });
|
await runHookConfigDone({ config: this.config });
|
||||||
warnIfUsingExperimentalSSR(logging, this.config);
|
|
||||||
const viteServer = await vite.createServer(viteConfig);
|
const viteServer = await vite.createServer(viteConfig);
|
||||||
debug('build', timerMessage('Vite started', this.timer.viteStart));
|
debug('build', timerMessage('Vite started', this.timer.viteStart));
|
||||||
return { viteConfig, viteServer };
|
return { viteConfig, viteServer };
|
||||||
|
|
|
@ -50,10 +50,6 @@ const ASTRO_CONFIG_DEFAULTS: AstroUserConfig & any = {
|
||||||
rehypePlugins: [],
|
rehypePlugins: [],
|
||||||
},
|
},
|
||||||
vite: {},
|
vite: {},
|
||||||
experimental: {
|
|
||||||
ssr: false,
|
|
||||||
integrations: false,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
async function resolvePostcssConfig(inlineOptions: any, root: URL): Promise<PostCSSConfigResult> {
|
async function resolvePostcssConfig(inlineOptions: any, root: URL): Promise<PostCSSConfigResult> {
|
||||||
|
@ -90,7 +86,6 @@ export const LEGACY_ASTRO_CONFIG_KEYS = new Set([
|
||||||
'markdownOptions',
|
'markdownOptions',
|
||||||
'buildOptions',
|
'buildOptions',
|
||||||
'devOptions',
|
'devOptions',
|
||||||
'experimentalIntegrations',
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const AstroConfigSchema = z.object({
|
export const AstroConfigSchema = z.object({
|
||||||
|
@ -221,13 +216,6 @@ export const AstroConfigSchema = z.object({
|
||||||
vite: z
|
vite: z
|
||||||
.custom<ViteUserConfig>((data) => data instanceof Object && !Array.isArray(data))
|
.custom<ViteUserConfig>((data) => data instanceof Object && !Array.isArray(data))
|
||||||
.default(ASTRO_CONFIG_DEFAULTS.vite),
|
.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 */
|
/** Turn raw config values into normalized values */
|
||||||
|
@ -354,22 +342,6 @@ export async function validateConfig(
|
||||||
(result._ctx.renderers as any[]).unshift(jsxRenderer);
|
(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.
|
// If successful, return the result as a verified AstroConfig object.
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -383,11 +355,6 @@ function resolveFlags(flags: Partial<Flags>): CLIFlags {
|
||||||
config: typeof flags.config === 'string' ? flags.config : undefined,
|
config: typeof flags.config === 'string' ? flags.config : undefined,
|
||||||
host:
|
host:
|
||||||
typeof flags.host === 'string' || typeof flags.host === 'boolean' ? flags.host : undefined,
|
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,
|
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) */
|
/** Merge CLI flags & user config object (CLI flags take priority) */
|
||||||
function mergeCLIFlags(astroConfig: AstroUserConfig, flags: CLIFlags, cmd: string) {
|
function mergeCLIFlags(astroConfig: AstroUserConfig, flags: CLIFlags, cmd: string) {
|
||||||
astroConfig.server = astroConfig.server || {};
|
astroConfig.server = astroConfig.server || {};
|
||||||
astroConfig.experimental = astroConfig.experimental || {};
|
|
||||||
astroConfig.markdown = astroConfig.markdown || {};
|
astroConfig.markdown = astroConfig.markdown || {};
|
||||||
if (typeof flags.site === 'string') astroConfig.site = flags.site;
|
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.drafts === 'boolean') astroConfig.markdown.drafts = flags.drafts;
|
||||||
if (typeof flags.port === 'number') {
|
if (typeof flags.port === 'number') {
|
||||||
// @ts-expect-error astroConfig.server may be a function, but TS doesn't like attaching properties to a function.
|
// @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,
|
runHookServerStart,
|
||||||
} from '../../integrations/index.js';
|
} from '../../integrations/index.js';
|
||||||
import { createVite } from '../create-vite.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 * as msg from '../messages.js';
|
||||||
import { apply as applyPolyfill } from '../polyfill.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' }
|
{ astroConfig: config, logging: options.logging, mode: 'dev' }
|
||||||
);
|
);
|
||||||
await runHookConfigDone({ config });
|
await runHookConfigDone({ config });
|
||||||
warnIfUsingExperimentalSSR(options.logging, config);
|
|
||||||
const viteServer = await vite.createServer(viteConfig);
|
const viteServer = await vite.createServer(viteConfig);
|
||||||
runHookServerSetup({ config, server: viteServer });
|
runHookServerSetup({ config, server: viteServer });
|
||||||
await viteServer.listen(port);
|
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`;
|
timeDiff < 750 ? `${Math.round(timeDiff)}ms` : `${(timeDiff / 1000).toFixed(1)}s`;
|
||||||
return `${message} ${dim(timeDisplay)}`;
|
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 (!adapter) return false;
|
||||||
|
|
||||||
if (typeof adapter.serverEntrypoint === 'string') {
|
if (typeof adapter.serverEntrypoint === 'string') {
|
||||||
if (!adapter.name.startsWith('@astrojs/') && !config.experimental.ssr) {
|
return true;
|
||||||
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;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,14 +61,6 @@ describe('Config Validation', () => {
|
||||||
{ name: '@astrojs/c', hooks: {} },
|
{ 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 () => {
|
it('ignores null or falsy "integration" values', async () => {
|
||||||
const configError = await validateConfig(
|
const configError = await validateConfig(
|
||||||
{ integrations: [null, undefined, false, '', ``] },
|
{ integrations: [null, undefined, false, '', ``] },
|
||||||
|
@ -76,10 +68,4 @@ describe('Config Validation', () => {
|
||||||
).catch((err) => err);
|
).catch((err) => err);
|
||||||
expect(configError).to.be.not.instanceOf(Error);
|
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