astro 6.0.0-beta.12 → 6.0.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
  npm create astro@latest
16
16
 
17
17
  # Manual:
18
- npm install --save-dev astro
18
+ npm install astro
19
19
  ```
20
20
 
21
21
  Looking for help? Start with our [Getting Started](https://docs.astro.build/en/getting-started/) guide.
@@ -1,10 +1,18 @@
1
1
  ---
2
- import { type ThemePresets, createShikiHighlighter } from '@astrojs/markdown-remark';
2
+ import {
3
+ type ThemePresets,
4
+ createShikiHighlighter,
5
+ globalShikiStyleCollector,
6
+ transformerStyleToClass,
7
+ } from '@astrojs/markdown-remark';
3
8
  import type { ShikiTransformer, ThemeRegistration, ThemeRegistrationRaw } from 'shiki';
4
9
  import { bundledLanguages } from 'shiki/langs';
5
10
  import type { CodeLanguage } from '../dist/types/public/common.js';
6
11
  import type { HTMLAttributes } from '../types.js';
7
12
 
13
+ // Code.astro always uses Shiki, so import the virtual CSS module
14
+ import 'virtual:astro:shiki-styles.css';
15
+
8
16
  interface Props extends Omit<HTMLAttributes<'pre'>, 'lang'> {
9
17
  /** The code to highlight. Required. */
10
18
  code: string;
@@ -16,6 +24,14 @@ interface Props extends Omit<HTMLAttributes<'pre'>, 'lang'> {
16
24
  * @default "plaintext"
17
25
  */
18
26
  lang?: CodeLanguage;
27
+ /**
28
+ * Additional languages to load.
29
+ * Useful if `code` embeds languages not included by the given `lang`
30
+ * For example, TSX in Vue
31
+ *
32
+ * @default []
33
+ */
34
+ embeddedLangs?: CodeLanguage[];
19
35
  /**
20
36
  * A metastring to pass to the highlighter.
21
37
  * Allows passing information to transformers: https://shiki.style/guide/transformers#meta
@@ -72,6 +88,7 @@ interface Props extends Omit<HTMLAttributes<'pre'>, 'lang'> {
72
88
  const {
73
89
  code,
74
90
  lang = 'plaintext',
91
+ embeddedLangs = [],
75
92
  meta,
76
93
  theme = 'github-dark',
77
94
  themes = {},
@@ -101,16 +118,23 @@ const highlighter = await createShikiHighlighter({
101
118
  ? lang
102
119
  : 'plaintext'
103
120
  : (lang as any),
121
+ ...embeddedLangs,
104
122
  ],
105
123
  theme,
106
124
  themes,
107
125
  });
108
126
 
127
+ // Combine style-to-class transformer with user-provided transformers
128
+ const allTransformers = [
129
+ globalShikiStyleCollector.register(transformerStyleToClass()),
130
+ ...transformers,
131
+ ];
132
+
109
133
  const html = await highlighter.codeToHtml(code, typeof lang === 'string' ? lang : lang.name, {
110
134
  defaultColor,
111
135
  wrap,
112
136
  inline,
113
- transformers,
137
+ transformers: allTransformers,
114
138
  meta,
115
139
  attributes: rest as any,
116
140
  });
@@ -1,29 +1,32 @@
1
- import { type AdobeProviderOptions, type GoogleFamilyOptions, type GoogleiconsFamilyOptions } from 'unifont';
1
+ import { type AdobeProviderOptions, type GoogleFamilyOptions, type GoogleiconsFamilyOptions, type NpmProviderOptions, type NpmFamilyOptions } from 'unifont';
2
2
  import type { FontProvider } from '../types.js';
3
3
  import { type LocalFamilyOptions } from './local.js';
4
- /** [Adobe](https://fonts.adobe.com/) */
4
+ /** [Adobe](https://v6.docs.astro.build/en/reference/font-provider-reference/#adobe) */
5
5
  declare function adobe(config: AdobeProviderOptions): FontProvider;
6
- /** [Bunny](https://fonts.bunny.net/) */
6
+ /** [Bunny](https://v6.docs.astro.build/en/reference/font-provider-reference/#bunny) */
7
7
  declare function bunny(): FontProvider;
8
- /** [Fontshare](https://www.fontshare.com/) */
8
+ /** [Fontshare](https://v6.docs.astro.build/en/reference/font-provider-reference/#fontshare) */
9
9
  declare function fontshare(): FontProvider;
10
- /** [Fontsource](https://fontsource.org/) */
10
+ /** [Fontsource](https://v6.docs.astro.build/en/reference/font-provider-reference/#fontsource) */
11
11
  declare function fontsource(): FontProvider;
12
- /** [Google](https://fonts.google.com/) */
12
+ /** [Google](https://v6.docs.astro.build/en/reference/font-provider-reference/#google) */
13
13
  declare function google(): FontProvider<GoogleFamilyOptions | undefined>;
14
- /** [Google Icons](https://fonts.google.com/icons) */
14
+ /** [Google Icons](https://v6.docs.astro.build/en/reference/font-provider-reference/#google-icons) */
15
15
  declare function googleicons(): FontProvider<GoogleiconsFamilyOptions | undefined>;
16
- /** A provider that handles local files. */
16
+ /** [Local](https://v6.docs.astro.build/en/reference/font-provider-reference/#local) */
17
17
  declare function local(): FontProvider<LocalFamilyOptions>;
18
+ /** [NPM](https://v6.docs.astro.build/en/reference/font-provider-reference/#npm) */
19
+ declare function npm(options?: Omit<NpmProviderOptions, 'root' | 'readFile'>): FontProvider<NpmFamilyOptions | undefined>;
18
20
  /**
19
21
  * Astro exports a few built-in providers:
20
- * - [Adobe](https://fonts.adobe.com/)
21
- * - [Bunny](https://fonts.bunny.net/)
22
- * - [Fontshare](https://www.fontshare.com/)
23
- * - [Fontsource](https://fontsource.org/)
24
- * - [Google](https://fonts.google.com/)
25
- * - [Google Icons](https://fonts.google.com/icons)
26
- * - Local
22
+ * - [Adobe](https://v6.docs.astro.build/en/reference/font-provider-reference/#adobe)
23
+ * - [Bunny](https://v6.docs.astro.build/en/reference/font-provider-reference/#bunny)
24
+ * - [Fontshare](https://v6.docs.astro.build/en/reference/font-provider-reference/#fontshare)
25
+ * - [Fontsource](https://v6.docs.astro.build/en/reference/font-provider-reference/#fontsource)
26
+ * - [Google](https://v6.docs.astro.build/en/reference/font-provider-reference/#google)
27
+ * - [Google Icons](https://v6.docs.astro.build/en/reference/font-provider-reference/#google-icons)
28
+ * - [Local](https://v6.docs.astro.build/en/reference/font-provider-reference/#local)
29
+ * - [NPM](TODO:)
27
30
  */
28
31
  export declare const fontProviders: {
29
32
  adobe: typeof adobe;
@@ -33,5 +36,6 @@ export declare const fontProviders: {
33
36
  google: typeof google;
34
37
  googleicons: typeof googleicons;
35
38
  local: typeof local;
39
+ npm: typeof npm;
36
40
  };
37
41
  export {};
@@ -3,6 +3,8 @@ import {
3
3
  } from "unifont";
4
4
  import { FontaceFontFileReader } from "../infra/fontace-font-file-reader.js";
5
5
  import { LocalFontProvider } from "./local.js";
6
+ import { fileURLToPath } from "node:url";
7
+ import { readFile } from "node:fs/promises";
6
8
  function adobe(config) {
7
9
  const provider = providers.adobe(config);
8
10
  let initializedProvider;
@@ -105,6 +107,25 @@ function local() {
105
107
  fontFileReader: new FontaceFontFileReader()
106
108
  });
107
109
  }
110
+ function npm(options) {
111
+ let initializedProvider;
112
+ return {
113
+ name: providers.npm()._name,
114
+ async init(context) {
115
+ initializedProvider = await providers.npm({
116
+ ...options,
117
+ root: fileURLToPath(context.root),
118
+ readFile: (path) => readFile(path, "utf-8").catch(() => null)
119
+ })(context);
120
+ },
121
+ async resolveFont({ familyName, ...rest }) {
122
+ return await initializedProvider?.resolveFont(familyName, rest);
123
+ },
124
+ async listFonts() {
125
+ return await initializedProvider?.listFonts?.();
126
+ }
127
+ };
128
+ }
108
129
  const fontProviders = {
109
130
  adobe,
110
131
  bunny,
@@ -112,7 +133,8 @@ const fontProviders = {
112
133
  fontsource,
113
134
  google,
114
135
  googleicons,
115
- local
136
+ local,
137
+ npm
116
138
  };
117
139
  export {
118
140
  fontProviders
@@ -1,6 +1,6 @@
1
1
  class BuildTimeAstroVersionProvider {
2
2
  // Injected during the build through esbuild define
3
- version = "6.0.0-beta.12";
3
+ version = "6.0.0-beta.13";
4
4
  }
5
5
  export {
6
6
  BuildTimeAstroVersionProvider
@@ -181,7 +181,7 @@ ${contentConfig.error.message}`
181
181
  logger.info("Content config changed");
