diff --git a/.changeset/cold-eyes-run.md b/.changeset/cold-eyes-run.md new file mode 100644 index 000000000000..8775c1919b46 --- /dev/null +++ b/.changeset/cold-eyes-run.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Add export keyword to astro config file stub created by add cli command diff --git a/.changeset/old-walls-draw.md b/.changeset/old-walls-draw.md new file mode 100644 index 000000000000..cda5405b3362 --- /dev/null +++ b/.changeset/old-walls-draw.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Added missing `media` attributes from the JSX definitions for the `meta` element diff --git a/.changeset/wet-wombats-prove.md b/.changeset/wet-wombats-prove.md new file mode 100644 index 000000000000..da0b0193469f --- /dev/null +++ b/.changeset/wet-wombats-prove.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Improve warning logs on astro.config change diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b125789df19..db76aefbd543 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -201,12 +201,6 @@ jobs: repository: withastro/docs path: smoke/docs - - name: Checkout astro.build - uses: actions/checkout@v3 - with: - repository: withastro/astro.build - path: smoke/astro-build - - name: Install dependencies run: pnpm install --no-frozen-lockfile diff --git a/packages/astro/astro-jsx.d.ts b/packages/astro/astro-jsx.d.ts index cf76e6e58e89..2f01aafe4773 100644 --- a/packages/astro/astro-jsx.d.ts +++ b/packages/astro/astro-jsx.d.ts @@ -820,6 +820,7 @@ declare namespace astroHTML.JSX { content?: string | URL | undefined | null; 'http-equiv'?: string | undefined | null; name?: string | undefined | null; + media?: string | undefined | null; } interface MeterHTMLAttributes extends HTMLAttributes { diff --git a/packages/astro/src/cli/index.ts b/packages/astro/src/cli/index.ts index ce588acfa78a..27aa7db304a0 100644 --- a/packages/astro/src/cli/index.ts +++ b/packages/astro/src/cli/index.ts @@ -8,7 +8,7 @@ import build from '../core/build/index.js'; import { openConfig } from '../core/config.js'; import devServer from '../core/dev/index.js'; import { collectErrorMetadata } from '../core/errors.js'; -import { debug, LogOptions } from '../core/logger/core.js'; +import { debug, info, LogOptions, warn } from '../core/logger/core.js'; import { enableVerboseLogging, nodeLogDestination } from '../core/logger/node.js'; import { formatConfigErrorMessage, formatErrorMessage, printHelp } from '../core/messages.js'; import preview from '../core/preview/index.js'; @@ -132,7 +132,7 @@ async function runCommand(cmd: string, flags: yargs.Arguments) { } } - const { astroConfig, userConfig } = await openConfig({ cwd: root, flags, cmd }); + let { astroConfig, userConfig, userConfigPath } = await openConfig({ cwd: root, flags, cmd }); telemetry.record(event.eventCliSession(cmd, userConfig, flags)); // Common CLI Commands: @@ -140,7 +140,33 @@ async function runCommand(cmd: string, flags: yargs.Arguments) { // by the end of this switch statement. switch (cmd) { case 'dev': { - await devServer(astroConfig, { logging, telemetry }); + async function startDevServer() { + const { watcher, stop } = await devServer(astroConfig, { logging, telemetry }); + + watcher.on('change', logRestartServerOnConfigChange); + watcher.on('unlink', logRestartServerOnConfigChange); + function logRestartServerOnConfigChange(changedFile: string) { + if (userConfigPath === changedFile) { + warn(logging, 'astro', 'Astro config updated. Restart server to see changes!'); + } + } + + watcher.on('add', async function restartServerOnNewConfigFile(addedFile: string) { + // if there was not a config before, attempt to resolve + if (!userConfigPath && addedFile.includes('astro.config')) { + const addedConfig = await openConfig({ cwd: root, flags, cmd }); + if (addedConfig.userConfigPath) { + info(logging, 'astro', 'Astro config detected. Restarting server...'); + astroConfig = addedConfig.astroConfig; + userConfig = addedConfig.userConfig; + userConfigPath = addedConfig.userConfigPath; + await stop(); + await startDevServer(); + } + } + }); + } + await startDevServer(); return await new Promise(() => {}); // lives forever } diff --git a/packages/astro/src/core/add/index.ts b/packages/astro/src/core/add/index.ts index 95892d80f62f..fe75c42c71d6 100644 --- a/packages/astro/src/core/add/index.ts +++ b/packages/astro/src/core/add/index.ts @@ -38,7 +38,7 @@ const ALIASES = new Map([ ['solid', 'solid-js'], ['tailwindcss', 'tailwind'], ]); -const ASTRO_CONFIG_STUB = `import { defineConfig } from 'astro/config';\n\ndefault defineConfig({});`; +const ASTRO_CONFIG_STUB = `import { defineConfig } from 'astro/config';\n\nexport default defineConfig({});`; const TAILWIND_CONFIG_STUB = `/** @type {import('tailwindcss').Config} */ module.exports = { content: ['./src/**/*.{astro,html,js,jsx,md,svelte,ts,tsx,vue}'], diff --git a/packages/astro/src/core/config.ts b/packages/astro/src/core/config.ts index f0b77e83047f..c08bf3576507 100644 --- a/packages/astro/src/core/config.ts +++ b/packages/astro/src/core/config.ts @@ -453,6 +453,7 @@ export async function resolveConfigURL( interface OpenConfigResult { userConfig: AstroUserConfig; + userConfigPath: string | undefined; astroConfig: AstroConfig; flags: CLIFlags; root: string; @@ -489,12 +490,14 @@ export async function openConfig(configOptions: LoadConfigOptions): Promise