diff --git a/.changeset/red-eggs-speak.md b/.changeset/red-eggs-speak.md new file mode 100644 index 000000000000..ce129883dc72 --- /dev/null +++ b/.changeset/red-eggs-speak.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Throw an error when unknown experimental keys are present diff --git a/packages/astro/src/core/config/schema.ts b/packages/astro/src/core/config/schema.ts index fd8d88c4df58..4317ae1edf08 100644 --- a/packages/astro/src/core/config/schema.ts +++ b/packages/astro/src/core/config/schema.ts @@ -201,6 +201,17 @@ export const AstroConfigSchema = z.object({ .default(ASTRO_CONFIG_DEFAULTS.experimental.inlineStylesheets), middleware: z.oboolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.middleware), }) + .passthrough() + .refine(d => { + const validKeys = Object.keys(ASTRO_CONFIG_DEFAULTS.experimental) + const invalidKeys = Object.keys(d).filter(key => !validKeys.includes(key)) + if (invalidKeys.length > 0) return false + return true + }, d => { + const validKeys = Object.keys(ASTRO_CONFIG_DEFAULTS.experimental) + const invalidKeys = Object.keys(d).filter(key => !validKeys.includes(key)) + return { message: `Invalid experimental key: \`${invalidKeys.join(', ')}\`. \nMake sure the spelling is correct, and that your Astro version supports this experiment.\nSee https://docs.astro.build/en/reference/configuration-reference/#experimental-flags for more information.` }; + }) .optional() .default({}), legacy: z.object({}).optional().default({}), diff --git a/packages/astro/test/custom-elements.test.js b/packages/astro/test/custom-elements.test.js index 51e8ece341fa..53a13b478792 100644 --- a/packages/astro/test/custom-elements.test.js +++ b/packages/astro/test/custom-elements.test.js @@ -8,9 +8,6 @@ describe('Custom Elements', () => { before(async () => { fixture = await loadFixture({ root: './fixtures/custom-elements/', - experimental: { - integrations: true, - }, }); await fixture.build(); }); diff --git a/packages/astro/test/fixtures/custom-elements/astro.config.mjs b/packages/astro/test/fixtures/custom-elements/astro.config.mjs index 4c426a9e7190..439334f8fa17 100644 --- a/packages/astro/test/fixtures/custom-elements/astro.config.mjs +++ b/packages/astro/test/fixtures/custom-elements/astro.config.mjs @@ -3,7 +3,4 @@ import ceIntegration from '@test/custom-element-renderer'; export default defineConfig({ integrations: [ceIntegration()], - experimental: { - integrations: true - } }) diff --git a/packages/astro/test/ssr-prerender-404.test.js b/packages/astro/test/ssr-prerender-404.test.js index 8ebcb01c8355..8a5d045967a2 100644 --- a/packages/astro/test/ssr-prerender-404.test.js +++ b/packages/astro/test/ssr-prerender-404.test.js @@ -11,9 +11,6 @@ describe('SSR: prerender 404', () => { root: './fixtures/ssr-prerender-404/', output: 'server', adapter: testAdapter(), - experimental: { - prerender: true, - }, }); await fixture.build(); }); diff --git a/packages/astro/test/ssr-prerender.test.js b/packages/astro/test/ssr-prerender.test.js index 8139c293dc66..b32f45dc6501 100644 --- a/packages/astro/test/ssr-prerender.test.js +++ b/packages/astro/test/ssr-prerender.test.js @@ -12,9 +12,6 @@ describe('SSR: prerender', () => { root: './fixtures/ssr-prerender/', output: 'server', adapter: testAdapter(), - experimental: { - prerender: true, - }, }); await fixture.build(); });