182
182
  shouldClear = true;
183
183
  }
184
- if (previousAstroVersion && previousAstroVersion !== "6.0.0-beta.12") {
184
+ if (previousAstroVersion && previousAstroVersion !== "6.0.0-beta.13") {
185
185
  logger.info("Astro version changed");
186
186
  shouldClear = true;
187
187
  }
@@ -189,8 +189,8 @@ ${contentConfig.error.message}`
189
189
  logger.info("Clearing content store");
190
190
  this.#store.clearAll();
191
191
  }
192
- if ("6.0.0-beta.12") {
193
- await this.#store.metaStore().set("astro-version", "6.0.0-beta.12");
192
+ if ("6.0.0-beta.13") {
193
+ await this.#store.metaStore().set("astro-version", "6.0.0-beta.13");
194
194
  }
195
195
  if (currentConfigDigest) {
196
196
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -1,2 +1,2 @@
1
- import type { BaseApp } from '../../base.js';
2
- export declare function createApp(): BaseApp;
1
+ import type { CreateApp } from '../../types.js';
2
+ export declare const createApp: CreateApp;
@@ -2,9 +2,9 @@ import { manifest } from "virtual:astro:manifest";
2
2
  import { DevApp } from "../../dev/app.js";
3
3
  import { createConsoleLogger } from "../../logging.js";
4
4
  let currentDevApp = null;
5
- function createApp() {
5
+ const createApp = ({ streaming } = {}) => {
6
6
  const logger = createConsoleLogger(manifest.logLevel);
7
- currentDevApp = new DevApp(manifest, true, logger);
7
+ currentDevApp = new DevApp(manifest, streaming, logger);
8
8
  if (import.meta.hot) {
9
9
  import.meta.hot.on("astro:routes-updated", async () => {
10
10
  if (!currentDevApp) return;
@@ -21,7 +21,7 @@ function createApp() {
21
21
  });
22
22
  }
23
23
  return currentDevApp;
24
- }
24
+ };
25
25
  export {
26
26
  createApp
27
27
  };
@@ -1,2 +1,2 @@
1
- import type { BaseApp } from '../../base.js';
2
- export declare const createApp: () => BaseApp;
1
+ import type { CreateApp } from '../../types.js';
2
+ export declare const createApp: CreateApp;
@@ -1,2 +1,2 @@
1
- import type { BaseApp } from '../../base.js';
2
- export declare function createApp(): BaseApp;
1
+ import type { CreateApp } from '../../types.js';
2
+ export declare const createApp: CreateApp;
@@ -1,8 +1,8 @@
1
1
  import { manifest } from "virtual:astro:manifest";
2
2
  import { App } from "../../app.js";
3
- function createApp() {
4
- return new App(manifest);
5
- }
3
+ const createApp = ({ streaming } = {}) => {
4
+ return new App(manifest, streaming);
5
+ };
6
6
  export {
7
7
  createApp
8
8
  };
@@ -9,6 +9,7 @@ import type { LoggerLevel } from '../logger/core.js';
9
9
  import type { RoutingStrategies } from './common.js';
10
10
  import type { BaseSessionConfig, SessionDriverFactory } from '../session/types.js';
11
11
  import type { DevToolbarPlacement } from '../../types/public/toolbar.js';
12
+ import type { BaseApp } from './base.js';
12
13
  type ComponentPath = string;
13
14
  export type StylesheetAsset = {
14
15
  type: 'inline';
@@ -168,4 +169,7 @@ export type NodeAppHeadersJson = {
168
169
  value: string;
169
170
  }[];
170
171
  }[];
172
+ export type CreateApp = (options?: {
173
+ streaming?: boolean;
174
+ }) => BaseApp;
171
175
  export {};
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "6.0.0-beta.12";
1
+ const ASTRO_VERSION = "6.0.0-beta.13";
2
2
  const ASTRO_GENERATOR = `Astro v${ASTRO_VERSION}`;
3
3
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
4
4
  const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
@@ -49,6 +49,7 @@ import { vitePluginEnvironment } from "../vite-plugin-environment/index.js";
49
49
  import { ASTRO_VITE_ENVIRONMENT_NAMES } from "./constants.js";
50
50
  import { vitePluginChromedevtools } from "../vite-plugin-chromedevtools/index.js";
51
51
  import { vitePluginAstroServerClient } from "../vite-plugin-overlay/index.js";
52
+ import { vitePluginShikiStyles } from "../vite-plugin-shiki-styles/index.js";
52
53
  async function createVite(commandConfig, { settings, logger, mode, command, fs = nodeFs, sync, routesList }) {
53
54
  const astroPkgsConfig = await crawlFrameworkPkgs({
54
55
  root: fileURLToPath(settings.config.root),
@@ -90,7 +91,11 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
90
91
  appType: "custom",
91
92
  plugins: [
92
93
  serializedManifestPlugin({ settings, command, sync }),
93
- vitePluginRenderers({ settings }),
94
+ vitePluginRenderers({
95
+ settings,
96
+ routesList,
97
+ command: command === "dev" ? "serve" : "build"
98
+ }),
94
99
  vitePluginStaticPaths(),
95
100
  await astroPluginRoutes({ routesList, settings, logger, fsMod: fs, command }),
96
101
  astroVirtualManifestPlugin(),
@@ -130,7 +135,8 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
130
135
  vitePluginSessionDriver({ settings }),
131
136
  astroContainer(),
132
137
  astroHmrReloadPlugin(),
133
- vitePluginChromedevtools({ settings })
138
+ vitePluginChromedevtools({ settings }),
139
+ vitePluginShikiStyles()
134
140
  ],
135
141
  publicDir: fileURLToPath(settings.config.publicDir),
136
142
  root: fileURLToPath(settings.config.root),
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
22
22
  await telemetry.record([]);
23
23
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
24
24
  const logger = restart.container.logger;
25
- const currentVersion = "6.0.0-beta.12";
25
+ const currentVersion = "6.0.0-beta.13";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -28,7 +28,7 @@ function serverStart({
28
28
  host,
29
29
  base
30
30
  }) {
31
- const version = "6.0.0-beta.12";
31
+ const version = "6.0.0-beta.13";
32
32
  const localPrefix = `${dim("\u2503")} Local `;
33
33
  const networkPrefix = `${dim("\u2503")} Network `;
34
34
  const emptyPrefix = " ".repeat(11);
@@ -265,7 +265,7 @@ function printHelp({
265
265
  message.push(
266
266
  linebreak(),
267
267
  ` ${bgGreen(black(` ${commandName} `))} ${green(
268
- `v${"6.0.0-beta.12"}`
268
+ `v${"6.0.0-beta.13"}`
269
269
  )} ${headline}`
270
270
  );
271
271
  }
@@ -382,10 +382,12 @@ class RenderContext {
382
382
  },
383
383
  get csp() {
384
384
  if (!pipeline.manifest.csp) {
385
- pipeline.logger.warn(
386
- "csp",
387
- `context.csp was used when rendering the route ${colors.green(this.routePattern)}, but CSP was not configured. For more information, see https://docs.astro.build/en/reference/experimental-flags/csp/`
388
- );
385
+ if (pipeline.runtimeMode === "production") {
386
+ pipeline.logger.warn(
387
+ "csp",
388
+ `context.csp was used when rendering the route ${colors.green(this.routePattern)}, but CSP was not configured. For more information, see https://docs.astro.build/en/reference/experimental-flags/csp/`
389
+ );
390
+ }
389
391
  return void 0;
