| class BuildTimeAstroVersionProvider { | ||
| // Injected during the build through esbuild define | ||
| version = "7.0.0-beta.5"; | ||
| version = "7.0.0-beta.6"; | ||
| } | ||
@@ -5,0 +5,0 @@ export { |
@@ -200,3 +200,3 @@ import { existsSync, promises as fs } from "node:fs"; | ||
| } | ||
| if (previousAstroVersion && previousAstroVersion !== "7.0.0-beta.5") { | ||
| if (previousAstroVersion && previousAstroVersion !== "7.0.0-beta.6") { | ||
| logger.info("Astro version changed"); | ||
@@ -209,4 +209,4 @@ shouldClear = true; | ||
| } | ||
| if ("7.0.0-beta.5") { | ||
| this.#store.metaStore().set("astro-version", "7.0.0-beta.5"); | ||
| if ("7.0.0-beta.6") { | ||
| this.#store.metaStore().set("astro-version", "7.0.0-beta.6"); | ||
| } | ||
@@ -213,0 +213,0 @@ if (currentConfigDigest) { |
@@ -261,6 +261,3 @@ import { fileURLToPath } from "node:url"; | ||
| sessionConfig: sessionConfigToManifest(settings.config.session), | ||
| cacheConfig: cacheConfigToManifest( | ||
| settings.config.experimental?.cache, | ||
| settings.config.experimental?.routeRules | ||
| ), | ||
| cacheConfig: cacheConfigToManifest(settings.config.cache, settings.config.routeRules), | ||
| csp, | ||
@@ -267,0 +264,0 @@ image: { |
@@ -38,2 +38,8 @@ import { fileURLToPath } from "node:url"; | ||
| preserveEntrySignatures: "exports-only", | ||
| checks: { | ||
| ...viteConfig.build?.rolldownOptions?.checks, | ||
| // Disable Rolldown's built-in plugin timing warnings. These fire by default | ||
| // and produce noisy warnings about slow plugins during normal builds. | ||
| pluginTimings: false | ||
| }, | ||
| ...legacyAdapter && settings.buildOutput === "server" ? { input: LEGACY_SSR_ENTRY_VIRTUAL_MODULE } : {}, | ||
@@ -40,0 +46,0 @@ output: { |
| import * as z from 'zod/v4'; | ||
| /** | ||
| * Cache provider configuration (experimental.cache). | ||
| * Provider only - routes are configured via experimental.routeRules. | ||
| * Cache provider configuration (`cache`). | ||
| * Provider only - routes are configured via `routeRules`. | ||
| */ | ||
@@ -14,4 +14,5 @@ export declare const CacheSchema: z.ZodObject<{ | ||
| /** | ||
| * Route rules configuration (experimental.routeRules). | ||
| * Maps glob patterns to route rules. | ||
| * Route rules configuration (`routeRules`). | ||
| * Maps route patterns to route rules. Patterns use the same `[param]` and | ||
| * `[...rest]` syntax as file-based routing; glob wildcards (`*`) are not supported. | ||
| * | ||
@@ -21,4 +22,4 @@ * Example: | ||
| * routeRules: { | ||
| * '/api/*': { swr: 600 }, | ||
| * '/products/*': { maxAge: 3600, tags: ['products'] }, | ||
| * '/api/[...path]': { swr: 600 }, | ||
| * '/products/[...slug]': { maxAge: 3600, tags: ['products'] }, | ||
| * } | ||
@@ -25,0 +26,0 @@ * ``` |
@@ -29,3 +29,3 @@ import { AstroError } from "../../errors/errors.js"; | ||
| "cache", | ||
| "`cache.set()` was called but caching is not enabled. Configure a cache provider in your Astro config under `experimental.cache` to enable caching." | ||
| "`cache.set()` was called but caching is not enabled. Configure a cache provider in your Astro config under `cache` to enable caching." | ||
| ); | ||
@@ -32,0 +32,0 @@ } |
@@ -13,5 +13,5 @@ import type { AstroConfig } from '../../types/public/index.js'; | ||
| /** | ||
| * Extract cache routes from experimental.routeRules config. | ||
| * Extract cache routes from the `routeRules` config. | ||
| */ | ||
| export declare function extractCacheRoutesFromRouteRules(routeRules: AstroConfig['experimental']['routeRules']): Record<string, CacheOptions> | undefined; | ||
| export declare function cacheConfigToManifest(cacheConfig: AstroConfig['experimental']['cache'], routeRulesConfig: AstroConfig['experimental']['routeRules']): SSRManifestCache | undefined; | ||
| export declare function extractCacheRoutesFromRouteRules(routeRules: AstroConfig['routeRules']): Record<string, CacheOptions> | undefined; | ||
| export declare function cacheConfigToManifest(cacheConfig: AstroConfig['cache'], routeRulesConfig: AstroConfig['routeRules']): SSRManifestCache | undefined; |
@@ -10,3 +10,3 @@ import { fileURLToPath } from "node:url"; | ||
| }) { | ||
| const providerConfig = settings.config.experimental?.cache?.provider; | ||
| const providerConfig = settings.config.cache?.provider; | ||
| if (!providerConfig) { | ||
@@ -13,0 +13,0 @@ return; |
@@ -507,2 +507,14 @@ import type { RehypePlugin as _RehypePlugin, RemarkPlugin as _RemarkPlugin, RemarkRehype as _RemarkRehype, Smartypants as _Smartypants, ShikiConfig } from '@astrojs/internal-helpers/markdown'; | ||
| }, z.core.$strict>>>; | ||
| cache: z.ZodOptional<z.ZodObject<{ | ||
| provider: z.ZodOptional<z.ZodObject<{ | ||
| config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; | ||
| entrypoint: z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>; | ||
| name: z.ZodOptional<z.ZodString>; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>>; | ||
| routeRules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{ | ||
| maxAge: z.ZodOptional<z.ZodNumber>; | ||
| swr: z.ZodOptional<z.ZodNumber>; | ||
| tags: z.ZodOptional<z.ZodArray<z.ZodString>>; | ||
| }, z.core.$strip>>>; | ||
| experimental: z.ZodPrefault<z.ZodObject<{ | ||
@@ -516,14 +528,2 @@ clientPrerender: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; | ||
| }, z.core.$strip>>; | ||
| cache: z.ZodOptional<z.ZodObject<{ | ||
| provider: z.ZodOptional<z.ZodObject<{ | ||
| config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; | ||
| entrypoint: z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>; | ||
| name: z.ZodOptional<z.ZodString>; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>>; | ||
| routeRules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{ | ||
| maxAge: z.ZodOptional<z.ZodNumber>; | ||
| swr: z.ZodOptional<z.ZodNumber>; | ||
| tags: z.ZodOptional<z.ZodArray<z.ZodString>>; | ||
| }, z.core.$strip>>>; | ||
| }, z.core.$strict>>; | ||
@@ -530,0 +530,0 @@ legacy: z.ZodPrefault<z.ZodObject<{ |
@@ -330,2 +330,4 @@ import { | ||
| fonts: z.array(FontFamilySchema).optional(), | ||
| cache: CacheSchema.optional(), | ||
| routeRules: RouteRulesSchema.optional(), | ||
| experimental: z.strictObject({ | ||
@@ -335,5 +337,3 @@ clientPrerender: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.clientPrerender), | ||
| chromeDevtoolsWorkspace: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.chromeDevtoolsWorkspace), | ||
| svgOptimizer: SvgOptimizerSchema.optional(), | ||
| cache: CacheSchema.optional(), | ||
| routeRules: RouteRulesSchema.optional() | ||
| svgOptimizer: SvgOptimizerSchema.optional() | ||
| }).prefault({}), | ||
@@ -340,0 +340,0 @@ legacy: z.object({ |
@@ -395,2 +395,14 @@ import type { OutgoingHttpHeaders } from 'node:http'; | ||
| }, z.core.$strict>>>; | ||
| cache: z.ZodOptional<z.ZodObject<{ | ||
| provider: z.ZodOptional<z.ZodObject<{ | ||
| config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; | ||
| entrypoint: z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>; | ||
| name: z.ZodOptional<z.ZodString>; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>>; | ||
| routeRules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{ | ||
| maxAge: z.ZodOptional<z.ZodNumber>; | ||
| swr: z.ZodOptional<z.ZodNumber>; | ||
| tags: z.ZodOptional<z.ZodArray<z.ZodString>>; | ||
| }, z.core.$strip>>>; | ||
| experimental: z.ZodPrefault<z.ZodObject<{ | ||
@@ -404,14 +416,2 @@ clientPrerender: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; | ||
| }, z.core.$strip>>; | ||
| cache: z.ZodOptional<z.ZodObject<{ | ||
| provider: z.ZodOptional<z.ZodObject<{ | ||
| config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; | ||
| entrypoint: z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>; | ||
| name: z.ZodOptional<z.ZodString>; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>>; | ||
| routeRules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{ | ||
| maxAge: z.ZodOptional<z.ZodNumber>; | ||
| swr: z.ZodOptional<z.ZodNumber>; | ||
| tags: z.ZodOptional<z.ZodArray<z.ZodString>>; | ||
| }, z.core.$strip>>>; | ||
| }, z.core.$strict>>; | ||
@@ -595,14 +595,2 @@ legacy: z.ZodPrefault<z.ZodObject<{ | ||
| } | undefined; | ||
| cache?: { | ||
| provider?: { | ||
| entrypoint: string | URL; | ||
| config?: Record<string, any> | undefined; | ||
| name?: string | undefined; | ||
| } | undefined; | ||
| } | undefined; | ||
| routeRules?: Record<string, { | ||
| maxAge?: number | undefined; | ||
| swr?: number | undefined; | ||
| tags?: string[] | undefined; | ||
| }> | undefined; | ||
| }; | ||
@@ -702,2 +690,14 @@ legacy: { | ||
| }[] | undefined; | ||
| cache?: { | ||
| provider?: { | ||
| entrypoint: string | URL; | ||
| config?: Record<string, any> | undefined; | ||
| name?: string | undefined; | ||
| } | undefined; | ||
| } | undefined; | ||
| routeRules?: Record<string, { | ||
| maxAge?: number | undefined; | ||
| swr?: number | undefined; | ||
| tags?: string[] | undefined; | ||
| }> | undefined; | ||
| }, { | ||
@@ -847,14 +847,2 @@ base: string; | ||
| } | undefined; | ||
| cache?: { | ||
| provider?: { | ||
| entrypoint: string | URL; | ||
| config?: Record<string, any> | undefined; | ||
| name?: string | undefined; | ||
| } | undefined; | ||
| } | undefined; | ||
| routeRules?: Record<string, { | ||
| maxAge?: number | undefined; | ||
| swr?: number | undefined; | ||
| tags?: string[] | undefined; | ||
| }> | undefined; | ||
| }; | ||
@@ -954,2 +942,14 @@ legacy: { | ||
| }[] | undefined; | ||
| cache?: { | ||
| provider?: { | ||
| entrypoint: string | URL; | ||
| config?: Record<string, any> | undefined; | ||
| name?: string | undefined; | ||
| } | undefined; | ||
| } | undefined; | ||
| routeRules?: Record<string, { | ||
| maxAge?: number | undefined; | ||
| swr?: number | undefined; | ||
| tags?: string[] | undefined; | ||
| }> | undefined; | ||
| }>>; |
@@ -1,2 +0,2 @@ | ||
| const ASTRO_VERSION = "7.0.0-beta.5"; | ||
| const ASTRO_VERSION = "7.0.0-beta.6"; | ||
| const ASTRO_GENERATOR = `Astro v${ASTRO_VERSION}`; | ||
@@ -3,0 +3,0 @@ const ASTRO_ERROR_HEADER = "X-Astro-Error"; |
@@ -29,3 +29,3 @@ import fs from "node:fs"; | ||
| const logger = restart.container.logger; | ||
| const currentVersion = "7.0.0-beta.5"; | ||
| const currentVersion = "7.0.0-beta.6"; | ||
| const isPrerelease = currentVersion.includes("-"); | ||
@@ -32,0 +32,0 @@ if (!isPrerelease) { |
@@ -796,4 +796,4 @@ const UnknownCompilerError = { | ||
| title: "Cache is not enabled.", | ||
| message: "`Astro.cache` is not available because the cache feature is not enabled. To use caching, configure a cache provider in your Astro config under `experimental.cache`.", | ||
| hint: 'Use an adapter that provides a default cache provider, or set one explicitly: `experimental: { cache: { provider: "..." } }`. See https://docs.astro.build/en/reference/experimental-flags/route-caching/.' | ||
| message: "`Astro.cache` is not available because the cache feature is not enabled. To use caching, configure a cache provider in your Astro config under `cache`.", | ||
| hint: 'Use an adapter that provides a default cache provider, or set one explicitly: `cache: { provider: "..." }`. See https://docs.astro.build/en/guides/caching/.' | ||
| }; | ||
@@ -800,0 +800,0 @@ const CacheQueryConfigConflict = { |
@@ -272,3 +272,3 @@ import colors from "piccolore"; | ||
| ` ${bgGreen(black(` ${commandName} `))} ${green( | ||
| `v${"7.0.0-beta.5"}` | ||
| `v${"7.0.0-beta.6"}` | ||
| )} ${headline}` | ||
@@ -275,0 +275,0 @@ ); |
@@ -86,3 +86,3 @@ import { fileURLToPath } from "node:url"; | ||
| } | ||
| const hasCacheConfig = !!settings.config.experimental?.cache?.provider; | ||
| const hasCacheConfig = !!settings.config.cache?.provider; | ||
| const cacheProviderLine = hasCacheConfig ? `cacheProvider: () => import('${VIRTUAL_CACHE_PROVIDER_ID}'),` : ""; | ||
@@ -185,6 +185,3 @@ const code = ` | ||
| sessionConfig: sessionConfigToManifest(settings.config.session), | ||
| cacheConfig: cacheConfigToManifest( | ||
| settings.config.experimental?.cache, | ||
| settings.config.experimental?.routeRules | ||
| ), | ||
| cacheConfig: cacheConfigToManifest(settings.config.cache, settings.config.routeRules), | ||
| csp, | ||
@@ -191,0 +188,0 @@ image: { |
| import { type Plugin as VitePlugin } from 'vite'; | ||
| import type { AstroSettings } from '../types/astro.js'; | ||
| /** Returns a Vite plugin used to alias paths from tsconfig.json and jsconfig.json. */ | ||
| /** Returns Vite plugins used to alias paths from tsconfig.json and jsconfig.json. */ | ||
| export default function configAliasVitePlugin({ settings, }: { | ||
| settings: AstroSettings; | ||
| }): VitePlugin | null; | ||
| }): VitePlugin[] | null; |
@@ -34,36 +34,15 @@ import fs from "node:fs"; | ||
| }; | ||
| const getViteResolveAlias = (settings) => { | ||
| const { tsConfig, tsConfigPath } = settings; | ||
| if (!tsConfig || !tsConfigPath || !tsConfig.compilerOptions) return []; | ||
| const { baseUrl, paths } = tsConfig.compilerOptions; | ||
| const effectiveBaseUrl = baseUrl ?? (paths ? "." : void 0); | ||
| if (!effectiveBaseUrl) return []; | ||
| const resolvedBaseUrl = path.resolve(path.dirname(tsConfigPath), effectiveBaseUrl); | ||
| const aliases = []; | ||
| if (paths) { | ||
| for (const [aliasPattern, values] of Object.entries(paths)) { | ||
| const resolvedValues = values.map((v) => path.resolve(resolvedBaseUrl, v)); | ||
| const customResolver = (id) => { | ||
| for (const resolvedValue of resolvedValues) { | ||
| const resolved = resolvedValue.replace("*", id); | ||
| const stats = fs.statSync(resolved, { throwIfNoEntry: false }); | ||
| if (stats && stats.isFile()) { | ||
| return normalizePath(resolved); | ||
| } | ||
| } | ||
| return null; | ||
| }; | ||
| aliases.push({ | ||
| // Build regex from alias pattern (e.g., '@styles/*' -> /^@styles\/(.+)$/) | ||
| // First, escape special regex chars. Then replace * with a capture group (.+) | ||
| find: new RegExp( | ||
| `^${aliasPattern.replace(/[\\^$+?.()|[\]{}]/g, "\\$&").replace(/\*/g, "(.+)")}$` | ||
| ), | ||
| replacement: aliasPattern.includes("*") ? "$1" : aliasPattern, | ||
| customResolver | ||
| }); | ||
| function resolveWithAlias(id, configAlias) { | ||
| for (const alias of configAlias) { | ||
| if (alias.find.test(id)) { | ||
| const updatedId = id.replace(alias.find, alias.replacement); | ||
| const stats = fs.statSync(updatedId, { throwIfNoEntry: false }); | ||
| if (stats && stats.isFile()) { | ||
| return normalizePath(updatedId); | ||
| } | ||
| } | ||
| } | ||
| return aliases; | ||
| }; | ||
| return null; | ||
| } | ||
| const cssImportRE = /@import\s+(?:url\(\s*)?['"]([^'"]+)['"]\s*\)?/g; | ||
| function configAliasVitePlugin({ | ||
@@ -74,32 +53,59 @@ settings | ||
| if (!configAlias) return null; | ||
| const plugin = { | ||
| name: "astro:tsconfig-alias", | ||
| // use post to only resolve ids that all other plugins before it can't | ||
| enforce: "post", | ||
| config() { | ||
| return { | ||
| resolve: { | ||
| alias: getViteResolveAlias(settings) | ||
| return [ | ||
| // Pre-plugin: rewrite CSS @import aliases to absolute paths before Vite's CSS plugin. | ||
| // Vite's internal CSS @import resolver (postcss-import) uses a mini plugin container | ||
| // that doesn't include user resolveId hooks, so we must rewrite aliases in a transform | ||
| // hook that runs before Vite's CSS processing. | ||
| { | ||
| name: "astro:tsconfig-alias-css", | ||
| enforce: "pre", | ||
| transform: { | ||
| filter: { | ||
| id: { | ||
| include: /\.css$/ | ||
| } | ||
| }, | ||
| handler(code) { | ||
| if (!code.includes("@import")) return; | ||
| let hasReplacement = false; | ||
| const result = code.replace(cssImportRE, (match, importId) => { | ||
| if (!importId) return match; | ||
| const resolved = resolveWithAlias(importId, configAlias); | ||
| if (resolved) { | ||
| hasReplacement = true; | ||
| return match.replace(importId, resolved); | ||
| } | ||
| return match; | ||
| }); | ||
| if (hasReplacement) { | ||
| return { code: result, map: null }; | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| }, | ||
| resolveId: { | ||
| filter: { | ||
| id: { | ||
| include: configAlias.map((alias) => alias.find), | ||
| exclude: /(?:\0|^virtual:|^astro:)/ | ||
| } | ||
| }, | ||
| async handler(id, importer, options) { | ||
| for (const alias of configAlias) { | ||
| if (alias.find.test(id)) { | ||
| const updatedId = id.replace(alias.find, alias.replacement); | ||
| if (updatedId.includes("*")) { | ||
| return updatedId; | ||
| // Post-plugin: resolve JS/TS imports using tsconfig path aliases via resolveId. | ||
| { | ||
| name: "astro:tsconfig-alias", | ||
| // use post to only resolve ids that all other plugins before it can't | ||
| enforce: "post", | ||
| resolveId: { | ||
| filter: { | ||
| id: { | ||
| include: configAlias.map((alias) => alias.find), | ||
| exclude: /(?:\0|^virtual:|^astro:)/ | ||
| } | ||
| }, | ||
| async handler(id, importer, options) { | ||
| for (const alias of configAlias) { | ||
| if (alias.find.test(id)) { | ||
| const updatedId = id.replace(alias.find, alias.replacement); | ||
| if (updatedId.includes("*")) { | ||
| return updatedId; | ||
| } | ||
| const resolved = await this.resolve(updatedId, importer, { | ||
| skipSelf: true, | ||
| ...options | ||
| }); | ||
| if (resolved) return resolved; | ||
| } | ||
| const resolved = await this.resolve(updatedId, importer, { | ||
| skipSelf: true, | ||
| ...options | ||
| }); | ||
| if (resolved) return resolved; | ||
| } | ||
@@ -109,4 +115,3 @@ } | ||
| } | ||
| }; | ||
| return plugin; | ||
| ]; | ||
| } | ||
@@ -113,0 +118,0 @@ export { |
+2
-2
| { | ||
| "name": "astro", | ||
| "version": "7.0.0-beta.5", | ||
| "version": "7.0.0-beta.6", | ||
| "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", | ||
@@ -169,3 +169,3 @@ "type": "module", | ||
| "@astrojs/internal-helpers": "0.10.0", | ||
| "@astrojs/markdown-satteri": "0.3.1-beta.1", | ||
| "@astrojs/markdown-satteri": "0.3.1-beta.2", | ||
| "@astrojs/telemetry": "3.3.2" | ||
@@ -172,0 +172,0 @@ }, |
Sorry, the diff of this file is too big to display
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
73534
0.01%2793380
-0.01%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed