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

Add errors for unknown experimental keys #7011

Merged
merged 6 commits into from
May 18, 2023
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/red-eggs-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Throw an error when unknown experimental keys are present
11 changes: 11 additions & 0 deletions packages/astro/src/core/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.` };
})
TheOtterlord marked this conversation as resolved.
Show resolved Hide resolved
.optional()
.default({}),
legacy: z.object({}).optional().default({}),
Expand Down
3 changes: 0 additions & 3 deletions packages/astro/test/custom-elements.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ describe('Custom Elements', () => {
before(async () => {
fixture = await loadFixture({
root: './fixtures/custom-elements/',
experimental: {
integrations: true,
},
});
await fixture.build();
});
Expand Down
3 changes: 0 additions & 3 deletions packages/astro/test/fixtures/custom-elements/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@ import ceIntegration from '@test/custom-element-renderer';

export default defineConfig({
integrations: [ceIntegration()],
experimental: {
integrations: true
}
})
3 changes: 0 additions & 3 deletions packages/astro/test/ssr-prerender-404.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ describe('SSR: prerender 404', () => {
root: './fixtures/ssr-prerender-404/',
output: 'server',
adapter: testAdapter(),
experimental: {
prerender: true,
},
});
await fixture.build();
});
Expand Down
3 changes: 0 additions & 3 deletions packages/astro/test/ssr-prerender.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ describe('SSR: prerender', () => {
root: './fixtures/ssr-prerender/',
output: 'server',
adapter: testAdapter(),
experimental: {
prerender: true,
},
});
await fixture.build();
});
Expand Down