Add errors for unknown experimental keys (#7011)
This commit is contained in:
parent
6b4fcde376
commit
cada10a466
6 changed files with 16 additions and 12 deletions
5
.changeset/red-eggs-speak.md
Normal file
5
.changeset/red-eggs-speak.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Throw an error when unknown experimental keys are present
|
|
@ -210,6 +210,17 @@ export const AstroConfigSchema = z.object({
|
||||||
middleware: z.oboolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.middleware),
|
middleware: z.oboolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.middleware),
|
||||||
hybridOutput: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.hybridOutput),
|
hybridOutput: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.hybridOutput),
|
||||||
})
|
})
|
||||||
|
.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()
|
.optional()
|
||||||
.default({}),
|
.default({}),
|
||||||
legacy: z.object({}).optional().default({}),
|
legacy: z.object({}).optional().default({}),
|
||||||
|
|
|
@ -8,9 +8,6 @@ describe('Custom Elements', () => {
|
||||||
before(async () => {
|
before(async () => {
|
||||||
fixture = await loadFixture({
|
fixture = await loadFixture({
|
||||||
root: './fixtures/custom-elements/',
|
root: './fixtures/custom-elements/',
|
||||||
experimental: {
|
|
||||||
integrations: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,4 @@ import ceIntegration from '@test/custom-element-renderer';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
integrations: [ceIntegration()],
|
integrations: [ceIntegration()],
|
||||||
experimental: {
|
|
||||||
integrations: true
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,9 +11,6 @@ describe('SSR: prerender 404', () => {
|
||||||
root: './fixtures/ssr-prerender-404/',
|
root: './fixtures/ssr-prerender-404/',
|
||||||
output: 'server',
|
output: 'server',
|
||||||
adapter: testAdapter(),
|
adapter: testAdapter(),
|
||||||
experimental: {
|
|
||||||
prerender: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,9 +12,6 @@ describe('SSR: prerender', () => {
|
||||||
root: './fixtures/ssr-prerender/',
|
root: './fixtures/ssr-prerender/',
|
||||||
output: 'server',
|
output: 'server',
|
||||||
adapter: testAdapter(),
|
adapter: testAdapter(),
|
||||||
experimental: {
|
|
||||||
prerender: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue