Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes warnings / flags for integrations and ssr #3992

Merged
merged 1 commit into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/loud-apes-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': minor
---

Removes warnings for integrations/ssr
18 changes: 0 additions & 18 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ export interface CLIFlags {
host?: string | boolean;
port?: number;
config?: string;
experimentalSsr?: boolean;
experimentalIntegrations?: boolean;
drafts?: boolean;
}

Expand Down Expand Up @@ -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. */
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions packages/astro/src/core/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 };
Expand Down
38 changes: 0 additions & 38 deletions packages/astro/src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -90,7 +86,6 @@ export const LEGACY_ASTRO_CONFIG_KEYS = new Set([
'markdownOptions',
'buildOptions',
'devOptions',
'experimentalIntegrations',
]);

export const AstroConfigSchema = z.object({
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}
Expand All @@ -383,25 +355,15 @@ 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,
};
}

/** 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.
Expand Down
3 changes: 1 addition & 2 deletions packages/astro/src/core/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
Expand Down
14 changes: 0 additions & 14 deletions packages/astro/src/core/logger/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`
);
}
}
15 changes: 1 addition & 14 deletions packages/astro/src/core/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
14 changes: 0 additions & 14 deletions packages/astro/test/config-validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,11 @@ 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, '', ``] },
process.cwd()
).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);
});
});