diff options
Diffstat (limited to 'packages')
182 files changed, 793 insertions, 897 deletions
diff --git a/packages/astro-prism/package.json b/packages/astro-prism/package.json index eae841073..d62e819a8 100644 --- a/packages/astro-prism/package.json +++ b/packages/astro-prism/package.json @@ -35,7 +35,7 @@ "prismjs": "^1.29.0" }, "devDependencies": { - "@types/prismjs": "1.26.0", + "@types/prismjs": "1.26.3", "astro-scripts": "workspace:*" }, "engines": { diff --git a/packages/astro-rss/package.json b/packages/astro-rss/package.json index c200e6c59..d9d8e771b 100644 --- a/packages/astro-rss/package.json +++ b/packages/astro-rss/package.json @@ -27,9 +27,9 @@ "test": "mocha --exit --timeout 20000" }, "devDependencies": { - "@types/chai": "^4.3.5", - "@types/chai-as-promised": "^7.1.5", - "@types/mocha": "^10.0.1", + "@types/chai": "^4.3.10", + "@types/chai-as-promised": "^7.1.8", + "@types/mocha": "^10.0.4", "astro": "workspace:*", "astro-scripts": "workspace:*", "chai": "^4.3.7", diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts index dfcffbee3..fe1a23311 100644 --- a/packages/astro/client.d.ts +++ b/packages/astro/client.d.ts @@ -1,4 +1,4 @@ -/// <reference path="./import-meta.d.ts" /> +/// <reference types="vite/types/import-meta.d.ts" /> // eslint-disable-next-line @typescript-eslint/no-namespace declare namespace App { @@ -106,7 +106,7 @@ declare module '*.avif' { } declare module 'astro:transitions' { - type TransitionModule = typeof import('./dist/transitions/index.js'); + type TransitionModule = typeof import('./dist/virtual-modules/transitions.js'); export const slide: TransitionModule['slide']; export const fade: TransitionModule['fade']; export const createAnimationScope: TransitionModule['createAnimationScope']; @@ -116,44 +116,44 @@ declare module 'astro:transitions' { } declare module 'astro:transitions/client' { - type TransitionRouterModule = typeof import('./dist/transitions/router.js'); + type TransitionRouterModule = typeof import('./dist/virtual-modules/transitions-router.js'); export const navigate: TransitionRouterModule['navigate']; - type TransitionUtilModule = typeof import('./dist/transitions/util.js'); + type TransitionUtilModule = typeof import('./dist/virtual-modules/transitions-util.js'); export const supportsViewTransitions: TransitionUtilModule['supportsViewTransitions']; export const getFallback: TransitionUtilModule['getFallback']; export const transitionEnabledOnThisPage: TransitionUtilModule['transitionEnabledOnThisPage']; - export type Fallback = import('./dist/transitions/types.ts').Fallback; - export type Direction = import('./dist/transitions/types.ts').Direction; - export type NavigationTypeString = import('./dist/transitions/types.ts').NavigationTypeString; - export type Options = import('./dist/transitions/types.ts').Options; + export type Fallback = import('./dist/virtual-modules/transitions-types.js').Fallback; + export type Direction = import('./dist/virtual-modules/transitions-types.ts').Direction; + export type NavigationTypeString = import('./dist/virtual-modules/transitions-types.js').NavigationTypeString; + export type Options = import('./dist/virtual-modules/transitions-types.js').Options; - type EventModule = typeof import('./dist/transitions/events.js'); + type EventModule = typeof import('./dist/virtual-modules/transitions-events.js'); export const TRANSITION_BEFORE_PREPARATION: EventModule['TRANSITION_BEFORE_PREPARATION']; export const TRANSITION_AFTER_PREPARATION: EventModule['TRANSITION_AFTER_PREPARATION']; export const TRANSITION_BEFORE_SWAP: EventModule['TRANSITION_BEFORE_SWAP']; export const TRANSITION_AFTER_SWAP: EventModule['TRANSITION_AFTER_SWAP']; export const TRANSITION_PAGE_LOAD: EventModule['TRANSITION_PAGE_LOAD']; export type TransitionBeforePreparationEvent = - import('./dist/transitions/events.ts').TransitionBeforePreparationEvent; + import('./dist/virtual-modules/transitions-events.js').TransitionBeforePreparationEvent; export type TransitionBeforeSwapEvent = - import('./dist/transitions/events.ts').TransitionBeforeSwapEvent; + import('./dist/virtual-modules/transitions-events.js').TransitionBeforeSwapEvent; export const isTransitionBeforePreparationEvent: EventModule['isTransitionBeforePreparationEvent']; export const isTransitionBeforeSwapEvent: EventModule['isTransitionBeforeSwapEvent']; } declare module 'astro:prefetch' { - export { prefetch, PrefetchOptions } from 'astro/prefetch'; + export { prefetch, PrefetchOptions } from 'astro/virtual-modules/prefetch.js'; } declare module 'astro:i18n' { - export type GetLocaleOptions = import('./dist/i18n/index.js').GetLocaleOptions; + export type GetLocaleOptions = import('./dist/virtual-modules/i18n.js').GetLocaleOptions; /** * @param {string} locale A locale * @param {string} [path=""] An optional path to add after the `locale`. - * @param {import('./dist/i18n/index.js').GetLocaleOptions} options Customise the generated path + * @param {import('./dist/virtual-modules/i18n.js').GetLocaleOptions} options Customise the generated path * @return {string} * * Returns a _relative_ path with passed locale. @@ -182,7 +182,7 @@ declare module 'astro:i18n' { * * @param {string} locale A locale * @param {string} [path=""] An optional path to add after the `locale`. - * @param {import('./dist/i18n/index.js').GetLocaleOptions} options Customise the generated path + * @param {import('./dist/virtual-modules/i18n.js').GetLocaleOptions} options Customise the generated path * @return {string} * * Returns an absolute path with the passed locale. The behaviour is subject to change based on `site` configuration. @@ -212,7 +212,7 @@ declare module 'astro:i18n' { /** * @param {string} [path=""] An optional path to add after the `locale`. - * @param {import('./dist/i18n/index.js').GetLocaleOptions} options Customise the generated path + * @param {import('./dist/virtual-modules/i18n.js').GetLocaleOptions} options Customise the generated path * @return {string[]} * * Works like `getRelativeLocaleUrl` but it emits the relative URLs for ALL locales: @@ -220,7 +220,7 @@ declare module 'astro:i18n' { export const getRelativeLocaleUrlList: (path?: string, options?: GetLocaleOptions) => string[]; /** * @param {string} [path=""] An optional path to add after the `locale`. - * @param {import('./dist/i18n/index.js').GetLocaleOptions} options Customise the generated path + * @param {import('./dist/virtual-modules/i18n.js').GetLocaleOptions} options Customise the generated path * @return {string[]} * * Works like `getAbsoluteLocaleUrl` but it emits the absolute URLs for ALL locales: @@ -229,7 +229,7 @@ declare module 'astro:i18n' { } declare module 'astro:middleware' { - export * from 'astro/middleware/namespace'; + export * from 'astro/virtual-modules/middleware.js'; } declare module 'astro:components' { diff --git a/packages/astro/components/ViewTransitions.astro b/packages/astro/components/ViewTransitions.astro index 645f2046a..1fa3611dd 100644 --- a/packages/astro/components/ViewTransitions.astro +++ b/packages/astro/components/ViewTransitions.astro @@ -29,9 +29,9 @@ const { fallback = 'animate', handleForms } = Astro.props; <script> import type { Options } from 'astro:transitions/client'; import { supportsViewTransitions, navigate } from 'astro:transitions/client'; - // NOTE: import from `astro/prefetch` as `astro:prefetch` requires the `prefetch` config to be enabled + // NOTE: import from `astro/virtual-modules/prefetch.js` as `astro:prefetch` requires the `prefetch` config to be enabled // @ts-ignore - import { init } from 'astro/prefetch'; + import { init } from 'astro/virtual-modules/prefetch.js'; type Fallback = 'none' | 'animate' | 'swap'; diff --git a/packages/astro/e2e/fixtures/astro-component/package.json b/packages/astro/e2e/fixtures/astro-component/package.json index b7cc8fbc1..b02f5b90c 100644 --- a/packages/astro/e2e/fixtures/astro-component/package.json +++ b/packages/astro/e2e/fixtures/astro-component/package.json @@ -6,6 +6,6 @@ "@astrojs/preact": "workspace:*", "@e2e/astro-linked-lib": "link:../_deps/astro-linked-lib", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/e2e/fixtures/astro-envs/package.json b/packages/astro/e2e/fixtures/astro-envs/package.json index 2fa703b96..ac0cd9afa 100644 --- a/packages/astro/e2e/fixtures/astro-envs/package.json +++ b/packages/astro/e2e/fixtures/astro-envs/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "vue": "^3.3.4" + "vue": "^3.3.8" } } diff --git a/packages/astro/e2e/fixtures/client-only/package.json b/packages/astro/e2e/fixtures/client-only/package.json index f71e9936c..938d67392 100644 --- a/packages/astro/e2e/fixtures/client-only/package.json +++ b/packages/astro/e2e/fixtures/client-only/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.17.1", + "preact": "^10.19.2", "react": "^18.1.0", "react-dom": "^18.1.0", - "solid-js": "^1.7.11", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "solid-js": "^1.8.5", + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/e2e/fixtures/dev-overlay/package.json b/packages/astro/e2e/fixtures/dev-overlay/package.json index 707aa8718..6cd05404d 100644 --- a/packages/astro/e2e/fixtures/dev-overlay/package.json +++ b/packages/astro/e2e/fixtures/dev-overlay/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/e2e/fixtures/error-cyclic/package.json b/packages/astro/e2e/fixtures/error-cyclic/package.json index b4a9ed29c..f63c95a37 100644 --- a/packages/astro/e2e/fixtures/error-cyclic/package.json +++ b/packages/astro/e2e/fixtures/error-cyclic/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/e2e/fixtures/error-sass/package.json b/packages/astro/e2e/fixtures/error-sass/package.json index 6c89910db..7f92d3b5a 100644 --- a/packages/astro/e2e/fixtures/error-sass/package.json +++ b/packages/astro/e2e/fixtures/error-sass/package.json @@ -4,6 +4,6 @@ "private": true, "dependencies": { "astro": "workspace:*", - "sass": "^1.66.1" + "sass": "^1.69.5" } } diff --git a/packages/astro/e2e/fixtures/errors/package.json b/packages/astro/e2e/fixtures/errors/package.json index 67ce0a535..7d93b8354 100644 --- a/packages/astro/e2e/fixtures/errors/package.json +++ b/packages/astro/e2e/fixtures/errors/package.json @@ -9,12 +9,12 @@ "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1", + "preact": "^10.19.2", "react": "^18.1.0", "react-dom": "^18.1.0", - "sass": "^1.66.1", - "solid-js": "^1.7.11", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "sass": "^1.69.5", + "solid-js": "^1.8.5", + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/e2e/fixtures/hmr/package.json b/packages/astro/e2e/fixtures/hmr/package.json index f5aa41460..6e102c997 100644 --- a/packages/astro/e2e/fixtures/hmr/package.json +++ b/packages/astro/e2e/fixtures/hmr/package.json @@ -4,6 +4,6 @@ "private": true, "devDependencies": { "astro": "workspace:*", - "sass": "^1.66.1" + "sass": "^1.69.5" } } diff --git a/packages/astro/e2e/fixtures/hydration-race/package.json b/packages/astro/e2e/fixtures/hydration-race/package.json index 8db4efa29..580c6721d 100644 --- a/packages/astro/e2e/fixtures/hydration-race/package.json +++ b/packages/astro/e2e/fixtures/hydration-race/package.json @@ -9,6 +9,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/e2e/fixtures/multiple-frameworks/package.json b/packages/astro/e2e/fixtures/multiple-frameworks/package.json index 1edb9df99..4666b1593 100644 --- a/packages/astro/e2e/fixtures/multiple-frameworks/package.json +++ b/packages/astro/e2e/fixtures/multiple-frameworks/package.json @@ -14,11 +14,11 @@ "dependencies": { "@webcomponents/template-shadowroot": "^0.2.1", "lit": "^2.8.0", - "preact": "^10.17.1", + "preact": "^10.19.2", "react": "^18.1.0", "react-dom": "^18.1.0", - "solid-js": "^1.7.11", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "solid-js": "^1.8.5", + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/e2e/fixtures/namespaced-component/package.json b/packages/astro/e2e/fixtures/namespaced-component/package.json index 596cb5d2b..a64e3b52a 100644 --- a/packages/astro/e2e/fixtures/namespaced-component/package.json +++ b/packages/astro/e2e/fixtures/namespaced-component/package.json @@ -8,6 +8,6 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/e2e/fixtures/nested-in-preact/package.json b/packages/astro/e2e/fixtures/nested-in-preact/package.json index c626314bd..fcbbd1e2b 100644 --- a/packages/astro/e2e/fixtures/nested-in-preact/package.json +++ b/packages/astro/e2e/fixtures/nested-in-preact/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.17.1", + "preact": "^10.19.2", "react": "^18.1.0", "react-dom": "^18.1.0", - "solid-js": "^1.7.11", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "solid-js": "^1.8.5", + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/e2e/fixtures/nested-in-react/package.json b/packages/astro/e2e/fixtures/nested-in-react/package.json index 88690f140..18463a773 100644 --- a/packages/astro/e2e/fixtures/nested-in-react/package.json +++ b/packages/astro/e2e/fixtures/nested-in-react/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.17.1", + "preact": "^10.19.2", "react": "^18.1.0", "react-dom": "^18.1.0", - "solid-js": "^1.7.11", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "solid-js": "^1.8.5", + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/e2e/fixtures/nested-in-solid/package.json b/packages/astro/e2e/fixtures/nested-in-solid/package.json index 47ba1334d..4c9f03262 100644 --- a/packages/astro/e2e/fixtures/nested-in-solid/package.json +++ b/packages/astro/e2e/fixtures/nested-in-solid/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.17.1", + "preact": "^10.19.2", "react": "^18.1.0", "react-dom": "^18.1.0", - "solid-js": "^1.7.11", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "solid-js": "^1.8.5", + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/e2e/fixtures/nested-in-svelte/package.json b/packages/astro/e2e/fixtures/nested-in-svelte/package.json index 91b88bbb8..a3adbea06 100644 --- a/packages/astro/e2e/fixtures/nested-in-svelte/package.json +++ b/packages/astro/e2e/fixtures/nested-in-svelte/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.17.1", + "preact": "^10.19.2", "react": "^18.1.0", "react-dom": "^18.1.0", - "solid-js": "^1.7.11", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "solid-js": "^1.8.5", + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/e2e/fixtures/nested-in-vue/package.json b/packages/astro/e2e/fixtures/nested-in-vue/package.json index 3cab15f47..2555b7a29 100644 --- a/packages/astro/e2e/fixtures/nested-in-vue/package.json +++ b/packages/astro/e2e/fixtures/nested-in-vue/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.17.1", + "preact": "^10.19.2", "react": "^18.1.0", "react-dom": "^18.1.0", - "solid-js": "^1.7.11", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "solid-js": "^1.8.5", + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/e2e/fixtures/nested-recursive/package.json b/packages/astro/e2e/fixtures/nested-recursive/package.json index a1dfa3a09..a6b11a389 100644 --- a/packages/astro/e2e/fixtures/nested-recursive/package.json +++ b/packages/astro/e2e/fixtures/nested-recursive/package.json @@ -11,12 +11,12 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.17.1", + "preact": "^10.19.2", "react": "^18.1.0", "react-dom": "^18.1.0", - "solid-js": "^1.7.11", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "solid-js": "^1.8.5", + "svelte": "^4.2.5", + "vue": "^3.3.8" }, "scripts": { "dev": "astro dev" diff --git a/packages/astro/e2e/fixtures/preact-compat-component/package.json b/packages/astro/e2e/fixtures/preact-compat-component/package.json index 72fdbdf3a..38b4fc3a8 100644 --- a/packages/astro/e2e/fixtures/preact-compat-component/package.json +++ b/packages/astro/e2e/fixtures/preact-compat-component/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/e2e/fixtures/preact-component/package.json b/packages/astro/e2e/fixtures/preact-component/package.json index 264c1d99b..4e2cd6fe2 100644 --- a/packages/astro/e2e/fixtures/preact-component/package.json +++ b/packages/astro/e2e/fixtures/preact-component/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/e2e/fixtures/solid-circular/package.json b/packages/astro/e2e/fixtures/solid-circular/package.json index e32dccbdb..a40b083c3 100644 --- a/packages/astro/e2e/fixtures/solid-circular/package.json +++ b/packages/astro/e2e/fixtures/solid-circular/package.json @@ -7,6 +7,6 @@ "astro": "workspace:*" }, "devDependencies": { - "solid-js": "^1.7.11" + "solid-js": "^1.8.5" } } diff --git a/packages/astro/e2e/fixtures/solid-component/package.json b/packages/astro/e2e/fixtures/solid-component/package.json index d4ef4de6e..634693c79 100644 --- a/packages/astro/e2e/fixtures/solid-component/package.json +++ b/packages/astro/e2e/fixtures/solid-component/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/solid-js": "workspace:*", "astro": "workspace:*", - "solid-js": "^1.7.11" + "solid-js": "^1.8.5" } } diff --git a/packages/astro/e2e/fixtures/solid-recurse/package.json b/packages/astro/e2e/fixtures/solid-recurse/package.json index 6f999c6a3..96d93df74 100644 --- a/packages/astro/e2e/fixtures/solid-recurse/package.json +++ b/packages/astro/e2e/fixtures/solid-recurse/package.json @@ -7,6 +7,6 @@ "astro": "workspace:*" }, "devDependencies": { - "solid-js": "^1.7.11" + "solid-js": "^1.8.5" } } diff --git a/packages/astro/e2e/fixtures/svelte-component/package.json b/packages/astro/e2e/fixtures/svelte-component/package.json index c6fe3c8e8..b721b8ccb 100644 --- a/packages/astro/e2e/fixtures/svelte-component/package.json +++ b/packages/astro/e2e/fixtures/svelte-component/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/svelte": "workspace:*", "astro": "workspace:*", - "svelte": "^4.2.0" + "svelte": "^4.2.5" } } diff --git a/packages/astro/e2e/fixtures/tailwindcss/package.json b/packages/astro/e2e/fixtures/tailwindcss/package.json index ddac263a5..d755b9516 100644 --- a/packages/astro/e2e/fixtures/tailwindcss/package.json +++ b/packages/astro/e2e/fixtures/tailwindcss/package.json @@ -7,6 +7,6 @@ "astro": "workspace:*", "autoprefixer": "^10.4.15", "postcss": "^8.4.28", - "tailwindcss": "^3.3.3" + "tailwindcss": "^3.3.5" } } diff --git a/packages/astro/e2e/fixtures/view-transitions/package.json b/packages/astro/e2e/fixtures/view-transitions/package.json index b53b5fcad..327393ccd 100644 --- a/packages/astro/e2e/fixtures/view-transitions/package.json +++ b/packages/astro/e2e/fixtures/view-transitions/package.json @@ -3,14 +3,14 @@ "version": "0.0.0", "private": true, "dependencies": { - "astro": "workspace:*", "@astrojs/node": "workspace:*", "@astrojs/react": "workspace:*", - "@astrojs/vue": "workspace:*", "@astrojs/svelte": "workspace:*", - "svelte": "^4.2.0", - "vue": "^3.3.4", + "@astrojs/vue": "workspace:*", + "astro": "workspace:*", "react": "^18.1.0", - "react-dom": "^18.1.0" + "react-dom": "^18.1.0", + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/e2e/fixtures/vue-component/package.json b/packages/astro/e2e/fixtures/vue-component/package.json index 81e799783..091f36435 100644 --- a/packages/astro/e2e/fixtures/vue-component/package.json +++ b/packages/astro/e2e/fixtures/vue-component/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "vue": "^3.3.4" + "vue": "^3.3.8" } } diff --git a/packages/astro/import-meta.d.ts b/packages/astro/import-meta.d.ts deleted file mode 100644 index 23d951cf2..000000000 --- a/packages/astro/import-meta.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -// File vendored from Vite itself, as a workaround to https://github.com/vitejs/vite/issues/13309 until Vite 5 comes out - -// This file is an augmentation to the built-in ImportMeta interface -// Thus cannot contain any top-level imports -// <https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation> - -/* eslint-disable @typescript-eslint/consistent-type-imports */ - -interface ImportMeta { - url: string; - - readonly hot?: import('vite/types/hot').ViteHotContext; - - readonly env: ImportMetaEnv; - - glob: import('vite/types/importGlob').ImportGlobFunction; - /** - * @deprecated Use `import.meta.glob('*', { eager: true })` instead - */ - globEager: import('vite/types/importGlob').ImportGlobEagerFunction; -} - -interface ImportMetaEnv { - [key: string]: any; - BASE_URL: string; - MODE: string; - DEV: boolean; - PROD: boolean; - SSR: boolean; -} diff --git a/packages/astro/package.json b/packages/astro/package.json index 95c8b1d88..a12c58c98 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -22,10 +22,7 @@ "./dist/core/app/*" ], "middleware": [ - "./dist/core/middleware/index.d.ts" - ], - "middleware/namespace": [ - "./dist/core/middleware/namespace.d.ts" + "./dist/virtual-modules/middleware.d.ts" ] } }, @@ -73,16 +70,7 @@ "types": "./dist/core/middleware/index.d.ts", "default": "./dist/core/middleware/index.js" }, - "./middleware/namespace": { - "types": "./dist/core/middleware/namespace.d.ts", - "default": "./dist/core/middleware/namespace.js" - }, - "./transitions": "./dist/transitions/index.js", - "./transitions/events": "./dist/transitions/events.js", - "./transitions/router": "./dist/transitions/router.js", - "./transitions/types": "./dist/transitions/types.js", - "./prefetch": "./dist/prefetch/index.js", - "./i18n": "./dist/i18n/index.js" + "./virtual-modules/*": "./dist/virtual-modules/*" }, "imports": { "#astro/*": "./dist/*.js" @@ -124,33 +112,33 @@ "test:e2e:match": "playwright test -g" }, "dependencies": { - "@astrojs/compiler": "^2.3.0", + "@astrojs/compiler": "^2.3.2", "@astrojs/internal-helpers": "workspace:*", "@astrojs/markdown-remark": "workspace:*", "@astrojs/telemetry": "workspace:*", - "@babel/core": "^7.22.10", - "@babel/generator": "^7.22.10", - "@babel/parser": "^7.22.10", + "@babel/core": "^7.23.3", + "@babel/generator": "^7.23.3", + "@babel/parser": "^7.23.3", "@babel/plugin-transform-react-jsx": "^7.22.5", - "@babel/traverse": "^7.22.10", - "@babel/types": "^7.22.10", - "@types/babel__core": "^7.20.1", - "acorn": "^8.10.0", + "@babel/traverse": "^7.23.3", + "@babel/types": "^7.23.3", + "@types/babel__core": "^7.20.4", + "acorn": "^8.11.2", "boxen": "^7.1.1", "chokidar": "^3.5.3", - "ci-info": "^3.8.0", + "ci-info": "^4.0.0", "clsx": "^2.0.0", "common-ancestor-path": "^1.0.1", - "cookie": "^0.5.0", + "cookie": "^0.6.0", "debug": "^4.3.4", - "deterministic-object-hash": "^1.3.1", + "deterministic-object-hash": "^2.0.1", "devalue": "^4.3.2", "diff": "^5.1.0", - "es-module-lexer": "^1.3.0", - "esbuild": "^0.19.2", + "es-module-lexer": "^1.4.1", + "esbuild": "^0.19.6", "estree-walker": "^3.0.3", "execa": "^8.0.1", - "fast-glob": "^3.3.1", + "fast-glob": "^3.3.2", "github-slugger": "^2.0.0", "gray-matter": "^4.0.3", "html-escaper": "^3.0.3", @@ -158,26 +146,26 @@ "js-yaml": "^4.1.0", "kleur": "^4.1.4", "magic-string": "^0.30.3", - "mdast-util-to-hast": "12.3.0", + "mdast-util-to-hast": "13.0.2", "mime": "^3.0.0", "ora": "^7.0.1", - "p-limit": "^4.0.0", + "p-limit": "^5.0.0", "p-queue": "^7.4.1", "path-to-regexp": "^6.2.1", "preferred-pm": "^3.1.2", "probe-image-size": "^7.2.3", "prompts": "^2.4.2", - "rehype": "^12.0.1", + "rehype": "^13.0.1", "resolve": "^1.22.4", "semver": "^7.5.4", "server-destroy": "^1.0.1", - "shikiji": "^0.6.8", - "string-width": "^6.1.0", + "shikiji": "^0.6.13", + "string-width": "^7.0.0", "strip-ansi": "^7.1.0", "tsconfck": "^3.0.0", - "unist-util-visit": "^4.1.2", - "vfile": "^5.3.7", - "vite": "^4.4.9", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.1", + "vite": "^5.0.0", "vitefu": "^0.2.4", "which-pm": "^2.1.1", "yargs-parser": "^21.1.1", @@ -187,31 +175,31 @@ "sharp": "^0.32.5" }, "devDependencies": { - "@astrojs/check": "^0.1.0", - "@playwright/test": "1.40.0-alpha-nov-13-2023", - "@types/babel__generator": "^7.6.4", - "@types/babel__traverse": "^7.20.1", - "@types/chai": "^4.3.5", - "@types/common-ancestor-path": "^1.0.0", - "@types/connect": "^3.4.35", - "@types/cookie": "^0.5.1", - "@types/debug": "^4.1.8", - "@types/diff": "^5.0.3", - "@types/dom-view-transitions": "^1.0.1", - "@types/estree": "^1.0.1", - "@types/hast": "^2.3.5", - "@types/html-escaper": "^3.0.0", - "@types/http-cache-semantics": "^4.0.1", - "@types/js-yaml": "^4.0.5", - "@types/mime": "^3.0.1", - "@types/mocha": "^10.0.1", - "@types/probe-image-size": "^7.2.0", - "@types/prompts": "^2.4.4", - "@types/resolve": "^1.20.2", - "@types/send": "^0.17.1", - "@types/server-destroy": "^1.0.1", - "@types/unist": "^2.0.7", - "@types/yargs-parser": "^21.0.0", + "@astrojs/check": "^0.3.1", + "@playwright/test": "1.40.0", + "@types/babel__generator": "^7.6.7", + "@types/babel__traverse": "^7.20.4", + "@types/chai": "^4.3.10", + "@types/common-ancestor-path": "^1.0.2", + "@types/connect": "^3.4.38", + "@types/cookie": "^0.5.4", + "@types/debug": "^4.1.12", + "@types/diff": "^5.0.8", + "@types/dom-view-transitions": "^1.0.4", + "@types/estree": "^1.0.5", + "@types/hast": "^3.0.3", + "@types/html-escaper": "^3.0.2", + "@types/http-cache-semantics": "^4.0.4", + "@types/js-yaml": "^4.0.9", + "@types/mime": "^3.0.4", + "@types/mocha": "^10.0.4", + "@types/probe-image-size": "^7.2.3", + "@types/prompts": "^2.4.8", + "@types/resolve": "^1.20.5", + "@types/send": "^0.17.4", + "@types/server-destroy": "^1.0.3", + "@types/unist": "^3.0.2", + "@types/yargs-parser": "^21.0.3", "astro-scripts": "workspace:*", "chai": "^4.3.7", "cheerio": "1.0.0-rc.12", @@ -220,14 +208,14 @@ "mocha": "^10.2.0", "node-mocks-http": "^1.13.0", "parse-srcset": "^1.0.2", - "rehype-autolink-headings": "^6.1.1", - "rehype-slug": "^5.0.1", + "rehype-autolink-headings": "^7.1.0", + "rehype-slug": "^6.0.0", "rehype-toc": "^3.0.2", "remark-code-titles": "^0.1.2", - "rollup": "^3.28.1", - "sass": "^1.66.1", + "rollup": "^4.5.0", + "sass": "^1.69.5", "srcset-parse": "^1.1.0", - "unified": "^10.1.2" + "unified": "^11.0.4" }, "engines": { "node": ">=18.14.1", diff --git a/packages/astro/performance/fixtures/md/package.json b/packages/astro/performance/fixtures/md/package.json index ff7b1dec0..4dea64d76 100644 --- a/packages/astro/performance/fixtures/md/package.json +++ b/packages/astro/performance/fixtures/md/package.json @@ -16,8 +16,8 @@ "dependencies": { "@astrojs/react": "workspace:*", "@performance/utils": "workspace:*", - "@types/react": "^18.2.21", - "@types/react-dom": "^18.2.7", + "@types/react": "^18.2.37", + "@types/react-dom": "^18.2.15", "astro": "workspace:*", "react": "^18.0.0", "react-dom": "^18.0.0" diff --git a/packages/astro/performance/fixtures/mdoc/package.json b/packages/astro/performance/fixtures/mdoc/package.json index 351ef15e4..a25e69c97 100644 --- a/packages/astro/performance/fixtures/mdoc/package.json +++ b/packages/astro/performance/fixtures/mdoc/package.json @@ -17,8 +17,8 @@ "@astrojs/markdoc": "workspace:*", "@astrojs/react": "workspace:*", "@performance/utils": "workspace:*", - "@types/react": "^18.2.21", - "@types/react-dom": "^18.2.7", + "@types/react": "^18.2.37", + "@types/react-dom": "^18.2.15", "astro": "workspace:*", "react": "^18.0.0", "react-dom": "^18.0.0" diff --git a/packages/astro/performance/fixtures/mdx/package.json b/packages/astro/performance/fixtures/mdx/package.json index c2d4e368a..2144dc225 100644 --- a/packages/astro/performance/fixtures/mdx/package.json +++ b/packages/astro/performance/fixtures/mdx/package.json @@ -17,8 +17,8 @@ "@astrojs/mdx": "workspace:*", "@astrojs/react": "workspace:*", "@performance/utils": "workspace:*", - "@types/react": "^18.2.21", - "@types/react-dom": "^18.2.7", + "@types/react": "^18.2.37", + "@types/react-dom": "^18.2.15", "astro": "workspace:*", "react": "^18.0.0", "react-dom": "^18.0.0" diff --git a/packages/astro/performance/package.json b/packages/astro/performance/package.json index e09f29173..25bfad16b 100644 --- a/packages/astro/performance/package.json +++ b/packages/astro/performance/package.json @@ -11,7 +11,7 @@ "author": "", "license": "ISC", "devDependencies": { - "@types/yargs-parser": "^21.0.0", + "@types/yargs-parser": "^21.0.3", "cross-env": "^7.0.3", "kleur": "^4.1.5", "npm-run-all": "^4.1.5", diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 2f2e9f75a..fff91ca10 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1317,7 +1317,7 @@ export interface AstroUserConfig { * { * markdown: { * // Example: Translate the footnotes text to another language, here are the default English values - * remarkRehype: { footnoteLabel: "Footnotes", footnoteBackLabel: "Back to content"}, + * remarkRehype: { footnoteLabel: "Footnotes", footnoteBackLabel: "Back to reference 1"}, * }, * }; * ``` diff --git a/packages/astro/src/assets/build/generate.ts b/packages/astro/src/assets/build/generate.ts index be637c26d..c4109ea1e 100644 --- a/packages/astro/src/assets/build/generate.ts +++ b/packages/astro/src/assets/build/generate.ts @@ -58,7 +58,7 @@ export async function prepareAssetsGenerationEnv( await fs.promises.mkdir(assetsCacheDir, { recursive: true }); } catch (err) { logger.warn( - 'astro:assets', + null, `An error was encountered while creating the cache directory. Proceeding without caching. Error: ${err}` ); useCache = false; @@ -231,7 +231,7 @@ export async function generateImagesForPath( } } catch (e) { env.logger.warn( - 'astro:assets', + null, `An error was encountered while creating the cache directory. Proceeding without caching. Error: ${e}` ); } finally { diff --git a/packages/astro/src/cli/install-package.ts b/packages/astro/src/cli/install-package.ts index 689f81e3e..667037a0c 100644 --- a/packages/astro/src/cli/install-package.ts +++ b/packages/astro/src/cli/install-package.ts @@ -26,7 +26,7 @@ export async function getPackage<T>( packageImport = await import(packageName); } catch (e) { logger.info( - '', + null, `To continue, Astro requires the following dependency to be installed: ${bold(packageName)}.` ); const result = await installPackage([packageName, ...otherDeps], options, logger); diff --git a/packages/astro/src/cli/telemetry/index.ts b/packages/astro/src/cli/telemetry/index.ts index fd664fcc9..277b1cab6 100644 --- a/packages/astro/src/cli/telemetry/index.ts +++ b/packages/astro/src/cli/telemetry/index.ts @@ -1,23 +1,23 @@ /* eslint-disable no-console */ -import whichPm from 'which-pm'; import type yargs from 'yargs-parser'; import * as msg from '../../core/messages.js'; import { telemetry } from '../../events/index.js'; +import { createLoggerFromFlags } from '../flags.js'; interface TelemetryOptions { flags: yargs.Arguments; } export async function notify() { - const packageManager = (await whichPm(process.cwd()))?.name ?? 'npm'; await telemetry.notify(() => { - console.log(msg.telemetryNotice(packageManager) + '\n'); + console.log(msg.telemetryNotice() + '\n'); return true; }); } export async function update(subcommand: string, { flags }: TelemetryOptions) { const isValid = ['enable', 'disable', 'reset'].includes(subcommand); + const logger = createLoggerFromFlags(flags); if (flags.help || flags.h || !isValid) { msg.printHelp({ @@ -37,17 +37,17 @@ export async function update(subcommand: string, { flags }: TelemetryOptions) { switch (subcommand) { case 'enable': { telemetry.setEnabled(true); - console.log(msg.telemetryEnabled()); + logger.info('SKIP_FORMAT', msg.telemetryEnabled()); return; } case 'disable': { telemetry.setEnabled(false); - console.log(msg.telemetryDisabled()); + logger.info('SKIP_FORMAT', msg.telemetryDisabled()); return; } case 'reset': { telemetry.clear(); - console.log(msg.telemetryReset()); + logger.info('SKIP_FORMAT', msg.telemetryReset()); return; } } diff --git a/packages/astro/src/content/server-listeners.ts b/packages/astro/src/content/server-listeners.ts index 699d5f271..3ff3148cb 100644 --- a/packages/astro/src/content/server-listeners.ts +++ b/packages/astro/src/content/server-listeners.ts @@ -1,4 +1,4 @@ -import { bold, cyan } from 'kleur/colors'; +import { bold, cyan, underline } from 'kleur/colors'; import type fsMod from 'node:fs'; import path from 'node:path'; import { fileURLToPath, pathToFileURL } from 'node:url'; @@ -26,7 +26,7 @@ export async function attachContentServerListeners({ const contentPaths = getContentPaths(settings.config, fs); if (fs.existsSync(contentPaths.contentDir)) { - logger.info( + logger.debug( 'content', `Watching ${cyan( contentPaths.contentDir.href.replace(settings.config.root.href, '') @@ -39,7 +39,7 @@ export async function attachContentServerListeners({ viteServer.watcher.on('addDir', contentDirListener); async function contentDirListener(dir: string) { if (appendForwardSlash(pathToFileURL(dir).href) === contentPaths.contentDir.href) { - logger.info('content', `Content dir found. Watching for changes`); + logger.debug('content', `Content directory found. Watching for changes`); await attachListeners(); viteServer.watcher.removeListener('addDir', contentDirListener); } @@ -55,7 +55,7 @@ export async function attachContentServerListeners({ contentConfigObserver: globalContentConfigObserver, }); await contentGenerator.init(); - logger.info('content', 'Types generated'); + logger.debug('content', 'Types generated'); viteServer.watcher.on('add', (entry) => { contentGenerator.queueEvent({ name: 'add', entry }); @@ -90,9 +90,9 @@ function warnAllowJsIsFalse({ 'true' )} in your ${bold(tsConfigFileName)} file to have autocompletion in your ${bold( contentConfigFileName - )} file. -See ${bold('https://www.typescriptlang.org/tsconfig#allowJs')} for more information. - ` + )} file. See ${underline( + cyan('https://www.typescriptlang.org/tsconfig#allowJs') + )} for more information.` ); } diff --git a/packages/astro/src/content/types-generator.ts b/packages/astro/src/content/types-generator.ts index b50c597fd..dc9c1ecc7 100644 --- a/packages/astro/src/content/types-generator.ts +++ b/packages/astro/src/content/types-generator.ts @@ -1,5 +1,5 @@ import glob from 'fast-glob'; -import { cyan } from 'kleur/colors'; +import { bold, cyan } from 'kleur/colors'; import type fsMod from 'node:fs'; import * as path from 'node:path'; import { fileURLToPath, pathToFileURL } from 'node:url'; @@ -56,13 +56,6 @@ type CreateContentGeneratorParams = { fs: typeof fsMod; }; -type EventOpts = { logLevel: 'info' | 'warn' }; - -type EventWithOptions = { - type: ContentEvent; - opts: EventOpts | undefined; -}; - class UnsupportedFileTypeError extends Error {} export async function createContentTypesGenerator({ @@ -78,7 +71,7 @@ export async function createContentTypesGenerator({ const contentEntryExts = [...contentEntryConfigByExt.keys()]; const dataEntryExts = getDataEntryExts(settings); - let events: EventWithOptions[] = []; + let events: ContentEvent[] = []; let debounceTimeout: NodeJS.Timeout | undefined; const typeTemplateContent = await fs.promises.readFile(contentPaths.typesTemplate, 'utf-8'); @@ -90,10 +83,7 @@ export async function createContentTypesGenerator({ return { typesGenerated: false, reason: 'no-content-dir' }; } - events.push({ - type: { name: 'add', entry: contentPaths.config.url }, - opts: { logLevel: 'warn' }, - }); + events.push({ name: 'add', entry: contentPaths.config.url }); const globResult = await glob('**', { cwd: fileURLToPath(contentPaths.contentDir), @@ -110,12 +100,9 @@ export async function createContentTypesGenerator({ const entryURL = pathToFileURL(fullPath); if (entryURL.href.startsWith(contentPaths.config.url.href)) continue; if (entry.dirent.isFile()) { - events.push({ - type: { name: 'add', entry: entryURL }, - opts: { logLevel: 'warn' }, - }); + events.push({ name: 'add', entry: entryURL }); } else if (entry.dirent.isDirectory()) { - events.push({ type: { name: 'addDir', entry: entryURL }, opts: { logLevel: 'warn' } }); + events.push({ name: 'addDir', entry: entryURL }); } } await runEvents(); @@ -123,11 +110,8 @@ export async function createContentTypesGenerator({ } async function handleEvent( - event: ContentEvent, - opts?: EventOpts + event: ContentEvent ): Promise<{ shouldGenerateTypes: boolean; error?: Error }> { - const logLevel = opts?.logLevel ?? 'info'; - if (event.name === 'addDir' || event.name === 'unlinkDir') { const collection = normalizePath( path.relative(fileURLToPath(contentPaths.contentDir), fileURLToPath(event.entry)) @@ -140,9 +124,7 @@ export async function createContentTypesGenerator({ switch (event.name) { case 'addDir': collectionEntryMap[JSON.stringify(collection)] = { type: 'unknown', entries: {} }; - if (logLevel === 'info') { - logger.info('content', `${cyan(collection)} collection added`); - } + logger.debug('content', `${cyan(collection)} collection added`); break; case 'unlinkDir': if (collectionKey in collectionEntryMap) { @@ -186,16 +168,14 @@ export async function createContentTypesGenerator({ const collection = getEntryCollectionName({ entry, contentDir }); if (collection === undefined) { - if (['info', 'warn'].includes(logLevel)) { - logger.warn( - 'content', - `${cyan( - normalizePath( - path.relative(fileURLToPath(contentPaths.contentDir), fileURLToPath(event.entry)) - ) - )} must be nested in a collection directory. Skipping.` - ); - } + logger.warn( + 'content', + `${bold( + normalizePath( + path.relative(fileURLToPath(contentPaths.contentDir), fileURLToPath(event.entry)) + ) + )} must live in a ${bold('content/...')} collection subdirectory.` + ); return { shouldGenerateTypes: false }; } @@ -308,22 +288,19 @@ export async function createContentTypesGenerator({ } } - function queueEvent(rawEvent: RawContentEvent, opts?: EventOpts) { + function queueEvent(rawEvent: RawContentEvent) { const event = { - type: { - entry: pathToFileURL(rawEvent.entry), - name: rawEvent.name, - }, - opts, + entry: pathToFileURL(rawEvent.entry), + name: rawEvent.name, }; - if (!event.type.entry.pathname.startsWith(contentPaths.contentDir.pathname)) return; + if (!event.entry.pathname.startsWith(contentPaths.contentDir.pathname)) return; events.push(event); debounceTimeout && clearTimeout(debounceTimeout); const runEventsSafe = async () => { try { - await runEvents(opts); + await runEvents(); } catch { // Prevent frontmatter errors from crashing the server. The errors // are still reported on page reflects as desired. @@ -333,30 +310,25 @@ export async function createContentTypesGenerator({ debounceTimeout = setTimeout(runEventsSafe, 50 /* debounce to batch chokidar events */); } - async function runEvents(opts?: EventOpts) { - const logLevel = opts?.logLevel ?? 'info'; + async function runEvents() { const eventResponses = []; for (const event of events) { - const response = await handleEvent(event.type, event.opts); + const response = await handleEvent(event); eventResponses.push(response); } events = []; - let unsupportedFiles = []; for (const response of eventResponses) { if (response.error instanceof UnsupportedFileTypeError) { - unsupportedFiles.push(response.error.message); + logger.warn( + 'content', + `Unsupported file type ${bold( + response.error.message + )} found. Prefix filename with an underscore (\`_\`) to ignore.` + ); } } - if (unsupportedFiles.length > 0 && ['info', 'warn'].includes(logLevel)) { - logger.warn( - 'content', - `Unsupported file types found. Prefix with an underscore (\`_\`) to ignore:\n- ${unsupportedFiles.join( - '\n' - )}` - ); - } const observable = contentConfigObserver.get(); if (eventResponses.some((r) => r.shouldGenerateTypes)) { await writeContentFiles({ @@ -369,7 +341,7 @@ export async function createContentTypesGenerator({ viteServer, }); invalidateVirtualMod(viteServer); - if (observable.status === 'loaded' && ['info', 'warn'].includes(logLevel)) { + if (observable.status === 'loaded') { warnNonexistentCollections({ logger, contentConfig: observable.config, @@ -475,6 +447,7 @@ async function writeContentFiles({ let configPathRelativeToCacheDir = normalizePath( path.relative(contentPaths.cacheDir.pathname, contentPaths.config.url.pathname) ); + if (!isRelativePath(configPathRelativeToCacheDir)) configPathRelativeToCacheDir = './' + configPathRelativeToCacheDir; @@ -514,9 +487,9 @@ function warnNonexistentCollections({ if (!collectionEntryMap[JSON.stringify(configuredCollection)]) { logger.warn( 'content', - `The ${JSON.stringify( - configuredCollection - )} collection does not have an associated folder in your \`content\` directory. Make sure the folder exists, or check your content config for typos.` + `The ${bold(configuredCollection)} collection is defined but no ${bold( + 'content/' + configuredCollection + )} folder exists in the content directory. Create a new folder for the collection, or check your content configuration file for typos.` ); } } diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index f069c3477..23ecba837 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -198,7 +198,7 @@ export class App { if (err instanceof EndpointNotFoundError) { return this.#renderError(request, { status: 404, response: err.originalResponse }); } else { - this.#logger.error('ssr', err.stack || err.message || String(err)); + this.#logger.error(null, err.stack || err.message || String(err)); return this.#renderError(request, { status: 500 }); } } diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index 35f8ecb66..3ffd13b7d 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -1,11 +1,9 @@ -import * as colors from 'kleur/colors'; -import { bgGreen, black, cyan, dim, green, magenta } from 'kleur/colors'; +import { bgGreen, black, blue, bold, dim, green, magenta, red } from 'kleur/colors'; import fs from 'node:fs'; import os from 'node:os'; import { fileURLToPath } from 'node:url'; import PQueue from 'p-queue'; import type { OutputAsset, OutputChunk } from 'rollup'; -import type { BufferEncoding } from 'vfile'; import type { AstroSettings, ComponentInstance, @@ -149,7 +147,7 @@ export function chunkIsPage( } export async function generatePages(opts: StaticBuildOptions, internals: BuildInternals) { - const timer = performance.now(); + const generatePagesTimer = performance.now(); const ssr = isServerLikeOutput(opts.settings.config); let manifest: SSRManifest; if (ssr) { @@ -179,7 +177,7 @@ export async function generatePages(opts: StaticBuildOptions, internals: BuildIn } const verb = ssr ? 'prerendering' : 'generating'; - logger.info(null, `\n${bgGreen(black(` ${verb} static routes `))}`); + logger.info('SKIP_FORMAT', `\n${bgGreen(black(` ${verb} static routes `))}`); const builtPaths = new Set<string>(); const pagesToGenerate = pipeline.retrieveRoutesToGenerate(); if (ssr) { @@ -223,12 +221,14 @@ export async function generatePages(opts: StaticBuildOptions, internals: BuildIn } } } - - logger.info(null, dim(`Completed in ${getTimeStat(timer, performance.now())}.\n`)); + logger.info( + null, + green(`✓ Completed in ${getTimeStat(generatePagesTimer, performance.now())}.\n`) + ); const staticImageList = getStaticImageList(); if (staticImageList.size) { - logger.info(null, `\n${bgGreen(black(` generating optimized images `))}`); + logger.info('SKIP_FORMAT', `${bgGreen(black(` generating optimized images `))}`); const totalCount = Array.from(staticImageList.values()) .map((x) => x.transforms.size) @@ -244,7 +244,10 @@ export async function generatePages(opts: StaticBuildOptions, internals: BuildIn await queue.onIdle(); const assetsTimeEnd = performance.now(); - logger.info(null, dim(`Completed in ${getTimeStat(assetsTimer, assetsTimeEnd)}.\n`)); + logger.info( + null, + green(`✓ Completed in ${getTimeStat(assetsTimer, assetsTimeEnd)}.\n`) + ); delete globalThis?.astroAsset?.addStaticImage; } @@ -299,11 +302,11 @@ async function generatePage( ); } const pageModule = await pageModulePromise(); + // TODO: Remove in Astro 4.0 if (shouldSkipDraft(pageModule, pipeline.getSettings())) { logger.info(null, `${magenta('⚠️')} Skipping draft ${pageData.route.component}`); - // TODO: Remove in Astro 4.0 logger.warn( - 'astro', + null, `The drafts feature is deprecated. You should migrate to content collections instead. See https://docs.astro.build/en/guides/content-collections/#filtering-collection-queries for more information.` ); return; @@ -321,7 +324,7 @@ async function generatePage( pageData.route.type === 'page' || pageData.route.type === 'redirect' || pageData.route.type === 'fallback' - ? green('▶') + ? blue('▶') : magenta('λ'); if (isRelativePath(pageData.route.component)) { logger.info(null, `${icon} ${pageData.route.route}`); @@ -341,10 +344,10 @@ async function generatePage( await generatePath(path, generationOptions, pipeline); const timeEnd = performance.now(); const timeChange = getTimeStat(prevTimeEnd, timeEnd); - const timeIncrease = `(+${timeChange})`; + const timeIncrease = `(${timeChange})`; const filePath = getOutputFilename(pipeline.getConfig(), path, pageData.route.type); const lineIcon = i === paths.length - 1 ? '└─' : '├─'; - logger.info(null, ` ${cyan(lineIcon)} ${dim(filePath)} ${dim(timeIncrease)}`); + logger.info(null, ` ${blue(lineIcon)} ${dim(filePath)} ${dim(timeIncrease)}`); prevTimeEnd = timeEnd; } } @@ -383,17 +386,17 @@ async function getPathsForRoute( logger, ssr: isServerLikeOutput(opts.settings.config), }).catch((err) => { - logger.debug('build', `├── ${colors.bold(colors.red('✗'))} ${route.component}`); + logger.debug('build', `├── ${bold(red('✗'))} ${route.component}`); throw err; }); - const label = staticPaths.length === 1 ? 'page' : 'pages'; - logger.debug( - 'build', - `├── ${colors.bold(colors.green('✔'))} ${route.component} → ${colors.magenta( - `[${staticPaths.length} ${label}]` - )}` - ); + const label = staticPaths.length === 1 ? 'page' : 'pages'; + logger.debug( + 'build', + `├── ${bold(green('✔'))} ${route.component} → ${magenta( + `[${staticPaths.length} ${label}]` + )}` + ); paths.push( ...staticPaths diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index f096b8f76..19f263a01 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -1,4 +1,4 @@ -import * as colors from 'kleur/colors'; +import { blue, bold, green } from 'kleur/colors'; import fs from 'node:fs'; import { performance } from 'node:perf_hooks'; import { fileURLToPath } from 'node:url'; @@ -69,8 +69,9 @@ export default async function build( if (astroConfig.experimental.contentCollectionCache && options.force) { const contentCacheDir = new URL('./content/', astroConfig.cacheDir); if (fs.existsSync(contentCacheDir)) { - logger.warn('content', 'clearing cache'); + logger.debug('content', 'clearing content cache'); await fs.promises.rm(contentCacheDir, { force: true, recursive: true }); + logger.warn('content', 'content cache cleared (force)'); } } @@ -157,9 +158,10 @@ class AstroBuilder { await runHookBuildStart({ config: this.settings.config, logging: this.logger }); this.validateConfig(); - this.logger.info('build', `output target: ${colors.green(this.settings.config.output)}`); + this.logger.info('build', `output: ${blue('"' + this.settings.config.output + '"')}`); + this.logger.info('build', `directory: ${blue(fileURLToPath(this.settings.config.outDir))}`); if (this.settings.adapter) { - this.logger.info('build', `deploy adapter: ${colors.green(this.settings.adapter.name)}`); + this.logger.info('build', `adapter: ${green(this.settings.adapter.name)}`); } this.logger.info('build', 'Collecting build info...'); this.timer.loadStart = performance.now(); @@ -179,7 +181,7 @@ class AstroBuilder { this.timer.buildStart = performance.now(); this.logger.info( 'build', - colors.dim(`Completed in ${getTimeStat(this.timer.init, performance.now())}.`) + green(`✓ Completed in ${getTimeStat(this.timer.init, performance.now())}.`) ); const opts: StaticBuildOptions = { @@ -252,27 +254,28 @@ class AstroBuilder { ); } + // TODO: Remove in Astro 4.0 if (config.build.split === true) { if (config.output === 'static') { this.logger.warn( - 'configuration', + 'config', 'The option `build.split` won\'t take effect, because `output` is not `"server"` or `"hybrid"`.' ); } this.logger.warn( - 'configuration', + 'deprecated', 'The option `build.split` is deprecated. Use the adapter options.' ); } if (config.build.excludeMiddleware === true) { if (config.output === 'static') { this.logger.warn( - 'configuration', + 'config', 'The option `build.excludeMiddleware` won\'t take effect, because `output` is not `"server"` or `"hybrid"`.' ); } this.logger.warn( - 'configuration', + 'deprecated', 'The option `build.excludeMiddleware` is deprecated. Use the adapter options.' ); } @@ -294,12 +297,12 @@ class AstroBuilder { let messages: string[] = []; if (buildMode === 'static') { - messages = [`${pageCount} page(s) built in`, colors.bold(total)]; + messages = [`${pageCount} page(s) built in`, bold(total)]; } else { - messages = ['Server built in', colors.bold(total)]; + messages = ['Server built in', bold(total)]; } logger.info('build', messages.join(' ')); - logger.info('build', `${colors.bold('Complete!')}`); + logger.info('build', `${bold('Complete!')}`); } } diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index c54de6b44..2580e585e 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -1,7 +1,7 @@ import { teardown } from '@astrojs/compiler'; import * as eslexer from 'es-module-lexer'; import glob from 'fast-glob'; -import { bgGreen, bgMagenta, black, dim } from 'kleur/colors'; +import { bgGreen, bgMagenta, black, green } from 'kleur/colors'; import fs from 'node:fs'; import path, { extname } from 'node:path'; import { fileURLToPath, pathToFileURL } from 'node:url'; @@ -78,7 +78,8 @@ export async function viteBuild(opts: StaticBuildOptions) { const ssrTime = performance.now(); opts.logger.info('build', `Building ${settings.config.output} entrypoints...`); const ssrOutput = await ssrBuild(opts, internals, pageInput, container); - opts.logger.info('build', dim(`Completed in ${getTimeStat(ssrTime, performance.now())}.`)); + opts.logger.info('build', green(`✓ Completed in ${getTimeStat(ssrTime, performance.now())}.`)); + settings.timer.end('SSR build'); settings.timer.start('Client build'); @@ -268,7 +269,6 @@ async function clientBuild( container: AstroBuildPluginContainer ) { const { settings, viteConfig } = opts; - const timer = performance.now(); const ssr = isServerLikeOutput(settings.config); const out = ssr ? settings.config.build.client : getOutDirWithinCwd(settings.config.outDir); @@ -283,7 +283,7 @@ async function clientBuild( } const { lastVitePlugins, vitePlugins } = await container.runBeforeHook('client', input); - opts.logger.info(null, `\n${bgGreen(black(' building client '))}`); + opts.logger.info('SKIP_FORMAT', `\n${bgGreen(black(' building client (vite) '))}`); const viteBuildConfig: vite.InlineConfig = { ...viteConfig, @@ -322,7 +322,6 @@ async function clientBuild( }); const buildResult = await vite.build(viteBuildConfig); - opts.logger.info(null, dim(`Completed in ${getTimeStat(timer, performance.now())}.\n`)); return buildResult; } diff --git a/packages/astro/src/core/build/util.ts b/packages/astro/src/core/build/util.ts index e46a0713a..fc12b486f 100644 --- a/packages/astro/src/core/build/util.ts +++ b/packages/astro/src/core/build/util.ts @@ -2,7 +2,7 @@ import type { AstroConfig } from '../../@types/astro.js'; export function getTimeStat(timeStart: number, timeEnd: number) { const buildTime = timeEnd - timeStart; - return buildTime < 750 ? `${Math.round(buildTime)}ms` : `${(buildTime / 1000).toFixed(2)}s`; + return buildTime < 1000 ? `${Math.round(buildTime)}ms` : `${(buildTime / 1000).toFixed(2)}s`; } /** diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index de6443729..c9716af89 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -1,10 +1,9 @@ -import type { AstroSettings } from '../@types/astro.js'; -import type { Logger } from './logger/core.js'; - import nodeFs from 'node:fs'; import { fileURLToPath } from 'node:url'; +import type { Logger as ViteLogger } from 'vite'; import * as vite from 'vite'; import { crawlFrameworkPkgs } from 'vitefu'; +import type { AstroSettings } from '../@types/astro.js'; import astroAssetsPlugin from '../assets/vite-plugin-assets.js'; import { astroContentAssetPropagationPlugin, @@ -31,6 +30,7 @@ import astroScannerPlugin from '../vite-plugin-scanner/index.js'; import astroScriptsPlugin from '../vite-plugin-scripts/index.js'; import astroScriptsPageSSRPlugin from '../vite-plugin-scripts/page-ssr.js'; import { vitePluginSSRManifest } from '../vite-plugin-ssr-manifest/index.js'; +import type { Logger } from './logger/core.js'; import { vitePluginMiddleware } from './middleware/vite-plugin.js'; import { joinPaths } from './path.js'; @@ -102,6 +102,17 @@ export async function createVite( }, }); + const viteCustomLogger: ViteLogger = { + ...vite.createLogger('warn'), + // All error log messages are also thrown as real errors, + // so we can safely ignore them here and let the error handler + // log them for the user instead. + error: (msg) => logger.debug('vite', 'ERROR ' + msg), + // Warnings are usually otherwise ignored by Vite, so it's + // important that we catch and log them here. + warn: (msg) => logger.warn('vite', msg), + }; + // Start with the Vite configuration that Astro core needs const commonConfig: vite.InlineConfig = { // Tell Vite not to combine config from vite.config.js with our provided inline config @@ -109,6 +120,7 @@ export async function createVite( cacheDir: fileURLToPath(new URL('./node_modules/.vite/', settings.config.root)), // using local caches allows Astro to be used in monorepos, etc. clearScreen: false, // we want to control the output, not Vite logLevel: 'warn', // log warnings and errors only + customLogger: viteCustomLogger, appType: 'custom', optimizeDeps: { entries: ['src/**/*'], @@ -180,7 +192,7 @@ export async function createVite( }, { find: 'astro:middleware', - replacement: 'astro/middleware/namespace', + replacement: 'astro/virtual-modules/middleware.js', }, { find: 'astro:components', diff --git a/packages/astro/src/core/dev/dev.ts b/packages/astro/src/core/dev/dev.ts index 02ba9d872..f8db6647e 100644 --- a/packages/astro/src/core/dev/dev.ts +++ b/packages/astro/src/core/dev/dev.ts @@ -9,6 +9,7 @@ import { telemetry } from '../../events/index.js'; import * as msg from '../messages.js'; import { startContainer } from './container.js'; import { createContainerWithAutomaticRestart } from './restart.js'; +import { green } from 'kleur/colors'; export interface DevServer { address: AddressInfo; @@ -33,9 +34,8 @@ export default async function dev(inlineConfig: AstroInlineConfig): Promise<DevS // Start listening to the port const devServerAddressInfo = await startContainer(restart.container); - logger.info( - null, + 'SKIP_FORMAT', msg.serverStart({ startupTime: performance.now() - devStart, resolvedUrls: restart.container.viteServer.resolvedUrls || { local: [], network: [] }, @@ -43,17 +43,20 @@ export default async function dev(inlineConfig: AstroInlineConfig): Promise<DevS base: restart.container.settings.config.base, }) ); + const currentVersion = process.env.PACKAGE_VERSION ?? '0.0.0'; if (currentVersion.includes('-')) { - logger.warn(null, msg.prerelease({ currentVersion })); + logger.warn('SKIP_FORMAT', msg.prerelease({ currentVersion })); } if (restart.container.viteServer.config.server?.fs?.strict === false) { - logger.warn(null, msg.fsStrictWarning()); + logger.warn('SKIP_FORMAT', msg.fsStrictWarning()); } await attachContentServerListeners(restart.container); + logger.info(null, green('watching for file changes...')); + return { address: devServerAddressInfo, get watcher() { diff --git a/packages/astro/src/core/dev/restart.ts b/packages/astro/src/core/dev/restart.ts index f03db39cf..137dde5df 100644 --- a/packages/astro/src/core/dev/restart.ts +++ b/packages/astro/src/core/dev/restart.ts @@ -82,7 +82,7 @@ export async function restartContainer(container: Container): Promise<Container }, }); container.restartInFlight = false; - logger.error('astro', 'Continuing with previous valid configuration\n'); + logger.error(null, 'Continuing with previous valid configuration\n'); return error; } } @@ -121,8 +121,8 @@ export async function createContainerWithAutomaticRestart({ }, }; - async function handleServerRestart(logMsg: string) { - logger.info('astro', logMsg + '\n'); + async function handleServerRestart(logMsg = '') { + logger.info(null, (logMsg + ' Restarting...').trim()); const container = restart.container; const result = await restartContainer(container); if (result instanceof Error) { @@ -150,13 +150,13 @@ export async function createContainerWithAutomaticRestart({ // Set up watches function addWatches() { const watcher = restart.container.viteServer.watcher; - watcher.on('change', handleChangeRestart('Configuration updated. Restarting...')); - watcher.on('unlink', handleChangeRestart('Configuration removed. Restarting...')); - watcher.on('add', handleChangeRestart('Configuration added. Restarting...')); + watcher.on('change', handleChangeRestart('Configuration file updated.')); + watcher.on('unlink', handleChangeRestart('Configuration file removed.')); + watcher.on('add', handleChangeRestart('Configuration file added.')); // Restart the Astro dev server instead of Vite's when the API is called by plugins. // Ignore the `forceOptimize` parameter for now. - restart.container.viteServer.restart = () => handleServerRestart('Restarting...'); + restart.container.viteServer.restart = () => handleServerRestart(); } addWatches(); return restart; diff --git a/packages/astro/src/core/endpoint/index.ts b/packages/astro/src/core/endpoint/index.ts index 80af2358d..f9c61d053 100644 --- a/packages/astro/src/core/endpoint/index.ts +++ b/packages/astro/src/core/endpoint/index.ts @@ -204,7 +204,7 @@ export async function callEndpoint<MiddlewareResult = Response | EndpointOutput> if (response instanceof Response) { if (isEndpointSSR && response.headers.get('X-Astro-Encoding')) { env.logger.warn( - 'ssr', + null, '`ResponseWithEncoding` is ignored in SSR. Please return an instance of Response. See https://docs.astro.build/en/core-concepts/endpoints/#server-endpoints-api-routes for more information.' ); } @@ -216,21 +216,21 @@ export async function callEndpoint<MiddlewareResult = Response | EndpointOutput> // TODO: Remove in Astro 4.0 env.logger.warn( - 'astro', + null, `${ctx.route.component} returns a simple object which is deprecated. Please return an instance of Response. See https://docs.astro.build/en/core-concepts/endpoints/#server-endpoints-api-routes for more information.` ); if (isEndpointSSR) { if (response.hasOwnProperty('headers')) { env.logger.warn( - 'ssr', + null, 'Setting headers is not supported when returning an object. Please return an instance of Response. See https://docs.astro.build/en/core-concepts/endpoints/#server-endpoints-api-routes for more information.' ); } if (response.encoding) { env.logger.warn( - 'ssr', + null, '`encoding` is ignored in SSR. To return a charset other than UTF-8, please return an instance of Response. See https://docs.astro.build/en/core-concepts/endpoints/#server-endpoints-api-routes for more information.' ); } diff --git a/packages/astro/src/core/errors/dev/vite.ts b/packages/astro/src/core/errors/dev/vite.ts index b3e49234d..7d67806f8 100644 --- a/packages/astro/src/core/errors/dev/vite.ts +++ b/packages/astro/src/core/errors/dev/vite.ts @@ -83,7 +83,6 @@ export function enhanceViteSSRError({ if (globPattern) { safeError.message = InvalidGlob.message(globPattern); safeError.name = 'InvalidGlob'; - safeError.hint = InvalidGlob.hint; safeError.title = InvalidGlob.title; const line = lns.findIndex((ln) => ln.includes(globPattern)); diff --git a/packages/astro/src/core/logger/console.ts b/packages/astro/src/core/logger/console.ts index f39f6b74d..d55318d4c 100644 --- a/packages/astro/src/core/logger/console.ts +++ b/packages/astro/src/core/logger/console.ts @@ -1,10 +1,6 @@ -import { bold, cyan, dim, red, reset, yellow } from 'kleur/colors'; -import type { LogMessage } from './core.js'; -import { dateTimeFormat, levels } from './core.js'; +import { getEventPrefix, levels, type LogMessage, type LogWritable } from './core.js'; -let lastMessage: string; -let lastMessageCount = 1; -export const consoleLogDestination = { +export const consoleLogDestination: LogWritable<LogMessage> = { write(event: LogMessage) { // eslint-disable-next-line no-console let dest = console.error; @@ -12,37 +8,11 @@ export const consoleLogDestination = { // eslint-disable-next-line no-console dest = console.log; } - - function getPrefix() { - let prefix = ''; - let type = event.label; - if (type) { - // hide timestamp when type is undefined - prefix += dim(dateTimeFormat.format(new Date()) + ' '); - if (event.level === 'info') { - type = bold(cyan(`[${type}]`)); - } else if (event.level === 'warn') { - type = bold(yellow(`[${type}]`)); - } else if (event.level === 'error') { - type = bold(red(`[${type}]`)); - } - - prefix += `${type} `; - } - return reset(prefix); - } - - let message = event.message; - // For repeat messages, only update the message counter - if (message === lastMessage) { - lastMessageCount++; - message = `${message} ${yellow(`(x${lastMessageCount})`)}`; + if (event.label === 'SKIP_FORMAT') { + dest(event.message); } else { - lastMessage = message; - lastMessageCount = 1; + dest(getEventPrefix(event) + ' ' + event.message); } - const outMessage = getPrefix() + message; - dest(outMessage); return true; }, }; diff --git a/packages/astro/src/core/logger/core.ts b/packages/astro/src/core/logger/core.ts index 11804dd01..5d617a1a2 100644 --- a/packages/astro/src/core/logger/core.ts +++ b/packages/astro/src/core/logger/core.ts @@ -1,12 +1,34 @@ -import { dim } from 'kleur/colors'; +import { blue, bold, dim, red, yellow } from 'kleur/colors'; import stringWidth from 'string-width'; -interface LogWritable<T> { +export interface LogWritable<T> { write: (chunk: T) => boolean; } export type LoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent'; // same as Pino +/** + * Defined logger labels. Add more as needed, but keep them high-level & reusable, + * rather than specific to a single command, function, use, etc. The label will be + * shown in the log message to the user, so it should be relevant. + */ +export type LoggerLabel = + | 'add' + | 'build' + | 'check' + | 'config' + | 'content' + | 'deprecated' + | 'markdown' + | 'router' + | 'types' + | 'vite' + | 'watch' + | 'middleware' + // SKIP_FORMAT: A special label that tells the logger not to apply any formatting. + // Useful for messages that are already formatted, like the server start message. + | 'SKIP_FORMAT'; + export interface LogOptions { dest: LogWritable<LogMessage>; level: LoggerLevel; @@ -25,6 +47,7 @@ export const dateTimeFormat = new Intl.DateTimeFormat([], { hour: '2-digit', minute: '2-digit', second: '2-digit', + hour12: false, }); export interface LogMessage { @@ -98,6 +121,35 @@ function padStr(str: string, len: number) { return str + spaces; } +/** + * Get the prefix for a log message. + * This includes the timestamp, log level, and label all properly formatted + * with colors. This is shared across different loggers, so it's defined here. + */ +export function getEventPrefix({ level, label }: LogMessage) { + const timestamp = `${dateTimeFormat.format(new Date())}`; + const prefix = []; + if (level === 'error' || level === 'warn') { + prefix.push(bold(timestamp)); + prefix.push(`[${level.toUpperCase()}]`); + } else { + prefix.push(timestamp); + } + if (label) { + prefix.push(`[${label}]`); + } + if (level === 'error') { + return red(prefix.join(' ')); + } + if (level === 'warn') { + return yellow(prefix.join(' ')); + } + if (prefix.length === 1) { + return dim(prefix[0]); + } + return dim(prefix[0]) + ' ' + blue(prefix.splice(1).join(' ')); +} + export let defaultLogLevel: LoggerLevel; if (typeof process !== 'undefined') { // This could be a shimmed environment so we don't know that `process` is the full @@ -133,16 +185,16 @@ export class Logger { this.options = options; } - info(label: string | null, message: string) { + info(label: LoggerLabel | null, message: string) { info(this.options, label, message); } - warn(label: string | null, message: string) { + warn(label: LoggerLabel | null, message: string) { warn(this.options, label, message); } - error(label: string | null, message: string) { + error(label: LoggerLabel | null, message: string) { error(this.options, label, message); } - debug(label: string | null, ...messages: any[]) { + debug(label: LoggerLabel, ...messages: any[]) { debug(label, ...messages); } diff --git a/packages/astro/src/core/logger/node.ts b/packages/astro/src/core/logger/node.ts index 57aa59ed0..801df32f5 100644 --- a/packages/astro/src/core/logger/node.ts +++ b/packages/astro/src/core/logger/node.ts @@ -1,113 +1,35 @@ import debugPackage from 'debug'; -import { bold, cyan, dim, red, reset, yellow } from 'kleur/colors'; -import * as readline from 'node:readline'; import { Writable } from 'node:stream'; -import stringWidth from 'string-width'; -import { dateTimeFormat, error, info, warn } from './core.js'; +import { getEventPrefix, levels, type LogMessage, type LogWritable } from './core.js'; type ConsoleStream = Writable & { fd: 1 | 2; }; -let lastMessage: string; -let lastMessageCount = 1; -export const nodeLogDestination = new Writable({ - objectMode: true, - write(event: LogMessage, _, callback) { +export const nodeLogDestination: LogWritable<LogMessage> = { + write(event: LogMessage) { let dest: ConsoleStream = process.stderr; if (levels[event.level] < levels['error']) { dest = process.stdout; } - - function getPrefix() { - let prefix = ''; - let label = event.label; - if (label) { - // hide timestamp when type is undefined - prefix += dim(dateTimeFormat.format(new Date()) + ' '); - if (event.level === 'info') { - label = bold(cyan(`[${label}]`)); - } else if (event.level === 'warn') { - label = bold(yellow(`[${label}]`)); - } else if (event.level === 'error') { - label = bold(red(`[${label}]`)); - } - - prefix += `${label} `; - } - return reset(prefix); - } - - // console.log({msg: event.message, args: event.args}); - let message = event.message; - // For repeat messages, only update the message counter - if (message === lastMessage) { - lastMessageCount++; - if (levels[event.level] < levels['error']) { - let lines = 1; - let len = stringWidth(`${getPrefix()}${message}`); - let cols = (dest as unknown as typeof process.stdout).columns; - if (len > cols) { - lines = Math.ceil(len / cols); - } - for (let i = 0; i < lines; i++) { - readline.clearLine(dest, 0); - readline.cursorTo(dest, 0); - readline.moveCursor(dest, 0, -1); - } - } - message = `${message} ${yellow(`(x${lastMessageCount})`)}`; + if (event.label === 'SKIP_FORMAT') { + dest.write(event.message + '\n'); } else { - lastMessage = message; - lastMessageCount = 1; + dest.write(getEventPrefix(event) + ' ' + event.message + '\n'); } - - dest.write(getPrefix()); - dest.write(message); - dest.write('\n'); - callback(); + return true; }, -}); - -interface LogWritable<T> { - write: (chunk: T) => boolean; -} - -export type LoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent'; // same as Pino -export type LoggerEvent = 'info' | 'warn' | 'error'; - -export interface LogOptions { - dest?: LogWritable<LogMessage>; - level?: LoggerLevel; -} - -export const nodeLogOptions: Required<LogOptions> = { - dest: nodeLogDestination, - level: 'info', -}; - -export interface LogMessage { - label: string | null; - level: LoggerLevel; - message: string; -} - -export const levels: Record<LoggerLevel, number> = { - debug: 20, - info: 30, - warn: 40, - error: 50, - silent: 90, }; const debuggers: Record<string, debugPackage.Debugger['log']> = {}; + /** * Emit a message only shown in debug mode. * Astro (along with many of its dependencies) uses the `debug` package for debug logging. * You can enable these logs with the `DEBUG=astro:*` environment variable. * More info https://github.com/debug-js/debug#environment-variables */ -export function debug(type: string, ...messages: Array<any>) { +function debug(type: string, ...messages: Array<any>) { const namespace = `astro:${type}`; debuggers[namespace] = debuggers[namespace] || debugPackage(namespace); return debuggers[namespace](...messages); @@ -116,13 +38,6 @@ export function debug(type: string, ...messages: Array<any>) { // This is gross, but necessary since we are depending on globals. (globalThis as any)._astroGlobalDebug = debug; -// A default logger for when too lazy to pass LogOptions around. -export const logger = { - info: info.bind(null, nodeLogOptions), - warn: warn.bind(null, nodeLogOptions), - error: error.bind(null, nodeLogOptions), -}; - export function enableVerboseLogging() { debugPackage.enable('*,-babel'); debug('cli', '--verbose flag enabled! Enabling: DEBUG="*,-babel"'); diff --git a/packages/astro/src/core/messages.ts b/packages/astro/src/core/messages.ts index 758f5e581..7c1d663c5 100644 --- a/packages/astro/src/core/messages.ts +++ b/packages/astro/src/core/messages.ts @@ -1,10 +1,10 @@ import { - bgCyan, bgGreen, bgRed, bgWhite, bgYellow, black, + blue, bold, cyan, dim, @@ -22,36 +22,29 @@ import { CompilerError, type ErrorWithMetadata, } from './errors/index.js'; -import { emoji, padMultilineString } from './util.js'; - -const PREFIX_PADDING = 6; +import { padMultilineString } from './util.js'; /** Display */ export function req({ url, + method, statusCode, reqTime, }: { url: string; statusCode: number; + method?: string; reqTime?: number; }): string { - let color = dim; - if (statusCode >= 500) color = red; - else if (statusCode >= 400) color = yellow; - else if (statusCode >= 300) color = dim; - else if (statusCode >= 200) color = green; - return `${bold(color(`${statusCode}`.padStart(PREFIX_PADDING)))} ${url.padStart(40)} ${ - reqTime ? dim(Math.round(reqTime) + 'ms') : '' - }`.trim(); -} - -export function reload({ file }: { file: string }): string { - return `${green('reload'.padStart(PREFIX_PADDING))} ${file}`; -} - -export function hmr({ file, style = false }: { file: string; style?: boolean }): string { - return `${green('update'.padStart(PREFIX_PADDING))} ${file}${style ? ` ${dim('style')}` : ''}`; + const color = statusCode >= 400 ? red : statusCode >= 300 ? yellow : blue; + return ( + color(`[${statusCode}]`) + + ` ` + + (method && method !== 'GET' ? color(method) + ' ' : '') + + url + + ` ` + + (reqTime ? dim(Math.round(reqTime) + 'ms') : '') + ); } /** Display server host and startup time */ @@ -60,13 +53,11 @@ export function serverStart({ resolvedUrls, host, base, - isRestart = false, }: { startupTime: number; resolvedUrls: ResolvedServerUrls; host: string | boolean; base: string; - isRestart?: boolean; }): string { // PACKAGE_VERSION is injected at build-time const version = process.env.PACKAGE_VERSION ?? '0.0.0'; @@ -75,10 +66,10 @@ export function serverStart({ const emptyPrefix = ' '.repeat(11); const localUrlMessages = resolvedUrls.local.map((url, i) => { - return `${i === 0 ? localPrefix : emptyPrefix}${bold(cyan(new URL(url).origin + base))}`; + return `${i === 0 ? localPrefix : emptyPrefix}${cyan(new URL(url).origin + base)}`; }); const networkUrlMessages = resolvedUrls.network.map((url, i) => { - return `${i === 0 ? networkPrefix : emptyPrefix}${bold(cyan(new URL(url).origin + base))}`; + return `${i === 0 ? networkPrefix : emptyPrefix}${cyan(new URL(url).origin + base)}`; }); if (networkUrlMessages.length === 0) { @@ -91,58 +82,58 @@ export function serverStart({ } const messages = [ - `${emoji('🚀 ', '')}${bgGreen(black(` astro `))} ${green(`v${version}`)} ${dim( - `${isRestart ? 're' : ''}started in ${Math.round(startupTime)}ms` - )}`, + '', + `${bgGreen(bold(` astro `))} ${green(`v${version}`)} ${dim(`ready in`)} ${Math.round( + startupTime + )} ${dim('ms')}`, '', ...localUrlMessages, ...networkUrlMessages, '', ]; - return messages - .filter((msg) => typeof msg === 'string') - .map((msg) => ` ${msg}`) - .join('\n'); + return messages.filter((msg) => typeof msg === 'string').join('\n'); } -export function telemetryNotice(packageManager = 'npm') { - const headline = `${cyan('◆')} Astro collects completely anonymous usage data.`; - const why = dim(' This optional program helps shape our roadmap.'); - const disable = dim(` Run \`${packageManager} run astro telemetry disable\` to opt-out.`); - const details = ` Details: ${underline('https://astro.build/telemetry')}`; - return [headline, why, disable, details].map((v) => ' ' + v).join('\n'); +export function telemetryNotice() { + const headline = blue(`▶ Astro collects anonymous usage data.`); + const why = ' This information helps us improve Astro.'; + const disable = ` Run "astro telemetry disable" to opt-out.`; + const details = ` ${cyan(underline('https://astro.build/telemetry'))}`; + return [headline, why, disable, details].join('\n'); } export function telemetryEnabled() { - return `${green('◉')} Anonymous telemetry is now ${bgGreen(black(' enabled '))}\n ${dim( - 'Thank you for improving Astro!' - )}\n`; + return [ + green('▶ Anonymous telemetry ') + bgGreen(' enabled '), + ` Thank you for helping us improve Astro!`, + ``, + ].join('\n'); } export function telemetryDisabled() { - return `${yellow('◯')} Anonymous telemetry is now ${bgYellow(black(' disabled '))}\n ${dim( - "We won't ever record your usage data." - )}\n`; + return [ + green('▶ Anonymous telemetry ') + bgGreen(' disabled '), + ` Astro is no longer collecting anonymous usage data.`, + ``, + ].join('\n'); } export function telemetryReset() { - return `${cyan('◆')} Anonymous telemetry has been ${bgCyan(black(' reset '))}\n ${dim( - 'You may be prompted again.' - )}\n`; + return [green('▶ Anonymous telemetry preferences reset.'), ``].join('\n'); } export function fsStrictWarning() { - return yellow( - '⚠️ Serving with vite.server.fs.strict: false. Note that all files on your machine will be accessible to anyone on your network!' - ); + const title = yellow('▶ ' + `${bold('vite.server.fs.strict')} has been disabled!`); + const subtitle = ` Files on your machine are likely accessible on your network.`; + return `${title}\n${subtitle}\n`; } export function prerelease({ currentVersion }: { currentVersion: string }) { - const tag = currentVersion.split('-').slice(1).join('-').replace(/\..*$/, ''); + const tag = currentVersion.split('-').slice(1).join('-').replace(/\..*$/, '') || 'unknown'; const badge = bgYellow(black(` ${tag} `)); - const headline = yellow(`▶ This is a ${badge} prerelease build`); - const warning = ` Feedback? ${underline('https://astro.build/issues')}`; - return [headline, warning, ''].map((msg) => ` ${msg}`).join('\n'); + const title = yellow('▶ ' + `This is a ${badge} prerelease build!`); + const subtitle = ` Report issues here: ${cyan(underline('https://astro.build/issues'))}`; + return `${title}\n${subtitle}\n`; } export function success(message: string, tip?: string) { @@ -196,6 +187,7 @@ export function formatConfigErrorMessage(err: ZodError) { )}`; } + export function formatErrorMessage(err: ErrorWithMetadata, args: string[] = []): string { const isOurError = AstroError.is(err) || CompilerError.is(err) || AstroUserError.is(err); diff --git a/packages/astro/src/core/middleware/callMiddleware.ts b/packages/astro/src/core/middleware/callMiddleware.ts index 40513c152..d0a6ceca2 100644 --- a/packages/astro/src/core/middleware/callMiddleware.ts +++ b/packages/astro/src/core/middleware/callMiddleware.ts @@ -62,8 +62,9 @@ export async function callMiddleware<R>( return await Promise.resolve(middlewarePromise).then(async (value) => { if (isEndpointOutput(value)) { logger.warn( - 'middleware', - 'Using simple endpoints can cause unexpected issues in the chain of middleware functions.' + + null, + apiContext.url.pathname + + ' Using simple endpoints can cause unexpected issues in the chain of middleware functions.' + `\nIt's strongly suggested to use full ${bold('Response')} objects.` ); } diff --git a/packages/astro/src/core/middleware/namespace.ts b/packages/astro/src/core/middleware/namespace.ts deleted file mode 100644 index 55a84f666..000000000 --- a/packages/astro/src/core/middleware/namespace.ts +++ /dev/null @@ -1 +0,0 @@ -export { defineMiddleware, sequence } from './index.js'; diff --git a/packages/astro/src/core/preview/static-preview-server.ts b/packages/astro/src/core/preview/static-preview-server.ts index 937ba1c99..ba692611e 100644 --- a/packages/astro/src/core/preview/static-preview-server.ts +++ b/packages/astro/src/core/preview/static-preview-server.ts @@ -42,7 +42,7 @@ export default async function createStaticPreviewServer( }); } catch (err) { if (err instanceof Error) { - logger.error('astro', err.stack || err.message); + logger.error(null, err.stack || err.message); } throw err; } @@ -51,7 +51,7 @@ export default async function createStaticPreviewServer( // Log server start URLs logger.info( - null, + 'SKIP_FORMAT', msg.serverStart({ startupTime: performance.now() - startServerTime, resolvedUrls: previewServer.resolvedUrls ?? { local: [], network: [] }, @@ -72,8 +72,6 @@ export default async function createStaticPreviewServer( host: getResolvedHostForHttpServer(settings.config.server.host), port: settings.config.server.port, closed, - // In Vite 5, `httpServer` may be a `Http2SecureServer`, but we know we are only starting a HTTP server - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion server: previewServer.httpServer as http.Server, stop: async () => { await new Promise((resolve, reject) => { diff --git a/packages/astro/src/core/preview/vite-plugin-astro-preview.ts b/packages/astro/src/core/preview/vite-plugin-astro-preview.ts index 7f9979275..aafd69cb4 100644 --- a/packages/astro/src/core/preview/vite-plugin-astro-preview.ts +++ b/packages/astro/src/core/preview/vite-plugin-astro-preview.ts @@ -1,13 +1,13 @@ import fs from 'node:fs'; +import type { IncomingMessage, ServerResponse } from 'node:http'; import { fileURLToPath } from 'node:url'; import type { Connect, Plugin } from 'vite'; -import { version } from 'vite'; import type { AstroSettings } from '../../@types/astro.js'; import { notFoundTemplate, subpathNotUsedTemplate } from '../../template/4xx.js'; +import { cleanUrl } from '../../vite-plugin-utils/index.js'; import { stripBase } from './util.js'; const HAS_FILE_EXTENSION_REGEXP = /^.*\.[^\\]+$/; -const IS_VITE_5 = version.startsWith('5.'); export function vitePluginAstroPreview(settings: AstroSettings): Plugin { const { base, outDir, trailingSlash } = settings.config; @@ -24,8 +24,7 @@ export function vitePluginAstroPreview(settings: AstroSettings): Plugin { return; } - const strippedPathname = stripBase(req.url!, base); - const pathname = new URL(strippedPathname, 'https://a.b').pathname; + const pathname = cleanUrl(stripBase(req.url!, base)); const isRoot = pathname === '/'; // Validate trailingSlash @@ -53,29 +52,49 @@ export function vitePluginAstroPreview(settings: AstroSettings): Plugin { }); return () => { - const fourOhFourMiddleware: Connect.NextHandleFunction = (req, res) => { - const errorPagePath = fileURLToPath(outDir + '/404.html'); - if (fs.existsSync(errorPagePath)) { - res.statusCode = 404; - res.setHeader('Content-Type', 'text/html;charset=utf-8'); - res.end(fs.readFileSync(errorPagePath)); - } else { - const pathname = stripBase(req.url!, base); - res.statusCode = 404; - res.end(notFoundTemplate(pathname, 'Not Found')); - } - }; + // NOTE: the `base` is stripped from `req.url` for post middlewares - // Vite 5 has its own 404 middleware, we replace it with ours instead. - if (IS_VITE_5) { - for (const middleware of server.middlewares.stack) { - // This hardcoded name will not break between Vite versions - if ((middleware.handle as Connect.HandleFunction).name === 'vite404Middleware') { - middleware.handle = fourOhFourMiddleware; + server.middlewares.use((req, res, next) => { + const pathname = cleanUrl(req.url!); + + // Vite doesn't handle /foo/ if /foo.html exists, we handle it anyways + if (pathname.endsWith('/')) { + const pathnameWithoutSlash = pathname.slice(0, -1); + const htmlPath = fileURLToPath(outDir + pathnameWithoutSlash + '.html'); + if (fs.existsSync(htmlPath)) { + req.url = pathnameWithoutSlash + '.html'; + return next(); } } - } else { - server.middlewares.use(fourOhFourMiddleware); + // Vite doesn't handle /foo if /foo/index.html exists, we handle it anyways + else { + const htmlPath = fileURLToPath(outDir + pathname + '/index.html'); + if (fs.existsSync(htmlPath)) { + req.url = pathname + '/index.html'; + return next(); + } + } + + next(); + }); + + // Vite has its own 404 middleware, we replace it with ours instead. + for (const middleware of server.middlewares.stack) { + // This hardcoded name will not break between Vite versions + if ((middleware.handle as Connect.HandleFunction).name === 'vite404Middleware') { + // Fallback to 404 page if it exists + middleware.handle = (req: IncomingMessage, res: ServerResponse) => { + const errorPagePath = fileURLToPath(outDir + '/404.html'); + if (fs.existsSync(errorPagePath)) { + res.statusCode = 404; + res.setHeader('Content-Type', 'text/html;charset=utf-8'); + res.end(fs.readFileSync(errorPagePath)); + } else { + res.statusCode = 404; + res.end(notFoundTemplate(req.url!, 'Not Found')); + } + }; + } } }; }, diff --git a/packages/astro/src/core/render/core.ts b/packages/astro/src/core/render/core.ts index ed9ea7fdb..5b120bb07 100644 --- a/packages/astro/src/core/render/core.ts +++ b/packages/astro/src/core/render/core.ts @@ -67,7 +67,7 @@ export async function renderPage({ mod, renderContext, env, cookies }: RenderPag // TODO: Remove in Astro 4.0 if (mod.frontmatter && typeof mod.frontmatter === 'object' && 'draft' in mod.frontmatter) { env.logger.warn( - 'astro', + null, `The drafts feature is deprecated and used in ${renderContext.route.component}. You should migrate to content collections instead. See https://docs.astro.build/en/guides/content-collections/#filtering-collection-queries for more information.` ); } diff --git a/packages/astro/src/core/render/result.ts b/packages/astro/src/core/render/result.ts index e9c8302a1..2c37f38c4 100644 --- a/packages/astro/src/core/render/result.ts +++ b/packages/astro/src/core/render/result.ts @@ -100,7 +100,7 @@ class Slots { const result = this.#result; if (!Array.isArray(args)) { this.#logger.warn( - 'Astro.slots.render', + null, `Expected second parameter to be an array, received a ${typeof args}. If you're trying to pass an array as a single argument and getting unexpected results, make sure you're passing your array as a item of an array. Ex: Astro.slots.render('default', [["Hello", "World"]])` ); } else if (args.length > 0) { diff --git a/packages/astro/src/core/render/route-cache.ts b/packages/astro/src/core/render/route-cache.ts index c318b8c44..322326957 100644 --- a/packages/astro/src/core/render/route-cache.ts +++ b/packages/astro/src/core/render/route-cache.ts @@ -108,7 +108,7 @@ export class RouteCache { // isn't invisible and developer can track down the issue. if (this.mode === 'production' && this.cache[route.component]?.staticPaths) { this.logger.warn( - 'routeCache', + null, `Internal Warning: route cache overwritten. (${route.component})` ); } @@ -131,5 +131,5 @@ export function findPathItemByKey( if (matchedStaticPath) { return matchedStaticPath; } - logger.debug('findPathItemByKey', `Unexpected cache miss looking for ${paramsKey}`); + logger.debug('router', `findPathItemByKey() - Unexpected cache miss looking for ${paramsKey}`); } diff --git a/packages/astro/src/core/request.ts b/packages/astro/src/core/request.ts index f478b0a32..6d55caa15 100644 --- a/packages/astro/src/core/request.ts +++ b/packages/astro/src/core/request.ts @@ -42,7 +42,7 @@ export function createRequest({ Object.defineProperties(request, { params: { get() { - logger.warn('deprecation', `Astro.request.params has been moved to Astro.params`); + logger.warn('deprecated', `Astro.request.params has been moved to Astro.params`); return undefined; }, }, @@ -56,8 +56,8 @@ export function createRequest({ ...headersDesc, get() { logger.warn( - 'ssg', - `Headers are not exposed in static (SSG) output mode. To enable headers: set \`output: "server"\` in your config file.` + null, + `\`Astro.request.headers\` is not available in "static" output mode. To enable header access: set \`output: "server"\` or \`output: "hybrid"\` in your config file.` ); return _headers; }, diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts index 44482fdcb..9ab331504 100644 --- a/packages/astro/src/core/routing/manifest/create.ts +++ b/packages/astro/src/core/routing/manifest/create.ts @@ -8,6 +8,7 @@ import type { } from '../../../@types/astro.js'; import type { Logger } from '../../logger/core.js'; +import { bold } from 'kleur/colors'; import { createRequire } from 'module'; import nodeFs from 'node:fs'; import path from 'node:path'; @@ -234,8 +235,6 @@ export function createRouteManifest( const localFs = fsMod ?? nodeFs; const prerender = getPrerenderDefault(settings.config); - const foundInvalidFileExtensions = new Set<string>(); - function walk( fs: typeof nodeFs, dir: string, @@ -259,10 +258,12 @@ export function createRouteManifest( } // filter out "foo.astro_tmp" files, etc if (!isDir && !validPageExtensions.has(ext) && !validEndpointExtensions.has(ext)) { - if (!foundInvalidFileExtensions.has(ext)) { - foundInvalidFileExtensions.add(ext); - logger.warn('astro', `Invalid file extension for Pages: ${ext}`); - } + logger.warn( + null, + `Unsupported file type ${bold( + resolved + )} found. Prefix filename with an underscore (\`_\`) to ignore.` + ); return; } @@ -359,8 +360,7 @@ export function createRouteManifest( walk(localFs, fileURLToPath(pages), [], []); } else if (settings.injectedRoutes.length === 0) { const pagesDirRootRelative = pages.href.slice(settings.config.root.href.length); - - logger.warn('astro', `Missing pages directory: ${pagesDirRootRelative}`); + logger.warn(null, `Missing pages directory: ${pagesDirRootRelative}`); } settings.injectedRoutes diff --git a/packages/astro/src/core/routing/validation.ts b/packages/astro/src/core/routing/validation.ts index 0261c865a..b68d5f3e8 100644 --- a/packages/astro/src/core/routing/validation.ts +++ b/packages/astro/src/core/routing/validation.ts @@ -79,16 +79,16 @@ export function validateGetStaticPathsResult( for (const [key, val] of Object.entries(pathObject.params)) { if (!(typeof val === 'undefined' || typeof val === 'string' || typeof val === 'number')) { logger.warn( - 'getStaticPaths', - `invalid path param: ${key}. A string, number or undefined value was expected, but got \`${JSON.stringify( + 'router', + `getStaticPaths() returned an invalid path param: "${key}". A string, number or undefined value was expected, but got \`${JSON.stringify( val )}\`.` ); } if (typeof val === 'string' && val === '') { logger.warn( - 'getStaticPaths', - `invalid path param: ${key}. \`undefined\` expected for an optional param, but got empty string.` + 'router', + `getStaticPaths() returned an invalid path param: "${key}". \`undefined\` expected for an optional param, but got empty string.` ); } } diff --git a/packages/astro/src/core/sync/index.ts b/packages/astro/src/core/sync/index.ts index 0c7b81c3a..966454845 100644 --- a/packages/astro/src/core/sync/index.ts +++ b/packages/astro/src/core/sync/index.ts @@ -117,7 +117,7 @@ export async function syncInternal( switch (typesResult.reason) { case 'no-content-dir': default: - logger.info('content', 'No content directory found. Skipping type generation.'); + logger.debug('types', 'No content directory found. Skipping type generation.'); return 0; } } @@ -137,7 +137,7 @@ export async function syncInternal( await tempViteServer.close(); } - logger.info('content', `Types generated ${dim(getTimeStat(timerStart, performance.now()))}`); + logger.info(null, `Types generated ${dim(getTimeStat(timerStart, performance.now()))}`); await setUpEnvTs({ settings, logger, fs: fs ?? fsMod }); return 0; diff --git a/packages/astro/src/i18n/vite-plugin-i18n.ts b/packages/astro/src/i18n/vite-plugin-i18n.ts index 4aa6ee42e..faba67da3 100644 --- a/packages/astro/src/i18n/vite-plugin-i18n.ts +++ b/packages/astro/src/i18n/vite-plugin-i18n.ts @@ -28,7 +28,7 @@ export default function astroInternationalization({ getLocaleAbsoluteUrl as _getLocaleAbsoluteUrl, getLocaleAbsoluteUrlList as _getLocaleAbsoluteUrlList, - } from "astro/i18n"; + } from "astro/virtual-modules/i18n.js"; const base = ${JSON.stringify(settings.config.base)}; const trailingSlash = ${JSON.stringify(settings.config.trailingSlash)}; diff --git a/packages/astro/src/integrations/astroFeaturesValidation.ts b/packages/astro/src/integrations/astroFeaturesValidation.ts index a26f42afb..d9049f876 100644 --- a/packages/astro/src/integrations/astroFeaturesValidation.ts +++ b/packages/astro/src/integrations/astroFeaturesValidation.ts @@ -106,17 +106,17 @@ function validateSupportKind( function featureIsUnsupported(adapterName: string, logger: Logger, featureName: string) { logger.error( - `${adapterName}`, - `The feature ${featureName} is not supported by the adapter ${adapterName}.` + 'config', + `The feature ${featureName} is not supported (used by ${adapterName}).` ); } function featureIsExperimental(adapterName: string, logger: Logger) { - logger.warn(`${adapterName}`, 'The feature is experimental and subject to issues or changes.'); + logger.warn('config', `The feature is experimental and subject to change (used by ${adapterName}).`); } function featureIsDeprecated(adapterName: string, logger: Logger) { - logger.warn(`${adapterName}`, 'The feature is deprecated and will be moved in the next release.'); + logger.warn('config', `The feature is deprecated and will be removed in the future (used by ${adapterName}).`); } const SHARP_SERVICE = 'astro/assets/services/sharp'; @@ -135,7 +135,7 @@ function validateAssetsFeature( } = assets; if (config?.image?.service?.entrypoint === SHARP_SERVICE && !isSharpCompatible) { logger.warn( - 'astro', + null, `The currently selected adapter \`${adapterName}\` is not compatible with the image service "Sharp".` ); return false; @@ -143,7 +143,7 @@ function validateAssetsFeature( if (config?.image?.service?.entrypoint === SQUOOSH_SERVICE && !isSquooshCompatible) { logger.warn( - 'astro', + null, `The currently selected adapter \`${adapterName}\` is not compatible with the image service "Squoosh".` ); return false; diff --git a/packages/astro/src/integrations/index.ts b/packages/astro/src/integrations/index.ts index 8b40e5825..55c1bcbcc 100644 --- a/packages/astro/src/integrations/index.ts +++ b/packages/astro/src/integrations/index.ts @@ -1,4 +1,4 @@ -import { bold } from 'kleur/colors'; +import { bold, cyan, underline } from 'kleur/colors'; import fs from 'node:fs'; import type { AddressInfo } from 'node:net'; import { fileURLToPath } from 'node:url'; @@ -24,17 +24,24 @@ import { validateSupportedFeatures } from './astroFeaturesValidation.js'; async function withTakingALongTimeMsg<T>({ name, + hookName, hookResult, timeoutMs = 3000, logger, }: { name: string; + hookName: string; hookResult: T | Promise<T>; timeoutMs?: number; logger: Logger; }): Promise<T> { const timeout = setTimeout(() => { - logger.info('build', `Waiting for the ${bold(name)} integration...`); + logger.info( + 'build', + `Waiting for integration ${bold(JSON.stringify(name))}, hook ${bold( + JSON.stringify(hookName) + )}...` + ); }, timeoutMs); const result = await hookResult; clearTimeout(timeout); @@ -188,6 +195,7 @@ export async function runHookConfigSetup({ await withTakingALongTimeMsg({ name: integration.name, + hookName: 'astro:config:setup', hookResult: integration.hooks['astro:config:setup'](hooks), logger, }); @@ -219,6 +227,7 @@ export async function runHookConfigDone({ if (integration?.hooks?.['astro:config:done']) { await withTakingALongTimeMsg({ name: integration.name, + hookName: 'astro:config:done', hookResult: integration.hooks['astro:config:done']({ config: settings.config, setAdapter(adapter) { @@ -230,7 +239,7 @@ export async function runHookConfigDone({ if (!adapter.supportedAstroFeatures) { // NOTE: throw an error in Astro 4.0 logger.warn( - 'astro', + null, `The adapter ${adapter.name} doesn't provide a feature map. From Astro 3.0, an adapter can provide a feature map. Not providing a feature map will cause an error in Astro 4.0.` ); } else { @@ -247,7 +256,7 @@ export async function runHookConfigDone({ // if we would refactor the validation to support more than boolean, we could still be able to differentiate between the two cases if (!supported && featureName !== 'assets') { logger.error( - 'astro', + null, `The adapter ${adapter.name} doesn't support the feature ${featureName}. Your project won't be built. You should not use it.` ); } @@ -276,6 +285,7 @@ export async function runHookServerSetup({ if (integration?.hooks?.['astro:server:setup']) { await withTakingALongTimeMsg({ name: integration.name, + hookName: 'astro:server:setup', hookResult: integration.hooks['astro:server:setup']({ server, logger: getLogger(integration, logger), @@ -299,6 +309,7 @@ export async function runHookServerStart({ if (integration?.hooks?.['astro:server:start']) { await withTakingALongTimeMsg({ name: integration.name, + hookName: 'astro:server:start', hookResult: integration.hooks['astro:server:start']({ address, logger: getLogger(integration, logger), @@ -320,6 +331,7 @@ export async function runHookServerDone({ if (integration?.hooks?.['astro:server:done']) { await withTakingALongTimeMsg({ name: integration.name, + hookName: 'astro:server:done', hookResult: integration.hooks['astro:server:done']({ logger: getLogger(integration, logger), }), @@ -342,6 +354,7 @@ export async function runHookBuildStart({ await withTakingALongTimeMsg({ name: integration.name, + hookName: 'astro:build:start', hookResult: integration.hooks['astro:build:start']({ logger }), logger: logging, }); @@ -368,6 +381,7 @@ export async function runHookBuildSetup({ if (integration?.hooks?.['astro:build:setup']) { await withTakingALongTimeMsg({ name: integration.name, + hookName: 'astro:build:setup', hookResult: integration.hooks['astro:build:setup']({ vite, pages, @@ -404,6 +418,7 @@ export async function runHookBuildSsr({ if (integration?.hooks?.['astro:build:ssr']) { await withTakingALongTimeMsg({ name: integration.name, + hookName: 'astro:build:ssr', hookResult: integration.hooks['astro:build:ssr']({ manifest, entryPoints, @@ -429,6 +444,7 @@ export async function runHookBuildGenerated({ if (integration?.hooks?.['astro:build:generated']) { await withTakingALongTimeMsg({ name: integration.name, + hookName: 'astro:build:generated', hookResult: integration.hooks['astro:build:generated']({ dir, logger: getLogger(integration, logger), @@ -456,6 +472,7 @@ export async function runHookBuildDone({ config, pages, routes, logging }: RunHo await withTakingALongTimeMsg({ name: integration.name, + hookName: 'astro:build:done', hookResult: integration.hooks['astro:build:done']({ pages: pages.map((p) => ({ pathname: p })), dir, diff --git a/packages/astro/src/prefetch/vite-plugin-prefetch.ts b/packages/astro/src/prefetch/vite-plugin-prefetch.ts index 73ae53f63..69714fd49 100644 --- a/packages/astro/src/prefetch/vite-plugin-prefetch.ts +++ b/packages/astro/src/prefetch/vite-plugin-prefetch.ts @@ -4,7 +4,7 @@ import type { AstroSettings } from '../@types/astro.js'; const virtualModuleId = 'astro:prefetch'; const resolvedVirtualModuleId = '\0' + virtualModuleId; const prefetchInternalModuleFsSubpath = 'astro/dist/prefetch/index.js'; -const prefetchCode = `import { init } from 'astro/prefetch';init()`; +const prefetchCode = `import { init } from 'astro/virtual-modules/prefetch.js';init()`; export default function astroPrefetch({ settings }: { settings: AstroSettings }): vite.Plugin { const prefetchOption = settings.config.prefetch; @@ -19,7 +19,7 @@ export default function astroPrefetch({ settings }: { settings: AstroSettings }) // Inject prefetch script to all pages settings.scripts.push({ stage: 'page', - content: `import { init } from 'astro/prefetch';init()`, + content: `import { init } from 'astro/virtual-modules/prefetch.js';init()`, }); } @@ -40,7 +40,7 @@ export default function astroPrefetch({ settings }: { settings: AstroSettings }) load(id) { if (id === resolvedVirtualModuleId) { if (!prefetch) throwPrefetchNotEnabledError(); - return `export { prefetch } from "astro/prefetch";`; + return `export { prefetch } from "astro/virtual-modules/prefetch.js";`; } }, transform(code, id) { diff --git a/packages/astro/src/runtime/server/endpoint.ts b/packages/astro/src/runtime/server/endpoint.ts index 7db5f07ee..df415ca67 100644 --- a/packages/astro/src/runtime/server/endpoint.ts +++ b/packages/astro/src/runtime/server/endpoint.ts @@ -1,3 +1,4 @@ +import { bold } from 'kleur/colors'; import type { APIContext, EndpointHandler, Params } from '../../@types/astro.js'; import type { Logger } from '../../core/logger/core.js'; @@ -7,7 +8,7 @@ function getHandlerFromModule(mod: EndpointHandler, method: string, logger: Logg // TODO: remove in Astro 4.0 if (mod[lowerCaseMethod]) { logger.warn( - 'astro', + null, `Lower case endpoint names are deprecated and will not be supported in Astro 4.0. Rename the endpoint ${lowerCaseMethod} to ${method}.` ); } @@ -44,15 +45,18 @@ export async function renderEndpoint( ssr: boolean, logger: Logger ) { - const { request } = context; + const { request, url } = context; const chosenMethod = request.method?.toUpperCase(); const handler = getHandlerFromModule(mod, chosenMethod, logger); // TODO: remove the 'get' check in Astro 4.0 if (!ssr && ssr === false && chosenMethod && chosenMethod !== 'GET' && chosenMethod !== 'get') { - // eslint-disable-next-line no-console - console.warn(` -${chosenMethod} requests are not available when building a static site. Update your config to \`output: 'server'\` or \`output: 'hybrid'\` with an \`export const prerender = false\` to handle ${chosenMethod} requests.`); + logger.warn( + null, + `${url.pathname} ${bold( + chosenMethod + )} requests are not available for a static site. Update your config to \`output: 'server'\` or \`output: 'hybrid'\` to enable.` + ); } if (!handler || typeof handler !== 'function') { // No handler found, so this should be a 404. Using a custom header diff --git a/packages/astro/src/transitions/vite-plugin-transitions.ts b/packages/astro/src/transitions/vite-plugin-transitions.ts index 247c61e2b..a3d68ade6 100644 --- a/packages/astro/src/transitions/vite-plugin-transitions.ts +++ b/packages/astro/src/transitions/vite-plugin-transitions.ts @@ -21,20 +21,20 @@ export default function astroTransitions({ settings }: { settings: AstroSettings load(id) { if (id === resolvedVirtualModuleId) { return ` - export * from "astro/transitions"; + export * from "astro/virtual-modules/transitions.js"; export { default as ViewTransitions } from "astro/components/ViewTransitions.astro"; `; } if (id === resolvedVirtualClientModuleId) { return ` - export { navigate, supportsViewTransitions, transitionEnabledOnThisPage } from "astro/transitions/router"; - export * from "astro/transitions/types"; + export { navigate, supportsViewTransitions, transitionEnabledOnThisPage } from "astro/virtual-modules/transitions-router.js"; + export * from "astro/virtual-modules/transitions-types.js"; export { TRANSITION_BEFORE_PREPARATION, isTransitionBeforePreparationEvent, TransitionBeforePreparationEvent, TRANSITION_AFTER_PREPARATION, TRANSITION_BEFORE_SWAP, isTransitionBeforeSwapEvent, TransitionBeforeSwapEvent, TRANSITION_AFTER_SWAP, TRANSITION_PAGE_LOAD - } from "astro/transitions/events"; + } from "astro/virtual-modules/transitions-events.js"; `; } }, diff --git a/packages/astro/src/virtual-modules/README.md b/packages/astro/src/virtual-modules/README.md new file mode 100644 index 000000000..137e2e16f --- /dev/null +++ b/packages/astro/src/virtual-modules/README.md @@ -0,0 +1,3 @@ +# virtual-modules + +This directory contains the entry points for Astro virtual modules. For example, `astro:foobar` would re-export or use `astro/virtual-modules/foobar.js` which maps to the internal file `astro/dist/virtual-modules/foobar.js`. diff --git a/packages/astro/src/virtual-modules/i18n.ts b/packages/astro/src/virtual-modules/i18n.ts new file mode 100644 index 000000000..a55c1f6cf --- /dev/null +++ b/packages/astro/src/virtual-modules/i18n.ts @@ -0,0 +1 @@ +export * from '../i18n/index.js'; diff --git a/packages/astro/src/virtual-modules/middleware.ts b/packages/astro/src/virtual-modules/middleware.ts new file mode 100644 index 000000000..4874c88d0 --- /dev/null +++ b/packages/astro/src/virtual-modules/middleware.ts @@ -0,0 +1 @@ +export { defineMiddleware, sequence } from '../core/middleware/index.js'; diff --git a/packages/astro/src/virtual-modules/prefetch.ts b/packages/astro/src/virtual-modules/prefetch.ts new file mode 100644 index 000000000..72bc23e2d --- /dev/null +++ b/packages/astro/src/virtual-modules/prefetch.ts @@ -0,0 +1 @@ +export * from '../prefetch/index.js'; diff --git a/packages/astro/src/virtual-modules/transitions-events.ts b/packages/astro/src/virtual-modules/transitions-events.ts new file mode 100644 index 000000000..35ecaf64f --- /dev/null +++ b/packages/astro/src/virtual-modules/transitions-events.ts @@ -0,0 +1 @@ +export * from '../transitions/events.js'; diff --git a/packages/astro/src/virtual-modules/transitions-router.ts b/packages/astro/src/virtual-modules/transitions-router.ts new file mode 100644 index 000000000..666089f3f --- /dev/null +++ b/packages/astro/src/virtual-modules/transitions-router.ts @@ -0,0 +1 @@ +export * from '../transitions/router.js'; diff --git a/packages/astro/src/virtual-modules/transitions-types.ts b/packages/astro/src/virtual-modules/transitions-types.ts new file mode 100644 index 000000000..66dfb1d0e --- /dev/null +++ b/packages/astro/src/virtual-modules/transitions-types.ts @@ -0,0 +1 @@ +export * from '../transitions/types.js'; diff --git a/packages/astro/src/virtual-modules/transitions.ts b/packages/astro/src/virtual-modules/transitions.ts new file mode 100644 index 000000000..84aeb3a2c --- /dev/null +++ b/packages/astro/src/virtual-modules/transitions.ts @@ -0,0 +1 @@ +export * from '../transitions/index.js'; diff --git a/packages/astro/src/vite-plugin-astro-server/base.ts b/packages/astro/src/vite-plugin-astro-server/base.ts index 7bf57d10a..e757515d7 100644 --- a/packages/astro/src/vite-plugin-astro-server/base.ts +++ b/packages/astro/src/vite-plugin-astro-server/base.ts @@ -1,10 +1,10 @@ import type * as vite from 'vite'; import type { AstroSettings } from '../@types/astro.js'; +import { bold } from 'kleur/colors'; import * as fs from 'node:fs'; import type { Logger } from '../core/logger/core.js'; import notFoundTemplate, { subpathNotUsedTemplate } from '../template/4xx.js'; -import { log404 } from './common.js'; import { writeHtmlResponse } from './response.js'; export function baseMiddleware( @@ -28,13 +28,11 @@ export function baseMiddleware( } if (pathname === '/' || pathname === '/index.html') { - log404(logger, pathname); const html = subpathNotUsedTemplate(devRoot, pathname); return writeHtmlResponse(res, 404, html); } if (req.headers.accept?.includes('text/html')) { - log404(logger, pathname); const html = notFoundTemplate({ statusCode: 404, title: 'Not found', @@ -45,13 +43,16 @@ export function baseMiddleware( } // Check to see if it's in public and if so 404 + // TODO: Remove redirect, turn this warning into an error in Astro 4.0 const publicPath = new URL('.' + req.url, config.publicDir); fs.stat(publicPath, (_err, stats) => { if (stats) { const expectedLocation = new URL('.' + url, devRootURL).pathname; logger.warn( - 'dev', - `Requests for items in your public folder must also include your base. ${url} should be ${expectedLocation}. Omitting the base will break in production.` + 'router', + `Request URLs for ${bold( + 'public/' + )} assets must also include your base. "${expectedLocation}" expected, but received "${url}".` ); res.writeHead(301, { Location: expectedLocation, diff --git a/packages/astro/src/vite-plugin-astro-server/common.ts b/packages/astro/src/vite-plugin-astro-server/common.ts deleted file mode 100644 index 9e331232c..000000000 --- a/packages/astro/src/vite-plugin-astro-server/common.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { Logger } from '../core/logger/core.js'; -import * as msg from '../core/messages.js'; - -export function log404(logger: Logger, pathname: string) { - logger.info('serve', msg.req({ url: pathname, statusCode: 404 })); -} diff --git a/packages/astro/src/vite-plugin-astro-server/response.ts b/packages/astro/src/vite-plugin-astro-server/response.ts index b1c948095..ac36e703b 100644 --- a/packages/astro/src/vite-plugin-astro-server/response.ts +++ b/packages/astro/src/vite-plugin-astro-server/response.ts @@ -68,7 +68,7 @@ export async function writeWebResponse(res: http.ServerResponse, webResponse: Re // Previously, `headers.entries()` would already have these merged, but it seems like this isn't the case anymore. if (headers.has('set-cookie')) { if ('getSetCookie' in headers && typeof headers.getSetCookie === 'function') { - _headers['set-cookie'] = headers.getSetCookie(); + _headers['set-cookie'] = headers.getSetCookie().toString(); } else { _headers['set-cookie'] = headers.get('set-cookie')!; } diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts index e7f8fd1e4..f87c4e147 100644 --- a/packages/astro/src/vite-plugin-astro-server/route.ts +++ b/packages/astro/src/vite-plugin-astro-server/route.ts @@ -10,6 +10,7 @@ import type { } from '../@types/astro.js'; import { AstroErrorData, isAstroError } from '../core/errors/index.js'; import { sequence } from '../core/middleware/index.js'; +import { req } from '../core/messages.js'; import { loadMiddleware } from '../core/middleware/loadMiddleware.js'; import { createRenderContext, @@ -24,7 +25,6 @@ import { createI18nMiddleware, i18nPipelineHook } from '../i18n/middleware.js'; import { getSortedPreloadedMatches } from '../prerender/routing.js'; import { isServerLikeOutput } from '../prerender/utils.js'; import { PAGE_SCRIPT_ID } from '../vite-plugin-scripts/index.js'; -import { log404 } from './common.js'; import { getStylesForURL } from './css.js'; import type DevPipeline from './devPipeline.js'; import { preload } from './index.js'; @@ -48,6 +48,10 @@ export interface MatchedRoute { mod: ComponentInstance; } +function isLoggedRequest(url: string) { + return url !== '/favicon.ico'; +} + function getCustom404Route(manifestData: ManifestData): RouteData | undefined { const route404 = /^\/404\/?$/; return manifestData.routes.find((r) => route404.test(r.route)); @@ -108,14 +112,13 @@ export async function matchRoute( const possibleRoutes = matches.flatMap((route) => route.component); pipeline.logger.warn( - 'getStaticPaths', + 'router', `${AstroErrorData.NoMatchingStaticPathFound.message( pathname )}\n\n${AstroErrorData.NoMatchingStaticPathFound.hint(possibleRoutes)}` ); } - log404(logger, pathname); const custom404 = getCustom404Route(manifestData); if (custom404) { @@ -161,11 +164,15 @@ export async function handleRoute({ incomingResponse, manifest, }: HandleRoute): Promise<void> { + const timeStart = performance.now(); const env = pipeline.getEnvironment(); const config = pipeline.getConfig(); const moduleLoader = pipeline.getModuleLoader(); const { logger } = env; if (!matchedRoute && !config.experimental.i18n) { + if (isLoggedRequest(pathname)) { + logger.info(null, req({ url: pathname, method: incomingRequest.method, statusCode: 404 })); + } return handle404Response(origin, incomingRequest, incomingResponse); } @@ -304,6 +311,18 @@ export async function handleRoute({ } let response = await pipeline.renderRoute(renderContext, mod); + if (isLoggedRequest(pathname)) { + const timeEnd = performance.now(); + logger.info( + null, + req({ + url: pathname, + method: incomingRequest.method, + statusCode: response.status, + reqTime: timeEnd - timeStart, + }) + ); + } if (response.status === 404 && has404Route(manifestData)) { const fourOhFourRoute = await matchRoute('/404', manifestData, pipeline); if (options && fourOhFourRoute?.route !== options.route) diff --git a/packages/astro/src/vite-plugin-astro/hmr.ts b/packages/astro/src/vite-plugin-astro/hmr.ts index 27cc2d10f..50e1bd25a 100644 --- a/packages/astro/src/vite-plugin-astro/hmr.ts +++ b/packages/astro/src/vite-plugin-astro/hmr.ts @@ -9,7 +9,6 @@ import { type CompileResult, } from '../core/compile/index.js'; import type { Logger } from '../core/logger/core.js'; -import * as msg from '../core/messages.js'; import { isAstroScript } from './query.js'; const PKG_PREFIX = fileURLToPath(new URL('../../', import.meta.url)); @@ -92,11 +91,10 @@ export async function handleHotUpdate( // Bugfix: sometimes style URLs get normalized and end with `lang.css=` // These will cause full reloads, so filter them out here const mods = [...filtered].filter((m) => !m.url.endsWith('=')); - const file = ctx.file.replace(slash(fileURLToPath(config.root)), '/'); // If only styles are changed, remove the component file from the update list if (isStyleOnlyChange) { - logger.info('astro', msg.hmr({ file, style: true })); + logger.debug('watch', 'style-only change'); // remove base file and hoisted scripts return mods.filter((mod) => mod.id !== ctx.file && !mod.id?.endsWith('.ts')); } @@ -112,11 +110,8 @@ export async function handleHotUpdate( // TODO: Svelte files should be marked as `isSelfAccepting` but they don't appear to be const isSelfAccepting = mods.every((m) => m.isSelfAccepting || m.url.endsWith('.svelte')); - if (isSelfAccepting) { - if (/astro\.config\.[cm][jt]s$/.test(file)) return mods; - logger.info('astro', msg.hmr({ file })); - } else { - logger.info('astro', msg.reload({ file })); + if (!isSelfAccepting) { + logger.debug('watch', 'full page reload triggered'); } return mods; diff --git a/packages/astro/src/vite-plugin-astro/index.ts b/packages/astro/src/vite-plugin-astro/index.ts index 1649d8069..631989903 100644 --- a/packages/astro/src/vite-plugin-astro/index.ts +++ b/packages/astro/src/vite-plugin-astro/index.ts @@ -4,6 +4,7 @@ import type { AstroSettings } from '../@types/astro.js'; import type { Logger } from '../core/logger/core.js'; import type { PluginMetadata as AstroPluginMetadata } from './types.js'; +import { fileURLToPath } from 'url'; import { normalizePath } from 'vite'; import { cachedCompilation, @@ -23,6 +24,28 @@ interface AstroPluginOptions { logger: Logger; } +const PKG_PREFIX = fileURLToPath(new URL('../../', import.meta.url)); +const E2E_PREFIX = fileURLToPath(new URL('../../e2e', import.meta.url)); +const isPkgFile = (id: string | null) => { + return id?.startsWith(PKG_PREFIX) && !id.startsWith(E2E_PREFIX); +}; + +const dedupeHotUpdateLogsCache = new Map<string, NodeJS.Timeout>(); + +// TODO(fks): For some reason, we're seeing duplicate handleHotUpdate() calls +// when hitting save multiple times in a row. This is a temporary workaround +// to prevent duplicate logging until the (vite?) issue is fixed. +function dedupeHotUpdateLogs(filename: string) { + if (dedupeHotUpdateLogsCache.has(filename)) { + return false; + } + dedupeHotUpdateLogsCache.set( + filename, + setTimeout(() => dedupeHotUpdateLogsCache.delete(filename), 150) + ); + return true; +} + /** Transform .astro files for Vite */ export default function astro({ settings, logger }: AstroPluginOptions): vite.Plugin[] { const { config } = settings; @@ -173,18 +196,27 @@ export default function astro({ settings, logger }: AstroPluginOptions): vite.Pl }, async handleHotUpdate(context) { if (context.server.config.isProduction) return; - const compileProps: CompileProps = { - astroConfig: config, - viteConfig: resolvedConfig, - filename: context.file, - source: await context.read(), - }; - const compile = () => cachedCompilation(compileProps); + const filename = context.file; + const isSkipLog = + /astro\.config\.[cm][jt]s$/.test(filename) || + /(\/|\\)\.astro(\/|\\)/.test(filename) || + isPkgFile(filename); + if (!isSkipLog && dedupeHotUpdateLogs(filename)) { + logger.info('watch', filename.replace(config.root.pathname, '/')); + } + const source = await context.read(); + const compile = () => + cachedCompilation({ + astroConfig: config, + viteConfig: resolvedConfig, + filename, + source, + }); return handleHotUpdate(context, { config, logger, compile, - source: compileProps.source, + source, }); }, }; diff --git a/packages/astro/src/vite-plugin-inject-env-ts/index.ts b/packages/astro/src/vite-plugin-inject-env-ts/index.ts index d884075ab..116b45e3c 100644 --- a/packages/astro/src/vite-plugin-inject-env-ts/index.ts +++ b/packages/astro/src/vite-plugin-inject-env-ts/index.ts @@ -57,7 +57,7 @@ export async function setUpEnvTs({ 'types="astro/client"' ); await fs.promises.writeFile(envTsPath, typesEnvContents, 'utf-8'); - logger.info('assets', `Removed ${bold(envTsPathRelativetoRoot)} types`); + logger.info('types', `Removed ${bold(envTsPathRelativetoRoot)} type declarations`); } if (!fs.existsSync(dotAstroDir)) @@ -68,7 +68,7 @@ export async function setUpEnvTs({ if (!typesEnvContents.includes(expectedTypeReference)) { typesEnvContents = `${expectedTypeReference}\n${typesEnvContents}`; await fs.promises.writeFile(envTsPath, typesEnvContents, 'utf-8'); - logger.info('content', `Added ${bold(envTsPathRelativetoRoot)} types`); + logger.info('types', `Added ${bold(envTsPathRelativetoRoot)} type declarations`); } } else { // Otherwise, inject the `env.d.ts` file @@ -81,6 +81,6 @@ export async function setUpEnvTs({ await fs.promises.mkdir(settings.config.srcDir, { recursive: true }); await fs.promises.writeFile(envTsPath, referenceDefs.join('\n'), 'utf-8'); - logger.info('astro', `Added ${bold(envTsPathRelativetoRoot)} types`); + logger.info('types', `Added ${bold(envTsPathRelativetoRoot)} type declarations`); } } diff --git a/packages/astro/src/vite-plugin-load-fallback/index.ts b/packages/astro/src/vite-plugin-load-fallback/index.ts index e11f317ca..80db39edd 100644 --- a/packages/astro/src/vite-plugin-load-fallback/index.ts +++ b/packages/astro/src/vite-plugin-load-fallback/index.ts @@ -2,6 +2,7 @@ import nodeFs from 'node:fs'; import npath from 'node:path'; import type * as vite from 'vite'; import { slash } from '../core/path.js'; +import { cleanUrl } from '../vite-plugin-utils/index.js'; type NodeFileSystemModule = typeof nodeFs; @@ -77,8 +78,3 @@ export default function loadFallbackPlugin({ }, ]; } - -const queryRE = /\?.*$/s; -const hashRE = /#.*$/s; - -const cleanUrl = (url: string): string => url.replace(hashRE, '').replace(queryRE, ''); diff --git a/packages/astro/src/vite-plugin-scanner/index.ts b/packages/astro/src/vite-plugin-scanner/index.ts index d48aed203..678f3ac18 100644 --- a/packages/astro/src/vite-plugin-scanner/index.ts +++ b/packages/astro/src/vite-plugin-scanner/index.ts @@ -52,12 +52,11 @@ export default function astroScannerPlugin({ // this should only be valid for `.astro`, `.js` and `.ts` files KNOWN_FILE_EXTENSIONS.includes(extname(filename)) ) { - const reason = ` because \`output: "${settings.config.output}"\` is set`; logger.warn( - 'getStaticPaths', - `The getStaticPaths() statement in ${bold( + 'router', + `getStaticPaths() ignored in dynamic page ${bold( rootRelativePath(settings.config.root, fileURL, true) - )} has been ignored${reason}.\n\nAdd \`export const prerender = true;\` to prerender this page.` + )}. Add \`export const prerender = true;\` to prerender the page as static HTML during the build process.` ); } diff --git a/packages/astro/src/vite-plugin-scripts/index.ts b/packages/astro/src/vite-plugin-scripts/index.ts index 0066b98f5..9b2848923 100644 --- a/packages/astro/src/vite-plugin-scripts/index.ts +++ b/packages/astro/src/vite-plugin-scripts/index.ts @@ -50,8 +50,7 @@ export default function astroScriptsPlugin({ settings }: { settings: AstroSettin }, buildStart() { const hasHydrationScripts = settings.scripts.some((s) => s.stage === 'before-hydration'); - // @ts-expect-error Vite 5 renamed `ssrBuild` to `isSsrBuild` - const isSsrBuild = env?.ssrBuild || env?.isSsrBuild; + const isSsrBuild = env?.isSsrBuild; if (hasHydrationScripts && env?.command === 'build' && !isSsrBuild) { this.emitFile({ type: 'chunk', diff --git a/packages/astro/src/vite-plugin-utils/index.ts b/packages/astro/src/vite-plugin-utils/index.ts index 51f0e6cc4..7bf9f092f 100644 --- a/packages/astro/src/vite-plugin-utils/index.ts +++ b/packages/astro/src/vite-plugin-utils/index.ts @@ -56,3 +56,8 @@ export function normalizeFilename(filename: string, root: URL) { } return removeLeadingForwardSlashWindows(filename); } + +const postfixRE = /[?#].*$/s; +export function cleanUrl(url: string): string { + return url.replace(postfixRE, ''); +} diff --git a/packages/astro/test/astro-markdown-remarkRehype.test.js b/packages/astro/test/astro-markdown-remarkRehype.test.js index 59b0eeda6..17b20b51e 100644 --- a/packages/astro/test/astro-markdown-remarkRehype.test.js +++ b/packages/astro/test/astro-markdown-remarkRehype.test.js @@ -15,7 +15,7 @@ describe('Astro Markdown without remark-rehype config', () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); expect($('#footnote-label').text()).to.equal('Footnotes'); - expect($('.data-footnote-backref').first().attr('aria-label')).to.equal('Back to content'); + expect($('.data-footnote-backref').first().attr('aria-label')).to.equal('Back to reference 1'); }); }); diff --git a/packages/astro/test/cli.test.js b/packages/astro/test/cli.test.js index 82cf7a12d..caec4241d 100644 --- a/packages/astro/test/cli.test.js +++ b/packages/astro/test/cli.test.js @@ -106,7 +106,7 @@ describe('astro cli', () => { expect(messages[0]).to.contain('astro'); expect(messages[0]).to.contain(pkgVersion); - expect(messages[0]).to.contain('started in'); + expect(messages[0]).to.contain('ready in'); }); ['dev', 'preview'].forEach((cmd) => { diff --git a/packages/astro/test/core-image.test.js b/packages/astro/test/core-image.test.js index 74f86ba7f..7d9ce4d3b 100644 --- a/packages/astro/test/core-image.test.js +++ b/packages/astro/test/core-image.test.js @@ -663,7 +663,6 @@ describe('astro:image', () => { logs.length = 0; let res = await fixture.fetch('/post'); await res.text(); - expect(logs).to.have.a.lengthOf(1); expect(logs[0].message).to.contain('Could not find requested image'); }); diff --git a/packages/astro/test/fixtures/0-css/package.json b/packages/astro/test/fixtures/0-css/package.json index 6ecfb1d9e..fca80fd91 100644 --- a/packages/astro/test/fixtures/0-css/package.json +++ b/packages/astro/test/fixtures/0-css/package.json @@ -9,7 +9,7 @@ "astro": "workspace:*", "react": "^18.1.0", "react-dom": "^18.1.0", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/test/fixtures/alias-tsconfig-baseurl-only/package.json b/packages/astro/test/fixtures/alias-tsconfig-baseurl-only/package.json index a708628bb..a632b8463 100644 --- a/packages/astro/test/fixtures/alias-tsconfig-baseurl-only/package.json +++ b/packages/astro/test/fixtures/alias-tsconfig-baseurl-only/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/svelte": "workspace:*", "astro": "workspace:*", - "svelte": "^4.2.0" + "svelte": "^4.2.5" } } diff --git a/packages/astro/test/fixtures/alias-tsconfig/package.json b/packages/astro/test/fixtures/alias-tsconfig/package.json index e27fc9130..80033bdf9 100644 --- a/packages/astro/test/fixtures/alias-tsconfig/package.json +++ b/packages/astro/test/fixtures/alias-tsconfig/package.json @@ -6,6 +6,6 @@ "@astrojs/svelte": "workspace:*", "@test/namespace-package": "workspace:*", "astro": "workspace:*", - "svelte": "^4.2.0" + "svelte": "^4.2.5" } } diff --git a/packages/astro/test/fixtures/alias/package.json b/packages/astro/test/fixtures/alias/package.json index e23fb4d58..74351e6e3 100644 --- a/packages/astro/test/fixtures/alias/package.json +++ b/packages/astro/test/fixtures/alias/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/svelte": "workspace:*", "astro": "workspace:*", - "svelte": "^4.2.0" + "svelte": "^4.2.5" } } diff --git a/packages/astro/test/fixtures/astro-basic/package.json b/packages/astro/test/fixtures/astro-basic/package.json index c2e0be656..417636229 100644 --- a/packages/astro/test/fixtures/astro-basic/package.json +++ b/packages/astro/test/fixtures/astro-basic/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/astro-children/package.json b/packages/astro/test/fixtures/astro-children/package.json index 5fc2951be..1ed097ea1 100644 --- a/packages/astro/test/fixtures/astro-children/package.json +++ b/packages/astro/test/fixtures/astro-children/package.json @@ -7,8 +7,8 @@ "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "preact": "^10.19.2", + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/test/fixtures/astro-client-only/package.json b/packages/astro/test/fixtures/astro-client-only/package.json index a550b3a7b..2d55fe99c 100644 --- a/packages/astro/test/fixtures/astro-client-only/package.json +++ b/packages/astro/test/fixtures/astro-client-only/package.json @@ -9,6 +9,6 @@ "astro": "workspace:*", "react": "^18.1.0", "react-dom": "^18.1.0", - "svelte": "^4.2.0" + "svelte": "^4.2.5" } } diff --git a/packages/astro/test/fixtures/astro-dynamic/package.json b/packages/astro/test/fixtures/astro-dynamic/package.json index 2dc810458..6209dabe9 100644 --- a/packages/astro/test/fixtures/astro-dynamic/package.json +++ b/packages/astro/test/fixtures/astro-dynamic/package.json @@ -8,6 +8,6 @@ "astro": "workspace:*", "react": "^18.1.0", "react-dom": "^18.1.0", - "svelte": "^4.2.0" + "svelte": "^4.2.5" } } diff --git a/packages/astro/test/fixtures/astro-envs/package.json b/packages/astro/test/fixtures/astro-envs/package.json index c46f4d681..86bad5a87 100644 --- a/packages/astro/test/fixtures/astro-envs/package.json +++ b/packages/astro/test/fixtures/astro-envs/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "vue": "^3.3.4" + "vue": "^3.3.8" } } diff --git a/packages/astro/test/fixtures/astro-expr/package.json b/packages/astro/test/fixtures/astro-expr/package.json index c6dce6e21..ac553abf2 100644 --- a/packages/astro/test/fixtures/astro-expr/package.json +++ b/packages/astro/test/fixtures/astro-expr/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/astro-fallback/package.json b/packages/astro/test/fixtures/astro-fallback/package.json index ea2281e08..8726d73a9 100644 --- a/packages/astro/test/fixtures/astro-fallback/package.json +++ b/packages/astro/test/fixtures/astro-fallback/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/astro-markdown-plugins/package.json b/packages/astro/test/fixtures/astro-markdown-plugins/package.json index a7953b785..bd48d532e 100644 --- a/packages/astro/test/fixtures/astro-markdown-plugins/package.json +++ b/packages/astro/test/fixtures/astro-markdown-plugins/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "astro": "workspace:*", - "hast-util-select": "^6.0.0", - "rehype-slug": "^5.0.1" + "hast-util-select": "^6.0.2", + "rehype-slug": "^6.0.0" } } diff --git a/packages/astro/test/fixtures/astro-slot-with-client/package.json b/packages/astro/test/fixtures/astro-slot-with-client/package.json index 830c205cf..eb88bae98 100644 --- a/packages/astro/test/fixtures/astro-slot-with-client/package.json +++ b/packages/astro/test/fixtures/astro-slot-with-client/package.json @@ -4,6 +4,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/astro-slots-nested/package.json b/packages/astro/test/fixtures/astro-slots-nested/package.json index e40fa0396..2e1a6bef9 100644 --- a/packages/astro/test/fixtures/astro-slots-nested/package.json +++ b/packages/astro/test/fixtures/astro-slots-nested/package.json @@ -9,11 +9,11 @@ "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1", + "preact": "^10.19.2", "react": "^18.2.0", "react-dom": "^18.2.0", - "solid-js": "^1.7.11", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "solid-js": "^1.8.5", + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/test/fixtures/before-hydration/package.json b/packages/astro/test/fixtures/before-hydration/package.json index a49804cd7..cf419345b 100644 --- a/packages/astro/test/fixtures/before-hydration/package.json +++ b/packages/astro/test/fixtures/before-hydration/package.json @@ -4,6 +4,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/build-assets/package.json b/packages/astro/test/fixtures/build-assets/package.json index 3a8c744ed..b09d02c66 100644 --- a/packages/astro/test/fixtures/build-assets/package.json +++ b/packages/astro/test/fixtures/build-assets/package.json @@ -4,6 +4,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/component-library-shared/package.json b/packages/astro/test/fixtures/component-library-shared/package.json index b6d1bdfe8..b91ef8216 100644 --- a/packages/astro/test/fixtures/component-library-shared/package.json +++ b/packages/astro/test/fixtures/component-library-shared/package.json @@ -18,7 +18,7 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.17.1", + "preact": "^10.19.2", "react": "^18.2.0" } } diff --git a/packages/astro/test/fixtures/component-library/package.json b/packages/astro/test/fixtures/component-library/package.json index 3697c7a7e..14a8cb44a 100644 --- a/packages/astro/test/fixtures/component-library/package.json +++ b/packages/astro/test/fixtures/component-library/package.json @@ -8,9 +8,9 @@ "@astrojs/svelte": "workspace:*", "@test/component-library-shared": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1", + "preact": "^10.19.2", "react": "^18.1.0", "react-dom": "^18.1.0", - "svelte": "^4.2.0" + "svelte": "^4.2.5" } } diff --git a/packages/astro/test/fixtures/css-dangling-references/package.json b/packages/astro/test/fixtures/css-dangling-references/package.json index 9ac28d282..03878694e 100644 --- a/packages/astro/test/fixtures/css-dangling-references/package.json +++ b/packages/astro/test/fixtures/css-dangling-references/package.json @@ -1,11 +1,10 @@ { - "name": "@test/css-dangling-references", - "version": "0.0.0", - "private": true, - "dependencies": { - "astro": "workspace:*", - "@astrojs/svelte": "workspace:*", - "svelte": "4" - } + "name": "@test/css-dangling-references", + "version": "0.0.0", + "private": true, + "dependencies": { + "@astrojs/svelte": "workspace:*", + "astro": "workspace:*", + "svelte": "^4.2.5" } -
\ No newline at end of file +}
\ No newline at end of file diff --git a/packages/astro/test/fixtures/entry-file-names/package.json b/packages/astro/test/fixtures/entry-file-names/package.json index a405afb9e..bfd58eae7 100644 --- a/packages/astro/test/fixtures/entry-file-names/package.json +++ b/packages/astro/test/fixtures/entry-file-names/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/fetch/package.json b/packages/astro/test/fixtures/fetch/package.json index 2d215ec89..60cfd4166 100644 --- a/packages/astro/test/fixtures/fetch/package.json +++ b/packages/astro/test/fixtures/fetch/package.json @@ -7,8 +7,8 @@ "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "preact": "^10.19.2", + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/test/fixtures/fontsource-package/package.json b/packages/astro/test/fixtures/fontsource-package/package.json index 7cfd6d26c..55140976c 100644 --- a/packages/astro/test/fixtures/fontsource-package/package.json +++ b/packages/astro/test/fixtures/fontsource-package/package.json @@ -3,8 +3,8 @@ "version": "0.0.0", "private": true, "dependencies": { - "@fontsource/monofett": "5.0.9", - "@fontsource/montserrat": "5.0.8", + "@fontsource/monofett": "5.0.17", + "@fontsource/montserrat": "5.0.15", "astro": "workspace:*" } } diff --git a/packages/astro/test/fixtures/hydration-race/package.json b/packages/astro/test/fixtures/hydration-race/package.json index aa0a5d47e..08319bc2b 100644 --- a/packages/astro/test/fixtures/hydration-race/package.json +++ b/packages/astro/test/fixtures/hydration-race/package.json @@ -9,6 +9,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/integration-add-page-extension/astro.config.mjs b/packages/astro/test/fixtures/integration-add-page-extension/astro.config.mjs index 0a0a33697..4c52ae0da 100644 --- a/packages/astro/test/fixtures/integration-add-page-extension/astro.config.mjs +++ b/packages/astro/test/fixtures/integration-add-page-extension/astro.config.mjs @@ -1,4 +1,4 @@ -import { defineConfig } from 'rollup' +import { defineConfig } from 'astro/config' import test from './integration.js' export default defineConfig({ diff --git a/packages/astro/test/fixtures/integration-server-setup/astro.config.mjs b/packages/astro/test/fixtures/integration-server-setup/astro.config.mjs index 0a0a33697..4c52ae0da 100644 --- a/packages/astro/test/fixtures/integration-server-setup/astro.config.mjs +++ b/packages/astro/test/fixtures/integration-server-setup/astro.config.mjs @@ -1,4 +1,4 @@ -import { defineConfig } from 'rollup' +import { defineConfig } from 'astro/config' import test from './integration.js' export default defineConfig({ diff --git a/packages/astro/test/fixtures/jsx/package.json b/packages/astro/test/fixtures/jsx/package.json index 73113746d..f4b89d76e 100644 --- a/packages/astro/test/fixtures/jsx/package.json +++ b/packages/astro/test/fixtures/jsx/package.json @@ -12,11 +12,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.17.1", + "preact": "^10.19.2", "react": "^18.1.0", "react-dom": "^18.1.0", - "solid-js": "^1.7.11", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "solid-js": "^1.8.5", + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/test/fixtures/large-array/package.json b/packages/astro/test/fixtures/large-array/package.json index e4559b4ae..69f74d040 100644 --- a/packages/astro/test/fixtures/large-array/package.json +++ b/packages/astro/test/fixtures/large-array/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/solid-js": "workspace:*", "astro": "workspace:*", - "solid-js": "^1.7.11" + "solid-js": "^1.8.5" } } diff --git a/packages/astro/test/fixtures/postcss/package.json b/packages/astro/test/fixtures/postcss/package.json index c9e4ba833..db86ba46c 100644 --- a/packages/astro/test/fixtures/postcss/package.json +++ b/packages/astro/test/fixtures/postcss/package.json @@ -9,11 +9,11 @@ "astro": "workspace:*", "autoprefixer": "^10.4.15", "postcss": "^8.4.28", - "solid-js": "^1.7.11", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "solid-js": "^1.8.5", + "svelte": "^4.2.5", + "vue": "^3.3.8" }, "devDependencies": { - "postcss-preset-env": "^9.1.1" + "postcss-preset-env": "^9.3.0" } } diff --git a/packages/astro/test/fixtures/preact-compat-component/package.json b/packages/astro/test/fixtures/preact-compat-component/package.json index bbab4a629..68de1f1b7 100644 --- a/packages/astro/test/fixtures/preact-compat-component/package.json +++ b/packages/astro/test/fixtures/preact-compat-component/package.json @@ -6,6 +6,6 @@ "@astrojs/preact": "workspace:*", "@test/react-lib": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/preact-component/package.json b/packages/astro/test/fixtures/preact-component/package.json index bdb2524aa..43e8fd8f8 100644 --- a/packages/astro/test/fixtures/preact-component/package.json +++ b/packages/astro/test/fixtures/preact-component/package.json @@ -6,6 +6,6 @@ "@astrojs/preact": "workspace:*", "@preact/signals": "1.2.1", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/react-and-solid/package.json b/packages/astro/test/fixtures/react-and-solid/package.json index 01ac7866e..a585a2c95 100644 --- a/packages/astro/test/fixtures/react-and-solid/package.json +++ b/packages/astro/test/fixtures/react-and-solid/package.json @@ -7,6 +7,6 @@ "astro": "workspace:*", "react": "^18.2.0", "react-dom": "^18.1.0", - "solid-js": "^1.7.11" + "solid-js": "^1.8.5" } } diff --git a/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json b/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json index 0a7f6e7cf..1388cc07a 100644 --- a/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json +++ b/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json @@ -4,6 +4,6 @@ "dependencies": { "@astrojs/preact": "workspace:", "astro": "workspace:", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/slots-preact/package.json b/packages/astro/test/fixtures/slots-preact/package.json index 33dcf78bc..bcd612323 100644 --- a/packages/astro/test/fixtures/slots-preact/package.json +++ b/packages/astro/test/fixtures/slots-preact/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/slots-solid/package.json b/packages/astro/test/fixtures/slots-solid/package.json index 87b0e75bf..688101adf 100644 --- a/packages/astro/test/fixtures/slots-solid/package.json +++ b/packages/astro/test/fixtures/slots-solid/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/solid-js": "workspace:*", "astro": "workspace:*", - "solid-js": "^1.7.11" + "solid-js": "^1.8.5" } } diff --git a/packages/astro/test/fixtures/slots-svelte/package.json b/packages/astro/test/fixtures/slots-svelte/package.json index f166a1fc9..5335dd2ad 100644 --- a/packages/astro/test/fixtures/slots-svelte/package.json +++ b/packages/astro/test/fixtures/slots-svelte/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/svelte": "workspace:*", "astro": "workspace:*", - "svelte": "^4.2.0" + "svelte": "^4.2.5" } } diff --git a/packages/astro/test/fixtures/slots-vue/package.json b/packages/astro/test/fixtures/slots-vue/package.json index e61cf2bbe..4beb43ad9 100644 --- a/packages/astro/test/fixtures/slots-vue/package.json +++ b/packages/astro/test/fixtures/slots-vue/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "vue": "^3.3.4" + "vue": "^3.3.8" } } diff --git a/packages/astro/test/fixtures/solid-component/deps/solid-jsx-component/package.json b/packages/astro/test/fixtures/solid-component/deps/solid-jsx-component/package.json index e9d0ed6c0..59568a514 100644 --- a/packages/astro/test/fixtures/solid-component/deps/solid-jsx-component/package.json +++ b/packages/astro/test/fixtures/solid-component/deps/solid-jsx-component/package.json @@ -10,6 +10,6 @@ } }, "dependencies": { - "solid-js": "^1.7.11" + "solid-js": "^1.8.5" } } diff --git a/packages/astro/test/fixtures/solid-component/package.json b/packages/astro/test/fixtures/solid-component/package.json index 9cd551755..8a8696964 100644 --- a/packages/astro/test/fixtures/solid-component/package.json +++ b/packages/astro/test/fixtures/solid-component/package.json @@ -4,9 +4,9 @@ "private": true, "dependencies": { "@astrojs/solid-js": "workspace:*", - "@solidjs/router": "^0.8.3", + "@solidjs/router": "^0.9.1", "@test/solid-jsx-component": "file:./deps/solid-jsx-component", "astro": "workspace:*", - "solid-js": "^1.7.11" + "solid-js": "^1.8.5" } } diff --git a/packages/astro/test/fixtures/ssr-env/package.json b/packages/astro/test/fixtures/ssr-env/package.json index 9a78d4213..4cc5e8ea5 100644 --- a/packages/astro/test/fixtures/ssr-env/package.json +++ b/packages/astro/test/fixtures/ssr-env/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/ssr-scripts/package.json b/packages/astro/test/fixtures/ssr-scripts/package.json index 5b4a8abb7..3489d3ba4 100644 --- a/packages/astro/test/fixtures/ssr-scripts/package.json +++ b/packages/astro/test/fixtures/ssr-scripts/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/static-build-frameworks/package.json b/packages/astro/test/fixtures/static-build-frameworks/package.json index 4df7c2b12..f2ba47078 100644 --- a/packages/astro/test/fixtures/static-build-frameworks/package.json +++ b/packages/astro/test/fixtures/static-build-frameworks/package.json @@ -6,7 +6,7 @@ "@astrojs/preact": "workspace:*", "@astrojs/react": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1", + "preact": "^10.19.2", "react": "^18.1.0", "react-dom": "^18.1.0" } diff --git a/packages/astro/test/fixtures/static-build/package.json b/packages/astro/test/fixtures/static-build/package.json index df47dd1ef..e8eaa87d3 100644 --- a/packages/astro/test/fixtures/static-build/package.json +++ b/packages/astro/test/fixtures/static-build/package.json @@ -6,6 +6,6 @@ "@astrojs/preact": "workspace:*", "@test/static-build-pkg": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/astro/test/fixtures/svelte-component/package.json b/packages/astro/test/fixtures/svelte-component/package.json index eb6c57470..bc4d8b5aa 100644 --- a/packages/astro/test/fixtures/svelte-component/package.json +++ b/packages/astro/test/fixtures/svelte-component/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/svelte": "workspace:*", "astro": "workspace:*", - "svelte": "^4.2.0" + "svelte": "^4.2.5" } } diff --git a/packages/astro/test/fixtures/tailwindcss-ts/package.json b/packages/astro/test/fixtures/tailwindcss-ts/package.json index a54b4779e..98ca7985c 100644 --- a/packages/astro/test/fixtures/tailwindcss-ts/package.json +++ b/packages/astro/test/fixtures/tailwindcss-ts/package.json @@ -6,6 +6,6 @@ "@astrojs/tailwind": "workspace:*", "astro": "workspace:*", "postcss": "^8.4.28", - "tailwindcss": "^3.3.3" + "tailwindcss": "^3.3.5" } } diff --git a/packages/astro/test/fixtures/tailwindcss/package.json b/packages/astro/test/fixtures/tailwindcss/package.json index 6117883a9..7815a3b2e 100644 --- a/packages/astro/test/fixtures/tailwindcss/package.json +++ b/packages/astro/test/fixtures/tailwindcss/package.json @@ -8,6 +8,6 @@ "astro": "workspace:*", "autoprefixer": "^10.4.15", "postcss": "^8.4.28", - "tailwindcss": "^3.3.3" + "tailwindcss": "^3.3.5" } } diff --git a/packages/astro/test/fixtures/third-party-astro/package.json b/packages/astro/test/fixtures/third-party-astro/package.json index cd9d0743c..01bdf2b20 100644 --- a/packages/astro/test/fixtures/third-party-astro/package.json +++ b/packages/astro/test/fixtures/third-party-astro/package.json @@ -4,6 +4,6 @@ "private": true, "dependencies": { "astro": "workspace:*", - "astro-embed": "^0.5.1" + "astro-embed": "^0.6.0" } } diff --git a/packages/astro/test/fixtures/vue-component/package.json b/packages/astro/test/fixtures/vue-component/package.json index b1f716dd6..7913b7720 100644 --- a/packages/astro/test/fixtures/vue-component/package.json +++ b/packages/astro/test/fixtures/vue-component/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "vue": "^3.3.4" + "vue": "^3.3.8" } } diff --git a/packages/astro/test/fixtures/vue-jsx/package.json b/packages/astro/test/fixtures/vue-jsx/package.json index e04e8077d..76bd57acf 100644 --- a/packages/astro/test/fixtures/vue-jsx/package.json +++ b/packages/astro/test/fixtures/vue-jsx/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "vue": "^3.3.4" + "vue": "^3.3.8" } } diff --git a/packages/astro/test/fixtures/vue-with-multi-renderer/package.json b/packages/astro/test/fixtures/vue-with-multi-renderer/package.json index 476c7f680..adc755525 100644 --- a/packages/astro/test/fixtures/vue-with-multi-renderer/package.json +++ b/packages/astro/test/fixtures/vue-with-multi-renderer/package.json @@ -6,7 +6,7 @@ "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "svelte": "^4.2.0", - "vue": "^3.3.4" + "svelte": "^4.2.5", + "vue": "^3.3.8" } } diff --git a/packages/astro/test/preview-routing.test.js b/packages/astro/test/preview-routing.test.js index 8a4653a72..9e986c47c 100644 --- a/packages/astro/test/preview-routing.test.js +++ b/packages/astro/test/preview-routing.test.js @@ -1,12 +1,7 @@ import { expect } from 'chai'; -import { version } from 'vite'; import { loadFixture } from './test-utils.js'; -const IS_VITE_5 = version.startsWith('5.'); - -// Skip in Vite 5 as it changes how HTML files are served. We may want to review aligning -// trailingSlash and build.format to avoid potential footguns in Astro 4 -(IS_VITE_5 ? describe.skip : describe)('Preview Routing', function () { +describe('Preview Routing', function () { describe('build format: directory', () => { describe('Subpath without trailing slash and trailingSlash: never', () => { /** @type {import('./test-utils').Fixture} */ diff --git a/packages/astro/test/static-build.test.js b/packages/astro/test/static-build.test.js index 8bde08132..5ec225133 100644 --- a/packages/astro/test/static-build.test.js +++ b/packages/astro/test/static-build.test.js @@ -186,8 +186,7 @@ describe('Static build', () => { let found = false; for (const log of logs) { if ( - log.label === 'ssg' && - /[hH]eaders are not exposed in static \(SSG\) output mode/.test(log.message) + /\`Astro\.request\.headers\` is not available in "static" output mode/.test(log.message) ) { found = true; } diff --git a/packages/astro/test/units/vite-plugin-astro-server/request.test.js b/packages/astro/test/units/vite-plugin-astro-server/request.test.js index d3472c56b..d1d0cf464 100644 --- a/packages/astro/test/units/vite-plugin-astro-server/request.test.js +++ b/packages/astro/test/units/vite-plugin-astro-server/request.test.js @@ -21,7 +21,7 @@ async function createDevPipeline(overrides = {}) { return new DevPipeline({ manifest, settings, - logging: defaultLogger, + logger: defaultLogger, loader, }); } diff --git a/packages/create-astro/package.json b/packages/create-astro/package.json index 7aa1b62f6..36dd357c7 100644 --- a/packages/create-astro/package.json +++ b/packages/create-astro/package.json @@ -32,7 +32,7 @@ "//b": "DEPENDENCIES IS FOR UNBUNDLED PACKAGES", "dependencies": { "@astrojs/cli-kit": "^0.3.1", - "giget": "1.1.2" + "giget": "1.1.3" }, "devDependencies": { "arg": "^5.0.2", diff --git a/packages/create-astro/src/index.ts b/packages/create-astro/src/index.ts index 3ac5d231b..f641e876e 100644 --- a/packages/create-astro/src/index.ts +++ b/packages/create-astro/src/index.ts @@ -19,9 +19,9 @@ process.on('SIGTERM', exit); // https://github.com/withastro/docs/blob/main/src/pages/en/install/auto.md // if you make any changes to the flow or wording here. export async function main() { - // Clear console because PNPM startup is super ugly + // Add some extra spacing from the noisy npm/pnpm init output // eslint-disable-next-line no-console - console.clear(); + console.log(''); // NOTE: In the v7.x version of npm, the default behavior of `npm init` was changed // to no longer require `--` to pass args and instead pass `--` directly to us. This // broke our arg parser, since `--` is a special kind of flag. Filtering for `--` here diff --git a/packages/integrations/lit/package.json b/packages/integrations/lit/package.json index 252a412d1..dd29cde62 100644 --- a/packages/integrations/lit/package.json +++ b/packages/integrations/lit/package.json @@ -59,7 +59,7 @@ "cheerio": "1.0.0-rc.12", "lit": "^2.8.0", "mocha": "^10.2.0", - "sass": "^1.66.1" + "sass": "^1.69.5" }, "peerDependencies": { "@webcomponents/template-shadowroot": "^0.2.1", diff --git a/packages/integrations/markdoc/package.json b/packages/integrations/markdoc/package.json index 18e6aca5e..3ee59d3d0 100644 --- a/packages/integrations/markdoc/package.json +++ b/packages/integrations/markdoc/package.json @@ -65,13 +65,13 @@ "dependencies": { "@astrojs/internal-helpers": "workspace:*", "@astrojs/prism": "workspace:*", - "@markdoc/markdoc": "^0.3.0", - "esbuild": "^0.19.2", + "@markdoc/markdoc": "^0.3.5", + "esbuild": "^0.19.6", "github-slugger": "^2.0.0", "gray-matter": "^4.0.3", "htmlparser2": "^9.0.0", "kleur": "^4.1.5", - "shikiji": "^0.6.8", + "shikiji": "^0.6.13", "zod": "^3.22.4" }, "peerDependencies": { @@ -79,18 +79,17 @@ }, "devDependencies": { "@astrojs/markdown-remark": "workspace:*", - "@types/chai": "^4.3.5", - "@types/html-escaper": "^3.0.0", - "@types/markdown-it": "^13.0.0", - "@types/mocha": "^10.0.1", + "@types/chai": "^4.3.10", + "@types/html-escaper": "^3.0.2", + "@types/markdown-it": "^13.0.6", + "@types/mocha": "^10.0.4", "astro": "workspace:*", "astro-scripts": "workspace:*", "chai": "^4.3.7", "devalue": "^4.3.2", - "linkedom": "^0.15.1", + "linkedom": "^0.16.4", "mocha": "^10.2.0", - "rollup": "^3.28.1", - "vite": "^4.4.9" + "vite": "^5.0.0" }, "engines": { "node": ">=18.14.1" diff --git a/packages/integrations/markdoc/src/content-entry-type.ts b/packages/integrations/markdoc/src/content-entry-type.ts index 07c5268e4..21ba7ab19 100644 --- a/packages/integrations/markdoc/src/content-entry-type.ts +++ b/packages/integrations/markdoc/src/content-entry-type.ts @@ -6,8 +6,7 @@ import matter from 'gray-matter'; import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; -import type * as rollup from 'rollup'; -import type { ErrorPayload as ViteErrorPayload } from 'vite'; +import type { ErrorPayload as ViteErrorPayload, Rollup } from 'vite'; import type { ComponentConfig } from './config.js'; import { htmlTokenTransform } from './html/transform/html-token-transform.js'; import type { MarkdocConfigResult } from './load-config.js'; @@ -174,7 +173,7 @@ function getEntryInfo({ fileUrl, contents }: { fileUrl: URL; contents: string }) async function emitOptimizedImages( nodeChildren: Node[], ctx: { - pluginContext: rollup.PluginContext; + pluginContext: Rollup.PluginContext; filePath: string; astroConfig: AstroConfig; } diff --git a/packages/integrations/mdx/package.json b/packages/integrations/mdx/package.json index f9e22d58c..8a2ff0b3f 100644 --- a/packages/integrations/mdx/package.json +++ b/packages/integrations/mdx/package.json @@ -35,47 +35,47 @@ }, "dependencies": { "@astrojs/markdown-remark": "workspace:*", - "@mdx-js/mdx": "^2.3.0", - "acorn": "^8.10.0", - "es-module-lexer": "^1.3.0", - "estree-util-visit": "^1.2.1", + "@mdx-js/mdx": "^3.0.0", + "acorn": "^8.11.2", + "es-module-lexer": "^1.4.1", + "estree-util-visit": "^2.0.0", "github-slugger": "^2.0.0", "gray-matter": "^4.0.3", - "hast-util-to-html": "^8.0.4", + "hast-util-to-html": "^9.0.0", "kleur": "^4.1.4", - "rehype-raw": "^6.1.1", - "remark-gfm": "^3.0.1", + "rehype-raw": "^7.0.0", + "remark-gfm": "^4.0.0", "remark-smartypants": "^2.0.0", "source-map": "^0.7.4", - "unist-util-visit": "^4.1.2", - "vfile": "^5.3.7" + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.1" }, "peerDependencies": { "astro": "^3.0.0" }, "devDependencies": { - "@types/chai": "^4.3.5", - "@types/estree": "^1.0.1", - "@types/mdast": "^3.0.12", - "@types/mocha": "^10.0.1", - "@types/yargs-parser": "^21.0.0", + "@types/chai": "^4.3.10", + "@types/estree": "^1.0.5", + "@types/mdast": "^4.0.3", + "@types/mocha": "^10.0.4", + "@types/yargs-parser": "^21.0.3", "astro": "workspace:*", "astro-scripts": "workspace:*", "chai": "^4.3.7", "cheerio": "1.0.0-rc.12", - "linkedom": "^0.15.1", - "mdast-util-mdx": "^2.0.1", - "mdast-util-to-string": "^3.2.0", + "linkedom": "^0.16.4", + "mdast-util-mdx": "^3.0.0", + "mdast-util-to-string": "^4.0.0", "mocha": "^10.2.0", "reading-time": "^1.5.0", - "rehype-mathjax": "^4.0.3", - "rehype-pretty-code": "^0.10.0", - "remark-math": "^5.1.1", - "remark-rehype": "^10.1.0", + "rehype-mathjax": "^5.0.0", + "rehype-pretty-code": "^0.10.2", + "remark-math": "^6.0.0", + "remark-rehype": "^11.0.0", "remark-shiki-twoslash": "^3.1.3", - "remark-toc": "^8.0.1", - "unified": "^10.1.2", - "vite": "^4.4.9" + "remark-toc": "^9.0.0", + "unified": "^11.0.4", + "vite": "^5.0.0" }, "engines": { "node": ">=18.14.1" diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts index fd330625e..f44e19e92 100644 --- a/packages/integrations/mdx/src/index.ts +++ b/packages/integrations/mdx/src/index.ts @@ -1,8 +1,8 @@ import { markdownConfigDefaults, setVfileFrontmatter } from '@astrojs/markdown-remark'; -import type { PluggableList } from '@mdx-js/mdx/lib/core.js'; import type { AstroIntegration, ContentEntryType, HookParameters, SSRError } from 'astro'; import astroJSXRenderer from 'astro/jsx/renderer.js'; import { parse as parseESM } from 'es-module-lexer'; +import type { PluggableList } from 'unified'; import fs from 'node:fs/promises'; import { fileURLToPath } from 'node:url'; import type { Options as RemarkRehypeOptions } from 'remark-rehype'; @@ -190,7 +190,7 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI componentsCode += ' }'; // Make `Content` the default export so we can wrap `MDXContent` and pass in `Fragment` - code = code.replace('export default MDXContent;', ''); + code = code.replace('export default function MDXContent', 'function MDXContent'); code += `\nexport const Content = (props = {}) => MDXContent({ ...props, components: ${componentsCode}, diff --git a/packages/integrations/mdx/src/plugins.ts b/packages/integrations/mdx/src/plugins.ts index 3286a9fd8..e6584aacf 100644 --- a/packages/integrations/mdx/src/plugins.ts +++ b/packages/integrations/mdx/src/plugins.ts @@ -5,12 +5,11 @@ import { remarkShiki, } from '@astrojs/markdown-remark'; import { createProcessor, nodeTypes } from '@mdx-js/mdx'; -import type { PluggableList } from '@mdx-js/mdx/lib/core.js'; import rehypeRaw from 'rehype-raw'; import remarkGfm from 'remark-gfm'; import remarkSmartypants from 'remark-smartypants'; import { SourceMapGenerator } from 'source-map'; -import type { Processor } from 'unified'; +import type { PluggableList } from 'unified'; import type { MdxOptions } from './index.js'; import { recmaInjectImportMetaEnv } from './recma-inject-import-meta-env.js'; import { rehypeApplyFrontmatterExport } from './rehype-apply-frontmatter-export.js'; @@ -27,10 +26,7 @@ interface MdxProcessorExtraOptions { importMetaEnv: Record<string, any>; } -export function createMdxProcessor( - mdxOptions: MdxOptions, - extraOptions: MdxProcessorExtraOptions -): Processor { +export function createMdxProcessor(mdxOptions: MdxOptions, extraOptions: MdxProcessorExtraOptions) { return createProcessor({ remarkPlugins: getRemarkPlugins(mdxOptions), rehypePlugins: getRehypePlugins(mdxOptions), diff --git a/packages/integrations/mdx/src/remark-images-to-component.ts b/packages/integrations/mdx/src/remark-images-to-component.ts index f83f5d76a..810056def 100644 --- a/packages/integrations/mdx/src/remark-images-to-component.ts +++ b/packages/integrations/mdx/src/remark-images-to-component.ts @@ -15,7 +15,7 @@ export function remarkImageToComponent() { const importsStatements: MdxjsEsm[] = []; const importedImages = new Map<string, string>(); - visit(tree, 'image', (node: Image, index: number | null, parent: Parent | null) => { + visit(tree, 'image', (node: Image, index: number | undefined, parent: Parent | null) => { // Use the imagePaths set from the remark-collect-images so we don't have to duplicate the logic for // checking if an image should be imported or not if (file.data.imagePaths?.has(node.url)) { diff --git a/packages/integrations/mdx/src/utils.ts b/packages/integrations/mdx/src/utils.ts index 3425c50e3..a5b198116 100644 --- a/packages/integrations/mdx/src/utils.ts +++ b/packages/integrations/mdx/src/utils.ts @@ -1,10 +1,10 @@ -import type { PluggableList } from '@mdx-js/mdx/lib/core.js'; import type { Options as AcornOpts } from 'acorn'; import { parse } from 'acorn'; import type { AstroConfig, SSRError } from 'astro'; import matter from 'gray-matter'; import { bold, yellow } from 'kleur/colors'; import type { MdxjsEsm } from 'mdast-util-mdx'; +import type { PluggableList } from 'unified'; function appendForwardSlash(path: string) { return path.endsWith('/') ? path : path + '/'; @@ -75,8 +75,8 @@ export function jsToTreeNode( type: 'mdxjsEsm', value: '', data: { + // @ts-expect-error `parse` return types is incompatible but it should work in runtime estree: { - body: [], ...parse(jsString, acornOpts), type: 'Program', sourceType: 'module', diff --git a/packages/integrations/mdx/test/fixtures/mdx-infinite-loop/package.json b/packages/integrations/mdx/test/fixtures/mdx-infinite-loop/package.json index d2fb7a75d..a00e19d5b 100644 --- a/packages/integrations/mdx/test/fixtures/mdx-infinite-loop/package.json +++ b/packages/integrations/mdx/test/fixtures/mdx-infinite-loop/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" } } diff --git a/packages/integrations/mdx/test/mdx-astro-markdown-remarkRehype.test.js b/packages/integrations/mdx/test/mdx-astro-markdown-remarkRehype.test.js index ddcce4ba5..eab2c61b0 100644 --- a/packages/integrations/mdx/test/mdx-astro-markdown-remarkRehype.test.js +++ b/packages/integrations/mdx/test/mdx-astro-markdown-remarkRehype.test.js @@ -79,7 +79,7 @@ describe('MDX with Astro Markdown remark-rehype config', () => { expect(document.querySelector('#footnote-label').textContent).to.equal('Catatan kaki'); expect(document.querySelector('.data-footnote-backref').getAttribute('aria-label')).to.equal( - 'Back to content' + 'Back to reference 1' ); }); }); diff --git a/packages/integrations/mdx/test/mdx-math.test.js b/packages/integrations/mdx/test/mdx-math.test.js index f39ea42c8..52ee94a46 100644 --- a/packages/integrations/mdx/test/mdx-math.test.js +++ b/packages/integrations/mdx/test/mdx-math.test.js @@ -4,7 +4,7 @@ import { parseHTML } from 'linkedom'; import { loadFixture } from '../../../astro/test/test-utils.js'; import remarkMath from 'remark-math'; import rehypeMathjaxSvg from 'rehype-mathjax'; -import rehypeMathjaxChtml from 'rehype-mathjax/chtml.js'; +import rehypeMathjaxChtml from 'rehype-mathjax/chtml'; const FIXTURE_ROOT = new URL('./fixtures/mdx-math/', import.meta.url); diff --git a/packages/integrations/node/package.json b/packages/integrations/node/package.json index b50b3e175..9d67157ff 100644 --- a/packages/integrations/node/package.json +++ b/packages/integrations/node/package.json @@ -41,8 +41,8 @@ }, "devDependencies": { "@types/node": "^18.17.8", - "@types/send": "^0.17.1", - "@types/server-destroy": "^1.0.1", + "@types/send": "^0.17.4", + "@types/server-destroy": "^1.0.3", "astro": "workspace:*", "astro-scripts": "workspace:*", "chai": "^4.3.7", diff --git a/packages/integrations/node/src/createOutgoingHttpHeaders.ts b/packages/integrations/node/src/createOutgoingHttpHeaders.ts index 781a74de6..44bbf81ca 100644 --- a/packages/integrations/node/src/createOutgoingHttpHeaders.ts +++ b/packages/integrations/node/src/createOutgoingHttpHeaders.ts @@ -23,8 +23,7 @@ export const createOutgoingHttpHeaders = ( // if there is > 1 set-cookie header, we have to fix it to be an array of values if (headers.has('set-cookie')) { - // @ts-expect-error - const cookieHeaders = headers.getSetCookie() as string[]; + const cookieHeaders = headers.getSetCookie(); if (cookieHeaders.length > 1) { // the Headers.entries() API already normalized all header names to lower case so we can safely index this as 'set-cookie' nodeHeaders['set-cookie'] = cookieHeaders; diff --git a/packages/integrations/preact/package.json b/packages/integrations/preact/package.json index 29a10439a..84043fb76 100644 --- a/packages/integrations/preact/package.json +++ b/packages/integrations/preact/package.json @@ -37,15 +37,15 @@ "dependencies": { "@babel/plugin-transform-react-jsx": "^7.22.5", "@babel/plugin-transform-react-jsx-development": "^7.22.5", - "@preact/preset-vite": "^2.5.0", + "@preact/preset-vite": "^2.7.0", "@preact/signals": "^1.2.1", "babel-plugin-transform-hook-names": "^1.0.2", - "preact-render-to-string": "^6.2.1" + "preact-render-to-string": "^6.3.1" }, "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", - "preact": "^10.17.1" + "preact": "^10.19.2" }, "peerDependencies": { "preact": "^10.6.5" diff --git a/packages/integrations/prefetch/package.json b/packages/integrations/prefetch/package.json index da199b43a..3291eb1a7 100644 --- a/packages/integrations/prefetch/package.json +++ b/packages/integrations/prefetch/package.json @@ -34,7 +34,7 @@ "test:match": "playwright test -g" }, "devDependencies": { - "@playwright/test": "^1.37.1", + "@playwright/test": "^1.40.0", "astro": "workspace:*", "astro-scripts": "workspace:*" }, diff --git a/packages/integrations/react/package.json b/packages/integrations/react/package.json index c72005a69..482dfccf9 100644 --- a/packages/integrations/react/package.json +++ b/packages/integrations/react/package.json @@ -46,19 +46,19 @@ "test": "mocha --exit --timeout 20000" }, "dependencies": { - "@vitejs/plugin-react": "^4.0.4", + "@vitejs/plugin-react": "^4.2.0", "ultrahtml": "^1.3.0" }, "devDependencies": { - "@types/react": "^18.2.21", - "@types/react-dom": "^18.2.7", + "@types/react": "^18.2.37", + "@types/react-dom": "^18.2.15", "astro": "workspace:*", "astro-scripts": "workspace:*", "chai": "^4.3.7", "cheerio": "1.0.0-rc.12", "react": "^18.1.0", "react-dom": "^18.1.0", - "vite": "^4.4.9", + "vite": "^5.0.0", "mocha": "^10.2.0" }, "peerDependencies": { diff --git a/packages/integrations/react/test/fixtures/react-component/package.json b/packages/integrations/react/test/fixtures/react-component/package.json index cf7b2b057..e7b7ac5d9 100644 --- a/packages/integrations/react/test/fixtures/react-component/package.json +++ b/packages/integrations/react/test/fixtures/react-component/package.json @@ -8,6 +8,6 @@ "astro": "workspace:*", "react": "^18.1.0", "react-dom": "^18.1.0", - "vue": "^3.3.4" + "vue": "^3.3.8" } } diff --git a/packages/integrations/sitemap/src/index.ts b/packages/integrations/sitemap/src/index.ts index 43728b1a3..45f694887 100644 --- a/packages/integrations/sitemap/src/index.ts +++ b/packages/integrations/sitemap/src/index.ts @@ -10,7 +10,6 @@ import { import { ZodError } from 'zod'; import { generateSitemap } from './generate-sitemap.js'; -import { Logger } from './utils/logger.js'; import { validateOptions } from './validate-options.js'; export { EnumChangefreq as ChangeFreqEnum } from 'sitemap'; @@ -62,7 +61,6 @@ function isStatusCodePage(pathname: string): boolean { const createPlugin = (options?: SitemapOptions): AstroIntegration => { let config: AstroConfig; - const logger = new Logger(PKG_NAME); return { name: PKG_NAME, @@ -72,7 +70,7 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { config = cfg; }, - 'astro:build:done': async ({ dir, routes, pages }) => { + 'astro:build:done': async ({ dir, routes, pages, logger }) => { try { if (!config.site) { logger.warn( @@ -178,7 +176,7 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { limit: entryLimit, gzip: false, }); - logger.success(`\`${OUTFILE}\` created at \`${path.relative(process.cwd(), destDir)}\``); + logger.info(`\`${OUTFILE}\` created at \`${path.relative(process.cwd(), destDir)}\``); } catch (err) { if (err instanceof ZodError) { logger.warn(formatConfigErrorMessage(err)); diff --git a/packages/integrations/sitemap/src/utils/logger.ts b/packages/integrations/sitemap/src/utils/logger.ts deleted file mode 100644 index 3292bbdfc..000000000 --- a/packages/integrations/sitemap/src/utils/logger.ts +++ /dev/null @@ -1,46 +0,0 @@ -// @internal -export interface ILogger { - info(msg: string): void; - success(msg: string): void; - warn(msg: string): void; - error(msg: string): void; -} - -// @internal -export class Logger implements ILogger { - private colors = { - reset: '\x1b[0m', - fg: { - red: '\x1b[31m', - green: '\x1b[32m', - yellow: '\x1b[33m', - }, - } as const; - - private packageName: string; - - constructor(packageName: string) { - this.packageName = packageName; - } - - private log(msg: string, prefix = '') { - // eslint-disable-next-line no-console - console.log(`%s${this.packageName}:%s ${msg}\n`, prefix, prefix ? this.colors.reset : ''); - } - - info(msg: string) { - this.log(msg); - } - - success(msg: string) { - this.log(msg, this.colors.fg.green); - } - - warn(msg: string) { - this.log(`Skipped!\n${msg}`, this.colors.fg.yellow); - } - - error(msg: string) { - this.log(`Failed!\n${msg}`, this.colors.fg.red); - } -} diff --git a/packages/integrations/solid/package.json b/packages/integrations/solid/package.json index 7e3fcd11b..407d5d870 100644 --- a/packages/integrations/solid/package.json +++ b/packages/integrations/solid/package.json @@ -40,7 +40,7 @@ "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", - "solid-js": "^1.7.11" + "solid-js": "^1.8.5" }, "peerDependencies": { "solid-js": "^1.4.3" diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json index 4c7e8bb63..003f119cf 100644 --- a/packages/integrations/svelte/package.json +++ b/packages/integrations/svelte/package.json @@ -42,18 +42,18 @@ "dev": "astro-scripts dev \"src/**/*.ts\"" }, "dependencies": { - "@sveltejs/vite-plugin-svelte": "^2.5.2", - "svelte2tsx": "^0.6.20" + "@sveltejs/vite-plugin-svelte": "^3.0.0", + "svelte2tsx": "^0.6.25" }, "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", - "svelte": "^4.2.0", - "vite": "^4.4.9" + "svelte": "^4.2.5", + "vite": "^5.0.0" }, "peerDependencies": { "astro": "^3.0.0", - "svelte": "^3.55.0 || ^4.0.0 || ^5.0.0-next.1" + "svelte": "^4.0.0 || ^5.0.0-next.1" }, "engines": { "node": ">=18.14.1" diff --git a/packages/integrations/svelte/src/index.ts b/packages/integrations/svelte/src/index.ts index 695214223..b894ee623 100644 --- a/packages/integrations/svelte/src/index.ts +++ b/packages/integrations/svelte/src/index.ts @@ -73,6 +73,7 @@ async function getViteConfiguration({ } if (!resolvedOptions.preprocess && !(await svelteConfigHasPreprocess(root))) { + // @ts-expect-error there's a bug with the types where the first arg should be optional resolvedOptions.preprocess = vitePreprocess(); } diff --git a/packages/integrations/tailwind/package.json b/packages/integrations/tailwind/package.json index d093ffc61..c0277b974 100644 --- a/packages/integrations/tailwind/package.json +++ b/packages/integrations/tailwind/package.json @@ -34,13 +34,13 @@ "dependencies": { "autoprefixer": "^10.4.15", "postcss": "^8.4.28", - "postcss-load-config": "^4.0.1" + "postcss-load-config": "^4.0.2" }, "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", - "tailwindcss": "^3.3.3", - "vite": "^4.4.9" + "tailwindcss": "^3.3.5", + "vite": "^5.0.0" }, "peerDependencies": { "astro": "^3.0.0", diff --git a/packages/integrations/tailwind/src/index.ts b/packages/integrations/tailwind/src/index.ts index daee5f857..f0cb5feb4 100644 --- a/packages/integrations/tailwind/src/index.ts +++ b/packages/integrations/tailwind/src/index.ts @@ -33,8 +33,7 @@ async function getViteConfiguration( const postcssOptions = postcssConfigResult?.options ?? {}; const postcssPlugins = postcssConfigResult?.plugins?.slice() ?? []; - // @ts-expect-error Tailwind plugin types are wrong - postcssPlugins.push(tailwindPlugin(tailwindConfigPath) as ResultPlugin); + postcssPlugins.push(tailwindPlugin(tailwindConfigPath)); postcssPlugins.push(autoprefixerPlugin()); return { diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json index dc9433c5a..971f0838e 100644 --- a/packages/integrations/vercel/package.json +++ b/packages/integrations/vercel/package.json @@ -54,9 +54,9 @@ "dependencies": { "@astrojs/internal-helpers": "workspace:*", "@vercel/analytics": "^1.0.2", - "@vercel/nft": "^0.23.1", - "esbuild": "^0.19.2", - "fast-glob": "^3.3.1", + "@vercel/nft": "^0.24.3", + "esbuild": "^0.19.6", + "fast-glob": "^3.3.2", "set-cookie-parser": "^2.6.0", "web-vitals": "^3.4.0" }, @@ -64,8 +64,8 @@ "astro": "^3.0.0" }, "devDependencies": { - "@types/set-cookie-parser": "^2.4.3", - "@vercel/edge": "^1.0.0", + "@types/set-cookie-parser": "^2.4.6", + "@vercel/edge": "^1.1.1", "astro": "workspace:*", "astro-scripts": "workspace:*", "chai": "^4.3.7", diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index b8fa62d38..3d0bca1e2 100644 --- a/packages/integrations/vue/package.json +++ b/packages/integrations/vue/package.json @@ -40,21 +40,21 @@ "test": "mocha --timeout 20000" }, "dependencies": { - "@vitejs/plugin-vue": "^4.3.3", - "@vitejs/plugin-vue-jsx": "^3.0.2", + "@vitejs/plugin-vue": "^4.5.0", + "@vitejs/plugin-vue-jsx": "^3.1.0", "@vue/babel-plugin-jsx": "^1.1.5", - "@vue/compiler-sfc": "^3.3.4" + "@vue/compiler-sfc": "^3.3.8" }, "devDependencies": { - "@types/chai": "^4.3.5", + "@types/chai": "^4.3.10", "astro": "workspace:*", "astro-scripts": "workspace:*", "chai": "^4.3.7", - "linkedom": "^0.15.1", "cheerio": "1.0.0-rc.12", + "linkedom": "^0.16.4", "mocha": "^10.2.0", - "vite": "^4.4.9", - "vue": "^3.3.4" + "vite": "^5.0.0", + "vue": "^3.3.8" }, "peerDependencies": { "astro": "^3.0.0", diff --git a/packages/integrations/vue/test/fixtures/app-entrypoint/package.json b/packages/integrations/vue/test/fixtures/app-entrypoint/package.json index abdab9e4c..0795ba955 100644 --- a/packages/integrations/vue/test/fixtures/app-entrypoint/package.json +++ b/packages/integrations/vue/test/fixtures/app-entrypoint/package.json @@ -3,8 +3,8 @@ "version": "0.0.0", "private": true, "dependencies": { - "astro": "workspace:*", "@astrojs/vue": "workspace:*", - "vite-svg-loader": "4.0.0" + "astro": "workspace:*", + "vite-svg-loader": "5.0.1" } }
\ No newline at end of file diff --git a/packages/markdown/remark/package.json b/packages/markdown/remark/package.json index 9f248eb32..5bae632fc 100644 --- a/packages/markdown/remark/package.json +++ b/packages/markdown/remark/package.json @@ -33,29 +33,29 @@ "dependencies": { "@astrojs/prism": "^3.0.0", "github-slugger": "^2.0.0", - "import-meta-resolve": "^3.0.0", + "import-meta-resolve": "^4.0.0", "mdast-util-definitions": "^6.0.0", - "rehype-raw": "^6.1.1", - "rehype-stringify": "^9.0.4", - "remark-gfm": "^3.0.1", - "remark-parse": "^10.0.2", - "remark-rehype": "^10.1.0", + "rehype-raw": "^7.0.0", + "rehype-stringify": "^10.0.0", + "remark-gfm": "^4.0.0", + "remark-parse": "^11.0.0", + "remark-rehype": "^11.0.0", "remark-smartypants": "^2.0.0", - "shikiji": "^0.6.8", - "unified": "^10.1.2", - "unist-util-visit": "^4.1.2", - "vfile": "^5.3.7" + "shikiji": "^0.6.13", + "unified": "^11.0.4", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.1" }, "devDependencies": { - "@types/chai": "^4.3.5", - "@types/estree": "^1.0.1", - "@types/hast": "^2.3.5", - "@types/mdast": "^3.0.12", - "@types/mocha": "^10.0.1", - "@types/unist": "^2.0.7", + "@types/chai": "^4.3.10", + "@types/estree": "^1.0.5", + "@types/hast": "^3.0.3", + "@types/mdast": "^4.0.3", + "@types/mocha": "^10.0.4", + "@types/unist": "^3.0.2", "astro-scripts": "workspace:*", "chai": "^4.3.7", - "mdast-util-mdx-expression": "^1.3.2", + "mdast-util-mdx-expression": "^2.0.0", "mocha": "^10.2.0" }, "publishConfig": { diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts index a60ab88c0..d42ce480c 100644 --- a/packages/markdown/remark/src/index.ts +++ b/packages/markdown/remark/src/index.ts @@ -102,7 +102,7 @@ export async function createMarkdownProcessor( } // Remark -> Rehype - parser.use(remarkRehype as any, { + parser.use(remarkRehype, { allowDangerousHtml: true, passThrough: [], ...remarkRehypeOptions, diff --git a/packages/markdown/remark/src/types.ts b/packages/markdown/remark/src/types.ts index 7038e2425..b25e92271 100644 --- a/packages/markdown/remark/src/types.ts +++ b/packages/markdown/remark/src/types.ts @@ -1,10 +1,6 @@ import type * as hast from 'hast'; import type * as mdast from 'mdast'; -import type { - one as Handler, - all as Handlers, - Options as RemarkRehypeOptions, -} from 'remark-rehype'; +import type { Options as RemarkRehypeOptions } from 'remark-rehype'; import type { BuiltinTheme, LanguageRegistration, @@ -34,10 +30,7 @@ export type RehypePlugin<PluginParameters extends any[] = any[]> = unified.Plugi export type RehypePlugins = (string | [string, any] | RehypePlugin | [RehypePlugin, any])[]; -export type RemarkRehype = Omit<RemarkRehypeOptions, 'handlers' | 'unknownHandler'> & { - handlers?: typeof Handlers; - handler?: typeof Handler; -}; +export type RemarkRehype = RemarkRehypeOptions; export interface ShikiConfig { langs?: LanguageRegistration[]; diff --git a/packages/telemetry/package.json b/packages/telemetry/package.json index 66edc3fba..f7708ef8b 100644 --- a/packages/telemetry/package.json +++ b/packages/telemetry/package.json @@ -29,19 +29,19 @@ "dist" ], "dependencies": { - "ci-info": "^3.8.0", + "ci-info": "^4.0.0", "debug": "^4.3.4", "dlv": "^1.1.3", - "dset": "^3.1.2", + "dset": "^3.1.3", "is-docker": "^3.0.0", "is-wsl": "^3.0.0", "which-pm-runs": "^1.1.0" }, "devDependencies": { - "@types/debug": "^4.1.8", - "@types/dlv": "^1.1.2", + "@types/debug": "^4.1.12", + "@types/dlv": "^1.1.4", "@types/node": "^18.17.8", - "@types/which-pm-runs": "^1.0.0", + "@types/which-pm-runs": "^1.0.2", "astro-scripts": "workspace:*", "chai": "^4.3.7", "mocha": "^10.2.0" diff --git a/packages/telemetry/src/config.ts b/packages/telemetry/src/config.ts index 6efcb7fe5..dee6c1d25 100644 --- a/packages/telemetry/src/config.ts +++ b/packages/telemetry/src/config.ts @@ -1,5 +1,4 @@ import dget from 'dlv'; -// @ts-expect-error `dset` is mispackaged: https://publint.dev/dset@3.1.2 import { dset } from 'dset'; import fs from 'node:fs'; import os from 'node:os'; diff --git a/packages/underscore-redirects/package.json b/packages/underscore-redirects/package.json index 17daae1a8..31606be68 100644 --- a/packages/underscore-redirects/package.json +++ b/packages/underscore-redirects/package.json @@ -28,8 +28,8 @@ "test": "mocha --exit --timeout 20000" }, "devDependencies": { - "@types/chai": "^4.3.5", - "@types/mocha": "^10.0.1", + "@types/chai": "^4.3.10", + "@types/mocha": "^10.0.4", "astro": "workspace:*", "astro-scripts": "workspace:*", "chai": "^4.3.7", |