390
392
  }
391
393
  return {
@@ -601,10 +603,12 @@ class RenderContext {
601
603
  },
602
604
  get csp() {
603
605
  if (!pipeline.manifest.csp) {
604
- pipeline.logger.warn(
605
- "csp",
606
- `Astro.csp was used when rendering the route ${colors.green(this.routePattern)}, but CSP was not configured. For more information, see https://docs.astro.build/en/reference/experimental-flags/csp/`
607
- );
606
+ if (pipeline.runtimeMode === "production") {
607
+ pipeline.logger.warn(
608
+ "csp",
609
+ `Astro.csp was used when rendering the route ${colors.green(this.routePattern)}, but CSP was not configured. For more information, see https://docs.astro.build/en/reference/experimental-flags/csp/`
610
+ );
611
+ }
608
612
  return void 0;
609
613
  }
610
614
  return {
@@ -2,7 +2,7 @@ import { clsx } from "clsx";
2
2
  import { HTMLString, markHTMLString } from "../escape.js";
3
3
  import { isPromise } from "../util.js";
4
4
  const voidElementNames = /^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
5
- const htmlBooleanAttributes = /^(?:allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|hidden|inert|loop|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|selected|itemscope)$/i;
5
+ const htmlBooleanAttributes = /^(?:allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|inert|loop|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|selected|itemscope)$/i;
6
6
  const AMPERSAND_REGEX = /&/g;
7
7
  const DOUBLE_QUOTE_REGEX = /"/g;
8
8
  const STATIC_DIRECTIVES = /* @__PURE__ */ new Set(["set:html", "set:text"]);
@@ -87,6 +87,9 @@ Make sure to use the static attribute syntax (\`${key}={value}\`) instead of the
87
87
  if (key === "download" && typeof value === "boolean") {
88
88
  return handleBooleanAttribute(key, value, shouldEscape, tagName);
89
89
  }
90
+ if (key === "hidden" && typeof value === "boolean") {
91
+ return handleBooleanAttribute(key, value, shouldEscape, tagName);
92
+ }
90
93
  return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
91
94
  }
92
95
  function internalSpreadAttributes(values, shouldEscape = true, tagName) {
@@ -66,60 +66,98 @@ export type AdapterSupportWithMessage = {
66
66
  export type AdapterSupport = AdapterSupportsKind | AdapterSupportWithMessage;
67
67
  export interface AstroAdapterFeatures {
68
68
  /**
69
- * Creates an edge function that will communicate with the Astro middleware
69
+ * Defines whether any on-demand rendering middleware code will be bundled when built. When enabled, this prevents
70
+ * middleware code from being bundled and imported by all pages during the build.
70
71
  */
71
72
  edgeMiddleware: boolean;
72
73
  /**
73
- * Determine the type of build output the adapter is intended for. Defaults to `server`;
74
+ * Allows you to force a specific output shape for the build. This can be useful for adapters that only work with
75
+ * a specific output type. For example, your adapter might expect a static website so it can create host-specific
76
+ * files. Defaults to `server` if not specified.
74
77
  */
75
78
  buildOutput?: 'static' | 'server';
76
79
  /**
77
- * If supported by the adapter and enabled, Astro won't add any `<meta http-equiv>` tags
78
- * in the static pages, instead it will return a mapping in the
79
- * `astro:build:generated` hook, so adapters can consume them and add them inside
80
- * their hosting headers configuration file.
81
- *
82
- * Future features may decide to use this feature to create/add headers for static pages.
80
+ * Whether or not the adapter provides support for setting response headers for static pages. When this feature is
81
+ * enabled, Astro will return a map of the `Headers` emitted by the static pages. This map is available as `routeToHeaders`
82
+ * in the `astro:build:generated` hook and can be used to generate platform-specific output that controls HTTP headers,
83
+ * for example, to create a `_headers` file for platforms that support it.
83
84
  */
84
85
  staticHeaders?: boolean;
85
86
  }
86
87
  interface AdapterExplicitProperties {
87
88
  /**
88
- * Determines how the adapter's entrypoint is handled during the build.
89
- * - `'auto'`: The adapter defines its own entrypoint and provides either serverEntrypoint or rollupOptions.input
90
- * - `'explicit'`: Uses the virtual module entrypoint with dynamic exports
91
- * @default 'explicit'
92
- * @deprecated This will be removed in a future major version and `'auto'` will become the default
89
+ * @deprecated `entrypointResolution: "explicit"` is deprecated. `entrypointResolution: "auto"` will become the default,
90
+ * and only, behavior in a future major version. See [how to migrate](https://v6.docs.astro.build/en/guides/upgrade-to/v6/#deprecated-createexports-and-start-adapter-api).
91
+ *
92
+ * Specifies the method Astro will use to resolve the server entrypoint: `"auto"` (recommended)
93
+ * or `"explicit"` (default, but deprecated):
94
+ *
95
+ * - **`"auto"` (recommended):** You are responsible for providing a valid module as an entrypoint
96
+ * using either `serverEntrypoint` or, if you need further customization at the Vite level using `vite.build.rollupOptions.input`.
97
+ * - **`"explicit"` (deprecated)**: You must provide the exports required by the host in the server entrypoint
98
+ * using a `createExports()` function before passing them to `setAdapter()` as an [`exports`](#exports) list. This supports
99
+ * adapters built using the Astro 5 version of the Adapter API. By default, all adapters will receive this value to allow backwards
100
+ * compatibility. **However, no new adapters should be created with this value.** Existing adapters should override this default
101
+ * value with `"auto"` as soon as they are able to migrate to the new v6 API.
93
102
  */
94
103
  entrypointResolution?: 'explicit';
104
+ /**
105
+ * Defines the entrypoint for on-demand rendering.
106
+ */
95
107
  serverEntrypoint?: string | URL;
96
- /** @deprecated This will be removed in a future major version, alongside `entrypointResolution: 'explicit'` */
108
+ /**
109
+ * @deprecated This will be removed in a future major version, alongside `entrypointResolution: 'explicit'`.
110
+ *
111
+ * Defines an array of named exports to use in conjunction with the `createExports()` function of your server entrypoint.
112
+ */
97
113
  exports?: string[];
98
- /** @deprecated This will be removed in a future major version, alongside `entrypointResolution: 'explicit'` */
114
+ /**
115
+ * @deprecated This will be removed in a future major version, alongside `entrypointResolution: 'explicit'`.
116
+ *
117
+ * A JSON-serializable value that will be passed to the adapter's server entrypoint at runtime. This is useful to pass an object containing build-time configuration (e.g. paths, secrets) to your server runtime code.
118
+ */
99
119
  args?: any;
100
120
  }
101
121
  interface AdapterAutoProperties {
102
122
  /**
103
- * Determines how the adapter's entrypoint is handled during the build.
104
- * - `'auto'`: The adapter defines its own entrypoint and provides either serverEntrypoint or rollupOptions.input
105
- * - `'explicit'`: Uses the virtual module entrypoint with dynamic exports
106
- * @default 'explicit'
123
+ * Specifies the method Astro will use to resolve the server entrypoint: `"auto"` (recommended)
124
+ * or `"explicit"` (default, but deprecated):
125
+ *
126
+ * - **`"auto"` (recommended):** You are responsible for providing a valid module as an entrypoint
127
+ * using either `serverEntrypoint` or, if you need further customization at the Vite level using `vite.build.rollupOptions.input`.
128
+ * - **`"explicit"` (deprecated)**: You must provide the exports required by the host in the server entrypoint
129
+ * using a `createExports()` function before passing them to `setAdapter()` as an [`exports`](#exports) list. This supports
130
+ * adapters built using the Astro 5 version of the Adapter API. By default, all adapters will receive this value to allow backwards
131
+ * compatibility. **However, no new adapters should be created with this value.** Existing adapters should override this default
132
+ * value with `"auto"` as soon as they are able to migrate to the new v6 API.
107
133
  */
108
134
  entrypointResolution: 'auto';
135
+ /**
136
+ * Defines the entrypoint for on-demand rendering.
137
+ */
109
138
  serverEntrypoint?: string | URL;
110
139
  }
111
140
  export type AstroAdapter = {
141
+ /**
142
+ * Defines a unique name for your adapter. This will be used for logging.
143
+ */
112
144
  name: string;
145
+ /**
146
+ * Defines the path or ID of a module in the adapter's package that is responsible for starting up the built
147
+ * server when `astro preview` is run.
148
+ */
113
149
  previewEntrypoint?: string | URL;
150
+ /**
151
+ * An object that specifies which adapter features that change the build output are supported by the adapter.
152
+ */
114
153
  adapterFeatures?: AstroAdapterFeatures;
115
154
  /**
116
- * List of features supported by an adapter.
117
- *
118
- * If the adapter is not able to handle certain configurations, Astro will throw an error.
155
+ * A map of Astro's built-in features supported by the adapter. This allows Astro to determine which features an
156
+ * adapter supports, so appropriate error messages can be provided.
119
157
  */
120
158
  supportedAstroFeatures: AstroAdapterFeatureMap;
121
159
  /**
122
- * Configuration for Astro's client-side code.
160
+ * A configuration object for Astro's client-side code.
123
161
  */
124
162
  client?: AstroAdapterClientConfig;
125
163
  } & (AdapterExplicitProperties | AdapterAutoProperties);
@@ -160,27 +198,31 @@ export interface AstroPrerenderer {
160
198
  }
161
199
  export type AstroAdapterFeatureMap = {
162
200
  /**
163
- * The adapter is able to serve static pages
201
+ * Defines whether the adapter is able to serve static pages.
164
202
  */
165
203
  staticOutput?: AdapterSupport;
166
204
  /**
167
- * The adapter is able to serve pages that are static or rendered via server
205
+ * Defines whether the adapter is able to serve sites that include a mix of static and on-demand rendered pages.
168
206
  */
169
207
  hybridOutput?: AdapterSupport;
170
208
  /**
171
- * The adapter is able to serve SSR pages
209
+ * Defines whether the adapter is able to serve on-demand rendered pages.
172
210
  */
173
211
  serverOutput?: AdapterSupport;
174
212
  /**
175
- * The adapter is able to support i18n domains
213
+ * Defines whether the adapter is able to support i18n domains.
176
214
  */
177
215
  i18nDomains?: AdapterSupport;
178
216
  /**
179
- * The adapter is able to support `getSecret` exported from `astro:env/server`
217
+ * Defines whether the adapter is able to support `getSecret()` exported from `astro:env/server`. When enabled, this feature
218
+ * allows your adapter to retrieve secrets configured by users in `env.schema`.
219
+ *
220
+ * The `astro/env/setup` module allows you to provide an implementation for `getSecret()`. In your server entrypoint, call
221
+ * `setGetEnv()` as soon as possible.
180
222
  */
181
223
  envGetSecret?: AdapterSupport;
182
224
  /**
183
- * The adapter supports image transformation using the built-in Sharp image service
225
+ * Defines whether the adapter supports image transformation using the built-in Sharp image service.
184
226
  */
185
227
  sharpImageService?: AdapterSupport;
186
228
  };
@@ -98,12 +98,15 @@ function markdown({ settings, logger }) {
98
98
  `[${id}] Astro now supports MDX! Support for components in ".md" (or alternative extensions like ".markdown") files using the "setup" frontmatter is no longer enabled by default. Migrate this file to MDX.`
99
99
  );
100
100
  }
101
+ const usesShiki = settings.config.markdown.syntaxHighlight === "shiki" || settings.config.markdown.syntaxHighlight === void 0;
102
+ const hasCodeBlocks = renderResult.metadata.hasCodeBlocks ?? false;
101
103
  const code = `
102
- import { unescapeHTML, spreadAttributes, createComponent, render, renderComponent, maybeRenderHead } from ${JSON.stringify(
104
+ import { unescapeHTML, spreadAttributes, createComponent, render, renderComponent, maybeRenderHead } from ${JSON.stringify(
103
105
  astroServerRuntimeModulePath
104
106
  )};
105
- import { AstroError, AstroErrorData } from ${JSON.stringify(astroErrorModulePath)};
106
- ${layout ? `import Layout from ${JSON.stringify(layout)};` : ""}
107
+ import { AstroError, AstroErrorData } from ${JSON.stringify(astroErrorModulePath)};
108
+ ${layout ? `import Layout from ${JSON.stringify(layout)};` : ""}
109
+ ${usesShiki && hasCodeBlocks ? `import 'virtual:astro:shiki-styles.css';` : ""}
107
110
 
108
111
  ${// Only include the code relevant to `astro:assets` if there's images in the file
109
112
  localImagePaths.length > 0 || remoteImagePaths.length > 0 ? getMarkdownCodeForImages(localImagePaths, remoteImagePaths, html) : `const html = () => ${JSON.stringify(html)};`}
@@ -1,8 +1,10 @@
1
- import type { Plugin as VitePlugin } from 'vite';
2
- import type { AstroSettings } from '../types/astro.js';
1
+ import type { ConfigEnv, Plugin as VitePlugin } from 'vite';
2
+ import type { AstroSettings, RoutesList } from '../types/astro.js';
3
3
  export declare const ASTRO_RENDERERS_MODULE_ID = "virtual:astro:renderers";
4
4
  interface PluginOptions {
5
5
  settings: AstroSettings;
6
+ routesList: RoutesList;
7
+ command: ConfigEnv['command'];
6
8
  }
7
9
  export default function vitePluginRenderers(options: PluginOptions): VitePlugin;
8
10
  export {};
@@ -1,5 +1,11 @@
1
+ import { ASTRO_VITE_ENVIRONMENT_NAMES } from "../core/constants.js";
1
2
  const ASTRO_RENDERERS_MODULE_ID = "virtual:astro:renderers";
2
3
  const RESOLVED_ASTRO_RENDERERS_MODULE_ID = `\0${ASTRO_RENDERERS_MODULE_ID}`;
4
+ function ssrBuildNeedsRenderers(routesList) {
5
+ return routesList.routes.some(
6
+ (route) => route.type === "page" && !route.prerender && route.origin !== "internal"
7
+ );
8
+ }
3
9
  function vitePluginRenderers(options) {
4
10
  const renderers = options.settings.renderers;
5
11
  return {
@@ -18,6 +24,9 @@ function vitePluginRenderers(options) {
18
24
  id: new RegExp(`^${RESOLVED_ASTRO_RENDERERS_MODULE_ID}$`)
19
25
  },
20
26
  handler() {
27
+ if (options.command === "build" && this.environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr && renderers.length > 0 && !ssrBuildNeedsRenderers(options.routesList)) {
28
+ return { code: `export const renderers = [];` };
29
+ }
21
30
  if (renderers.length > 0) {
22
31
  const imports = [];
23
32
  const exports = [];
@@ -0,0 +1,9 @@
1
+ import type { Plugin } from 'vite';
2
+ /**
3
+ * Vite plugin that provides a virtual CSS module containing all Shiki syntax highlighting styles.
4
+ *
5
+ * This plugin collects styles from the style-to-class transformer used by both Code.astro
6
+ * and Markdown processing, and bundles them into a single CSS file. The .css extension
7
+ * ensures Vite processes this through its CSS pipeline (minification, hashing, etc.).
8
+ */
9
+ export declare function vitePluginShikiStyles(): Plugin;
@@ -0,0 +1,44 @@
1
+ import { globalShikiStyleCollector } from "@astrojs/markdown-remark";
2
+ const VIRTUAL_SHIKI_STYLES_ID = "virtual:astro:shiki-styles.css";
3
+ const RESOLVED_VIRTUAL_SHIKI_STYLES_ID = "\0virtual:astro:shiki-styles.css";
4
+ function vitePluginShikiStyles() {
5
+ return {
6
+ name: "astro:shiki-styles",
7
+ buildStart() {
8
+ globalShikiStyleCollector.clear();
9
+ },
10
+ resolveId: {
11
+ filter: {
12
+ id: new RegExp(`^${VIRTUAL_SHIKI_STYLES_ID}$`)
13
+ },
14
+ handler(id) {
15
+ if (id === VIRTUAL_SHIKI_STYLES_ID) {
16
+ return RESOLVED_VIRTUAL_SHIKI_STYLES_ID;
17
+ }
18
+ }
19
+ },
20
+ load: {
21
+ filter: {
22
+ id: new RegExp(`^${RESOLVED_VIRTUAL_SHIKI_STYLES_ID}$`)
23
+ },
24
+ handler(id) {
25
+ if (id === RESOLVED_VIRTUAL_SHIKI_STYLES_ID) {
26
+ const css = globalShikiStyleCollector.collectCSS();
27
+ return css || "/* Shiki styles will be generated during build */";
28
+ }
29
+ }
30
+ },
31
+ // Handle HMR invalidation when markdown/astro files change
32
+ handleHotUpdate({ file, server }) {
33
+ if (file.endsWith(".md") || file.endsWith(".mdx") || file.endsWith(".astro")) {
34
+ const module = server.moduleGraph.getModuleById(RESOLVED_VIRTUAL_SHIKI_STYLES_ID);
35
+ if (module) {
36
+ server.moduleGraph.invalidateModule(module);
37
+ }
38
+ }
39
+ }
40
+ };
41
+ }
42
+ export {
43
+ vitePluginShikiStyles
44
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "6.0.0-beta.12",
3
+ "version": "6.0.0-beta.13",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",
@@ -144,7 +144,7 @@
144
144
  "tinyglobby": "^0.2.15",
145
145
  "tsconfck": "^3.1.6",
146
146
  "ultrahtml": "^1.6.0",
147
- "unifont": "~0.7.3",
147
+ "unifont": "~0.7.4",
148
148
  "unist-util-visit": "^5.1.0",
149
149
  "unstorage": "^1.17.4",
150
150
  "vfile": "^6.0.3",
@@ -154,7 +154,7 @@
154
154
  "yargs-parser": "^22.0.0",
155
155
  "zod": "^4.3.6",
156
156
  "@astrojs/internal-helpers": "0.8.0-beta.1",
157
- "@astrojs/markdown-remark": "7.0.0-beta.6",
157
+ "@astrojs/markdown-remark": "7.0.0-beta.7",
158
158
  "@astrojs/telemetry": "3.3.0"
159
159
  },
160
160
  "optionalDependencies": {
@@ -33,7 +33,6 @@ declare module 'astro:content' {
33
33
  /** Run `astro dev` or `astro sync` to generate high fidelity types */
34
34
  export type CollectionKey = any;
35
35
  /** Run `astro dev` or `astro sync` to generate high fidelity types */
36
- // biome-ignore lint/correctness/noUnusedVariables: stub generic type to match generated type
37
36
  export type CollectionEntry<C> = any;
38
37
  /** Run `astro dev` or `astro sync` to generate high fidelity types */
39
38
  export type ContentCollectionKey = any;