diff --git a/.changeset/quick-islands-call.md b/.changeset/quick-islands-call.md new file mode 100644 index 000000000..305e5a382 --- /dev/null +++ b/.changeset/quick-islands-call.md @@ -0,0 +1,15 @@ +--- +'astro': patch +--- + +Add an `astro/config` entrypoint with a `defineConfig` utility. + +Config files can now be easily benefit from Intellisense using the following approach: + +```js +import { defineConfig } from 'astro/config'; + +export default defineConfig({ + renderers: [] +}) +``` diff --git a/examples/blog-multiple-authors/astro.config.mjs b/examples/blog-multiple-authors/astro.config.mjs index a1516f292..a024b64b4 100644 --- a/examples/blog-multiple-authors/astro.config.mjs +++ b/examples/blog-multiple-authors/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Enable the Preact renderer to support Preact JSX components. renderers: ['@astrojs/renderer-preact'], }); diff --git a/examples/blog/astro.config.mjs b/examples/blog/astro.config.mjs index b769e1743..f682daa06 100644 --- a/examples/blog/astro.config.mjs +++ b/examples/blog/astro.config.mjs @@ -1,14 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ - // Enable the Preact renderer to support Preact JSX components. +// https://astro.build/config +export default defineConfig({ renderers: ['@astrojs/renderer-preact'], buildOptions: { site: 'https://example.com/', diff --git a/examples/component/demo/astro.config.mjs b/examples/component/demo/astro.config.mjs index d68cea82c..c6e58dbdc 100644 --- a/examples/component/demo/astro.config.mjs +++ b/examples/component/demo/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Comment out "renderers: []" to enable Astro's default component support. renderers: [], }); diff --git a/examples/docs/astro.config.mjs b/examples/docs/astro.config.mjs index 075ab81fe..9f97b3a89 100644 --- a/examples/docs/astro.config.mjs +++ b/examples/docs/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ renderers: [ // Enable the Preact renderer to support Preact JSX components. '@astrojs/renderer-preact', diff --git a/examples/env-vars/astro.config.mjs b/examples/env-vars/astro.config.mjs index 67c95c240..e3579a160 100644 --- a/examples/env-vars/astro.config.mjs +++ b/examples/env-vars/astro.config.mjs @@ -1,8 +1,6 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ - // Comment out "renderers: []" to enable Astro's default component support. +// https://astro.build/config +export default defineConfig({ renderers: [], }); diff --git a/examples/framework-alpine/astro.config.mjs b/examples/framework-alpine/astro.config.mjs index 05fc24b01..9827239bb 100644 --- a/examples/framework-alpine/astro.config.mjs +++ b/examples/framework-alpine/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // No renderers are needed for AlpineJS support, just use Astro components! renderers: [], }); diff --git a/examples/framework-lit/astro.config.mjs b/examples/framework-lit/astro.config.mjs index 0e5346799..c86c77bf7 100644 --- a/examples/framework-lit/astro.config.mjs +++ b/examples/framework-lit/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Enable the lit renderer to support LitHTML components and templates. renderers: ['@astrojs/renderer-lit'], }); diff --git a/examples/framework-multiple/astro.config.mjs b/examples/framework-multiple/astro.config.mjs index ce173ed92..90f8b2ca4 100644 --- a/examples/framework-multiple/astro.config.mjs +++ b/examples/framework-multiple/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Enable many renderers to support all different kinds of components. renderers: ['@astrojs/renderer-preact', '@astrojs/renderer-react', '@astrojs/renderer-svelte', '@astrojs/renderer-vue', '@astrojs/renderer-solid'], }); diff --git a/examples/framework-preact/astro.config.mjs b/examples/framework-preact/astro.config.mjs index a1516f292..a024b64b4 100644 --- a/examples/framework-preact/astro.config.mjs +++ b/examples/framework-preact/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Enable the Preact renderer to support Preact JSX components. renderers: ['@astrojs/renderer-preact'], }); diff --git a/examples/framework-react/astro.config.mjs b/examples/framework-react/astro.config.mjs index 443a69232..b35ad27e9 100644 --- a/examples/framework-react/astro.config.mjs +++ b/examples/framework-react/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Enable the React renderer to support React JSX components. renderers: ['@astrojs/renderer-react'], }); diff --git a/examples/framework-solid/astro.config.mjs b/examples/framework-solid/astro.config.mjs index 72c154cb3..c78642c43 100644 --- a/examples/framework-solid/astro.config.mjs +++ b/examples/framework-solid/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Enable the Solid renderer to support Solid JSX components. renderers: ['@astrojs/renderer-solid'], }); diff --git a/examples/framework-svelte/astro.config.mjs b/examples/framework-svelte/astro.config.mjs index a22ba9c95..4452ef101 100644 --- a/examples/framework-svelte/astro.config.mjs +++ b/examples/framework-svelte/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Enable the Svelte renderer to support Svelte components. renderers: ['@astrojs/renderer-svelte'], }); diff --git a/examples/framework-vue/astro.config.mjs b/examples/framework-vue/astro.config.mjs index 950355760..563e8b8fc 100644 --- a/examples/framework-vue/astro.config.mjs +++ b/examples/framework-vue/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Enable the Vue renderer to support Vue components. renderers: ['@astrojs/renderer-vue'], }); diff --git a/examples/minimal/astro.config.mjs b/examples/minimal/astro.config.mjs index 67c95c240..c6e58dbdc 100644 --- a/examples/minimal/astro.config.mjs +++ b/examples/minimal/astro.config.mjs @@ -1,8 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Comment out "renderers: []" to enable Astro's default component support. renderers: [], }); diff --git a/examples/non-html-pages/astro.config.mjs b/examples/non-html-pages/astro.config.mjs index 67c95c240..c6e58dbdc 100644 --- a/examples/non-html-pages/astro.config.mjs +++ b/examples/non-html-pages/astro.config.mjs @@ -1,8 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Comment out "renderers: []" to enable Astro's default component support. renderers: [], }); diff --git a/examples/portfolio/astro.config.mjs b/examples/portfolio/astro.config.mjs index a1516f292..a024b64b4 100644 --- a/examples/portfolio/astro.config.mjs +++ b/examples/portfolio/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Enable the Preact renderer to support Preact JSX components. renderers: ['@astrojs/renderer-preact'], }); diff --git a/examples/ssr/astro.config.mjs b/examples/ssr/astro.config.mjs index c96372f66..d54ab5929 100644 --- a/examples/ssr/astro.config.mjs +++ b/examples/ssr/astro.config.mjs @@ -1,6 +1,6 @@ // @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +export default defineConfig({ renderers: ['@astrojs/renderer-svelte'], vite: { server: { diff --git a/examples/starter/astro.config.mjs b/examples/starter/astro.config.mjs index a5fc95e58..f8ad313bc 100644 --- a/examples/starter/astro.config.mjs +++ b/examples/starter/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Set "renderers" to "[]" to disable all default, builtin component support. renderers: [], }); diff --git a/examples/subpath/astro.config.mjs b/examples/subpath/astro.config.mjs index 2b41e4ce7..42ecf7db4 100644 --- a/examples/subpath/astro.config.mjs +++ b/examples/subpath/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Comment out "renderers: []" to enable Astro's default component support. buildOptions: { site: 'http://example.com/blog', diff --git a/examples/with-markdown-plugins/astro.config.mjs b/examples/with-markdown-plugins/astro.config.mjs index c25530d6a..26d986ce1 100644 --- a/examples/with-markdown-plugins/astro.config.mjs +++ b/examples/with-markdown-plugins/astro.config.mjs @@ -1,15 +1,9 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference - -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. +import { defineConfig } from 'astro/config'; import astroRemark from '@astrojs/markdown-remark'; import addClasses from './add-classes.mjs'; -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Enable Custom Markdown options, plugins, etc. renderers: [], markdownOptions: { diff --git a/examples/with-markdown-shiki/astro.config.mjs b/examples/with-markdown-shiki/astro.config.mjs index 59502b3a8..3e9c52479 100644 --- a/examples/with-markdown-shiki/astro.config.mjs +++ b/examples/with-markdown-shiki/astro.config.mjs @@ -1,14 +1,8 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference - -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. +import { defineConfig } from 'astro/config'; import astroRemark from '@astrojs/markdown-remark'; -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Enable Custom Markdown options, plugins, etc. renderers: [], markdownOptions: { diff --git a/examples/with-markdown/astro.config.mjs b/examples/with-markdown/astro.config.mjs index cad67e3e4..f5069ec18 100644 --- a/examples/with-markdown/astro.config.mjs +++ b/examples/with-markdown/astro.config.mjs @@ -1,12 +1,6 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ renderers: ['@astrojs/renderer-preact', '@astrojs/renderer-react', '@astrojs/renderer-svelte', '@astrojs/renderer-vue'], }); diff --git a/examples/with-nanostores/astro.config.mjs b/examples/with-nanostores/astro.config.mjs index ce173ed92..90f8b2ca4 100644 --- a/examples/with-nanostores/astro.config.mjs +++ b/examples/with-nanostores/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Enable many renderers to support all different kinds of components. renderers: ['@astrojs/renderer-preact', '@astrojs/renderer-react', '@astrojs/renderer-svelte', '@astrojs/renderer-vue', '@astrojs/renderer-solid'], }); diff --git a/examples/with-tailwindcss/astro.config.mjs b/examples/with-tailwindcss/astro.config.mjs index a1516f292..a024b64b4 100644 --- a/examples/with-tailwindcss/astro.config.mjs +++ b/examples/with-tailwindcss/astro.config.mjs @@ -1,13 +1,7 @@ -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference +import { defineConfig } from 'astro/config'; -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ // Enable the Preact renderer to support Preact JSX components. renderers: ['@astrojs/renderer-preact'], }); diff --git a/examples/with-vite-plugin-pwa/astro.config.mjs b/examples/with-vite-plugin-pwa/astro.config.mjs index a14546663..7f5cebf51 100644 --- a/examples/with-vite-plugin-pwa/astro.config.mjs +++ b/examples/with-vite-plugin-pwa/astro.config.mjs @@ -1,15 +1,8 @@ +import { defineConfig } from 'astro/config'; import { VitePWA } from 'vite-plugin-pwa'; -// Full Astro Configuration API Documentation: -// https://docs.astro.build/reference/configuration-reference - -// @type-check enabled! -// VSCode and other TypeScript-enabled text editors will provide auto-completion, -// helpful tooltips, and warnings if your exported object is invalid. -// You can disable this by removing "@ts-check" and `@type` comments below. - -// @ts-check -export default /** @type {import('astro').AstroUserConfig} */ ({ +// https://astro.build/config +export default defineConfig({ renderers: [], vite: { plugins: [VitePWA()], diff --git a/packages/astro/config.d.ts b/packages/astro/config.d.ts new file mode 100644 index 000000000..b63f18336 --- /dev/null +++ b/packages/astro/config.d.ts @@ -0,0 +1,7 @@ +type AstroUserConfig = import('./dist/types/@types/astro').AstroUserConfig; + +/** + * See the full Astro Configuration API Documentation + * https://astro.build/config + */ +export function defineConfig(config: AstroUserConfig): AstroUserConfig; diff --git a/packages/astro/config.mjs b/packages/astro/config.mjs new file mode 100644 index 000000000..cf19c5aa4 --- /dev/null +++ b/packages/astro/config.mjs @@ -0,0 +1,3 @@ +export function defineConfig(config) { + return config; +} diff --git a/packages/astro/package.json b/packages/astro/package.json index 854c5d9fa..3d9fb5b00 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -16,6 +16,7 @@ "exports": { ".": "./astro.js", "./env": "./env.d.ts", + "./config": "./config.mjs", "./internal": "./internal.js", "./app/node": "./dist/core/app/node.js", "./client/*": "./dist/runtime/client/*", @@ -45,6 +46,8 @@ "components", "dist", "astro.js", + "config.d.ts", + "config.mjs", "env.d.ts", "README.md", "vendor"