astro 6.2.1 → 7.0.0-alpha.0

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.
Files changed (54) hide show
  1. package/dist/assets/utils/assets.d.ts +4 -5
  2. package/dist/assets/utils/node.d.ts +2 -2
  3. package/dist/assets/vite-plugin-assets.js +1 -1
  4. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  5. package/dist/content/content-layer.js +3 -3
  6. package/dist/content/runtime-assets.d.ts +2 -2
  7. package/dist/content/utils.d.ts +2 -3
  8. package/dist/core/build/add-rolldown-input.d.ts +2 -0
  9. package/dist/core/build/{add-rollup-input.js → add-rolldown-input.js} +3 -3
  10. package/dist/core/build/graph.d.ts +8 -8
  11. package/dist/core/build/plugins/plugin-analyzer.js +1 -1
  12. package/dist/core/build/plugins/plugin-component-entry.d.ts +1 -1
  13. package/dist/core/build/plugins/plugin-component-entry.js +3 -3
  14. package/dist/core/build/plugins/plugin-internals.js +1 -1
  15. package/dist/core/build/plugins/plugin-prerender.js +1 -1
  16. package/dist/core/build/static-build.d.ts +2 -2
  17. package/dist/core/build/static-build.js +31 -31
  18. package/dist/core/build/util.d.ts +2 -2
  19. package/dist/core/build/util.js +2 -2
  20. package/dist/core/compile/compile.d.ts +1 -1
  21. package/dist/core/compile/compile.js +20 -16
  22. package/dist/core/config/schemas/base.d.ts +4 -6
  23. package/dist/core/config/schemas/base.js +7 -9
  24. package/dist/core/config/schemas/relative.d.ts +7 -7
  25. package/dist/core/config/schemas/relative.js +3 -2
  26. package/dist/core/constants.js +1 -1
  27. package/dist/core/create-vite.js +2 -0
  28. package/dist/core/dev/dev.js +1 -1
  29. package/dist/core/errors/dev/utils.js +1 -1
  30. package/dist/core/errors/zod-error-map.js +0 -27
  31. package/dist/core/head-propagation/hint.d.ts +4 -0
  32. package/dist/core/head-propagation/hint.js +7 -0
  33. package/dist/core/messages/runtime.js +1 -1
  34. package/dist/core/middleware/vite-plugin.js +2 -2
  35. package/dist/toolbar/vite-plugin-dev-toolbar.js +1 -23
  36. package/dist/types/public/config.d.ts +0 -1
  37. package/dist/types/public/content.d.ts +3 -3
  38. package/dist/types/public/integrations.d.ts +2 -2
  39. package/dist/vite-plugin-adapter-config/index.js +1 -1
  40. package/dist/vite-plugin-astro/compile.d.ts +3 -5
  41. package/dist/vite-plugin-astro/compile.js +4 -60
  42. package/dist/vite-plugin-astro/index.js +15 -28
  43. package/dist/vite-plugin-astro/types.d.ts +2 -1
  44. package/dist/vite-plugin-head/index.js +9 -3
  45. package/dist/vite-plugin-pages/util.d.ts +1 -1
  46. package/package.json +3 -5
  47. package/templates/content/module.mjs +1 -1
  48. package/dist/core/build/add-rollup-input.d.ts +0 -2
  49. package/dist/core/compile/compile-rs.d.ts +0 -25
  50. package/dist/core/compile/compile-rs.js +0 -111
  51. package/dist/core/head-propagation/comment.d.ts +0 -7
  52. package/dist/core/head-propagation/comment.js +0 -7
  53. package/dist/vite-plugin-astro/compile-rs.d.ts +0 -12
  54. package/dist/vite-plugin-astro/compile-rs.js +0 -39
@@ -10,10 +10,10 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
10
10
  name: z.ZodString;
11
11
  hooks: z.ZodDefault<z.ZodObject<{}, z.core.$loose>>;
12
12
  }, z.core.$strip>>;
13
- integrations: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodArray<z.ZodObject<{
13
+ integrations: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodArray<z.ZodObject<{
14
14
  name: z.ZodString;
15
15
  hooks: z.ZodDefault<z.ZodObject<{}, z.core.$loose>>;
16
- }, z.core.$strip>>>>>;
16
+ }, z.core.$strip>>>>;
17
17
  redirects: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
18
18
  status: z.ZodUnion<readonly [z.ZodLiteral<300>, z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<303>, z.ZodLiteral<304>, z.ZodLiteral<307>, z.ZodLiteral<308>]>;
19
19
  destination: z.ZodString;
@@ -400,7 +400,6 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
400
400
  swr: z.ZodOptional<z.ZodNumber>;
401
401
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
402
402
  }, z.core.$strip>>>;
403
- rustCompiler: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
404
403
  queuedRendering: z.ZodPrefault<z.ZodOptional<z.ZodObject<{
405
404
  enabled: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
406
405
  poolSize: z.ZodOptional<z.ZodNumber>;
@@ -437,13 +436,14 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
437
436
  }>>>;
438
437
  concurrency: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
439
438
  }, z.core.$strip>>>;
440
- server: z.ZodPrefault<z.ZodPipe<z.ZodTransform<any, unknown>, z.ZodObject<{
439
+ server: z.ZodPipe<z.ZodTransform<any, unknown>, z.ZodPrefault<z.ZodOptional<z.ZodObject<{
441
440
  open: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>>;
442
441
  host: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>>;
443
442
  port: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
444
443
  headers: z.ZodOptional<z.ZodCustom<OutgoingHttpHeaders, OutgoingHttpHeaders>>;
444
+ streaming: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
445
445
  allowedHosts: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodLiteral<true>]>>>;
446
- }, z.core.$strip>>>;
446
+ }, z.core.$strip>>>>;
447
447
  }, z.core.$strip>, z.ZodTransform<{
448
448
  base: string;
449
449
  trailingSlash: "never" | "ignore" | "always";
@@ -576,7 +576,6 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
576
576
  clientPrerender: boolean;
577
577
  contentIntellisense: boolean;
578
578
  chromeDevtoolsWorkspace: boolean;
579
- rustCompiler: boolean;
580
579
  queuedRendering: {
581
580
  enabled: boolean;
582
581
  poolSize?: number | undefined;
@@ -629,6 +628,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
629
628
  open: string | boolean;
630
629
  host: string | boolean;
631
630
  port: number;
631
+ streaming: boolean;
632
632
  allowedHosts: true | string[];
633
633
  headers?: OutgoingHttpHeaders | undefined;
634
634
  };
@@ -824,7 +824,6 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
824
824
  clientPrerender: boolean;
825
825
  contentIntellisense: boolean;
826
826
  chromeDevtoolsWorkspace: boolean;
827
- rustCompiler: boolean;
828
827
  queuedRendering: {
829
828
  enabled: boolean;
830
829
  poolSize?: number | undefined;
@@ -877,6 +876,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
877
876
  open: string | boolean;
878
877
  host: string | boolean;
879
878
  port: number;
879
+ streaming: boolean;
880
880
  allowedHosts: true | string[];
881
881
  headers?: OutgoingHttpHeaders | undefined;
882
882
  };
@@ -59,9 +59,10 @@ function createRelativeSchema(cmd, fileProtocolRoot) {
59
59
  host: z.union([z.string(), z.boolean()]).optional().default(ASTRO_CONFIG_DEFAULTS.server.host),
60
60
  port: z.number().optional().default(ASTRO_CONFIG_DEFAULTS.server.port),
61
61
  headers: z.custom().optional(),
62
+ streaming: z.boolean().optional().default(true),
62
63
  allowedHosts: z.union([z.array(z.string()), z.literal(true)]).optional().default(ASTRO_CONFIG_DEFAULTS.server.allowedHosts)
63
- })
64
- ).prefault({})
64
+ }).optional().prefault({})
65
+ )
65
66
  }).transform((config) => {
66
67
  if (config.outDir.toString() !== resolveDirAsUrl(ASTRO_CONFIG_DEFAULTS.outDir, fileProtocolRoot).toString()) {
67
68
  const outDirPath = fileURLToPath(config.outDir);
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "6.2.1";
1
+ const ASTRO_VERSION = "7.0.0-alpha.0";
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";
@@ -279,6 +279,7 @@ const COMMON_PREFIXES_NOT_ASTRO = [
279
279
  "@webcomponents/",
280
280
  "@fontsource/",
281
281
  "@postcss-plugins/",
282
+ "@rolldown/",
282
283
  "@rollup/",
283
284
  "@astrojs/renderer-",
284
285
  "@types/",
@@ -289,6 +290,7 @@ const COMMON_PREFIXES_NOT_ASTRO = [
289
290
  "prettier-plugin-",
290
291
  "remark-",
291
292
  "rehype-",
293
+ "rolldown-plugin-",
292
294
  "rollup-plugin-",
293
295
  "vite-plugin-"
294
296
  ];
@@ -37,7 +37,7 @@ async function dev(inlineConfig) {
37
37
  await telemetry.record([]);
38
38
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
39
39
  const logger = restart.container.logger;
40
- const currentVersion = "6.2.1";
40
+ const currentVersion = "7.0.0-alpha.0";
41
41
  const isPrerelease = currentVersion.includes("-");
42
42
  if (!isPrerelease) {
43
43
  try {
@@ -50,7 +50,7 @@ function collectErrorMetadata(e, rootFolder) {
50
50
  });
51
51
  if (!AggregateError.is(e) && Array.isArray(e.errors)) {
52
52
  e.errors.forEach((buildError, i) => {
53
- const { location, pluginName, text } = buildError;
53
+ const { loc: location, plugin: pluginName, message: text } = buildError;
54
54
  if (text) {
55
55
  try {
56
56
  err[i].message = text;
@@ -24,17 +24,6 @@ const errorMap = (issue) => {
24
24
  `> ${getTypeOrLiteralMsg(error)}`
25
25
  ) : `> ${prefix(key, getTypeOrLiteralMsg(error))}`
26
26
  );
27
- if (details.length === 0) {
28
- if ("discriminator" in issue && issue.discriminator && "options" in issue) {
29
- const options = issue.options;
30
- if (Array.isArray(options)) {
31
- details.push(
32
- `> Expected \`${issue.discriminator}\` to be ${options.map((o) => `\`${stringify(o)}\``).join(" | ")}`
33
- );
34
- details.push("> Received `" + stringify(issue.input) + "`");
35
- }
36
- }
37
- }
38
27
  if (details.length === 0) {
39
28
  const expectedShapes = [];
40
29
  for (const unionErrors of issue.errors) {
@@ -70,22 +59,6 @@ const errorMap = (issue) => {
70
59
  return {
71
60
  message: messages.concat(details).join("\n")
72
61
  };
73
- } else if (issue.code === "invalid_key") {
74
- const keyIssues = issue.issues;
75
- if (Array.isArray(keyIssues) && keyIssues.length > 0) {
76
- const firstIssue = keyIssues[0];
77
- const msg = firstIssue.message || "Invalid key in record";
78
- return { message: prefix(baseErrorPath, msg) };
79
- }
80
- return { message: prefix(baseErrorPath, "Invalid key in record") };
81
- } else if (issue.code === "invalid_element") {
82
- const elementIssues = issue.issues;
83
- if (Array.isArray(elementIssues) && elementIssues.length > 0) {
84
- const firstIssue = elementIssues[0];
85
- const msg = firstIssue.message || "Invalid element";
86
- return { message: prefix(baseErrorPath, msg) };
87
- }
88
- return { message: prefix(baseErrorPath, "Invalid element") };
89
62
  } else if (issue.code === "invalid_type") {
90
63
  return {
91
64
  message: prefix(
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Returns true when source contains the `"use astro:head-inject"` directive.
3
+ */
4
+ export declare function hasHeadPropagationCall(source: string): boolean;
@@ -0,0 +1,7 @@
1
+ const HEAD_PROPAGATION_HINT = '"use astro:head-inject"';
2
+ function hasHeadPropagationCall(source) {
3
+ return source.includes(HEAD_PROPAGATION_HINT);
4
+ }
5
+ export {
6
+ hasHeadPropagationCall
7
+ };
@@ -276,7 +276,7 @@ function printHelp({
276
276
  message.push(
277
277
  linebreak(),
278
278
  ` ${bgGreen(black(` ${commandName} `))} ${green(
279
- `v${"6.2.1"}`
279
+ `v${"7.0.0-alpha.0"}`
280
280
  )} ${headline}`
281
281
  );
282
282
  }
@@ -3,7 +3,7 @@ import {
3
3
  normalizePath as viteNormalizePath
4
4
  } from "vite";
5
5
  import { getServerOutputDirectory } from "../../prerender/utils.js";
6
- import { addRollupInput } from "../build/add-rollup-input.js";
6
+ import { addRolldownInput } from "../build/add-rolldown-input.js";
7
7
  import { ASTRO_VITE_ENVIRONMENT_NAMES, MIDDLEWARE_PATH_SEGMENT_NAME } from "../constants.js";
8
8
  import { MissingMiddlewareForInternationalization } from "../errors/errors-data.js";
9
9
  import { AstroError } from "../errors/index.js";
@@ -119,7 +119,7 @@ function vitePluginMiddlewareBuild(opts, internals) {
119
119
  },
120
120
  options(options) {
121
121
  if (canSplitMiddleware) {
122
- return addRollupInput(options, [MIDDLEWARE_MODULE_ID]);
122
+ return addRolldownInput(options, [MIDDLEWARE_MODULE_ID]);
123
123
  } else {
124
124
  }
125
125
  },
@@ -1,4 +1,3 @@
1
- import { readFileSync, writeFileSync } from "node:fs";
2
1
  import { telemetry } from "../events/index.js";
3
2
  import { eventAppToggled } from "../events/toolbar.js";
4
3
  const VIRTUAL_MODULE_ID = "astro:toolbar:internal";
@@ -15,28 +14,7 @@ function astroDevToolbar({ settings, logger }) {
15
14
  "astro > aria-query",
16
15
  "astro > axobject-query",
17
16
  ...settings.devToolbarApps.length > 0 ? ["astro/toolbar"] : []
18
- ],
19
- esbuildOptions: {
20
- plugins: [
21
- {
22
- name: "astro:strip-toolbar-sourcemap",
23
- setup(build) {
24
- build.onEnd((result) => {
25
- if (!result.metafile) return;
26
- for (const outputPath of Object.keys(result.metafile.outputs)) {
27
- if (!outputPath.includes("entrypoint") || !outputPath.endsWith(".js"))
28
- continue;
29
- const code = readFileSync(outputPath, "utf-8");
30
- const stripped = code.replace(/\/\/# sourceMappingURL=.*$/m, "");
31
- if (stripped !== code) {
32
- writeFileSync(outputPath, stripped);
33
- }
34
- }
35
- });
36
- }
37
- }
38
- ]
39
- }
17
+ ]
40
18
  }
41
19
  };
42
20
  },
@@ -2811,7 +2811,6 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2811
2811
  * ```
2812
2812
  */
2813
2813
  routeRules?: RouteRules;
2814
- rustCompiler?: boolean;
2815
2814
  /**
2816
2815
  * @name experimental.queuedRendering
2817
2816
  * @type {boolean | { poolSize?: number; cache?: boolean }}
@@ -1,9 +1,9 @@
1
1
  import type { MarkdownHeading } from '@astrojs/markdown-remark';
2
- import type * as rollup from 'rollup';
3
2
  import type { DataEntry, RenderedContent } from '../../content/data-store.js';
4
3
  import type { LiveCollectionError } from '../../content/loaders/errors.js';
5
4
  import type { AstroComponentFactory } from '../../runtime/server/index.js';
6
5
  import type { AstroConfig } from './config.js';
6
+ import type { Rolldown } from 'vite';
7
7
  export interface AstroInstance {
8
8
  file: string;
9
9
  url: string | undefined;
@@ -96,11 +96,11 @@ export interface ContentEntryType {
96
96
  fileUrl: URL;
97
97
  contents: string;
98
98
  }): GetContentEntryInfoReturnType | Promise<GetContentEntryInfoReturnType>;
99
- getRenderModule?(this: rollup.PluginContext, params: {
99
+ getRenderModule?(this: Rolldown.PluginContext, params: {
100
100
  contents: string;
101
101
  fileUrl: URL;
102
102
  viteId: string;
103
- }): rollup.LoadResult | Promise<rollup.LoadResult>;
103
+ }): Rolldown.LoadResult | Promise<Rolldown.LoadResult>;
104
104
  contentModuleTypes?: string;
105
105
  getRenderFunction?(config: AstroConfig): Promise<ContentEntryRenderFunction>;
106
106
  /**
@@ -112,7 +112,7 @@ interface AdapterExplicitProperties {
112
112
  * or `"explicit"` (default, but deprecated):
113
113
  *
114
114
  * - **`"auto"` (recommended):** You are responsible for providing a valid module as an entrypoint
115
- * using either `serverEntrypoint` or, if you need further customization at the Vite level using `vite.build.rollupOptions.input`.
115
+ * using either `serverEntrypoint` or, if you need further customization at the Vite level using `vite.build.rolldownOptions.input`.
116
116
  * - **`"explicit"` (deprecated)**: You must provide the exports required by the host in the server entrypoint
117
117
  * using a `createExports()` function before passing them to `setAdapter()` as an [`exports`](#exports) list. This supports
118
118
  * adapters built using the Astro 5 version of the Adapter API. By default, all adapters will receive this value to allow backwards
@@ -143,7 +143,7 @@ interface AdapterAutoProperties {
143
143
  * or `"explicit"` (default, but deprecated):
144
144
  *
145
145
  * - **`"auto"` (recommended):** You are responsible for providing a valid module as an entrypoint
146
- * using either `serverEntrypoint` or, if you need further customization at the Vite level using `vite.build.rollupOptions.input`.
146
+ * using either `serverEntrypoint` or, if you need further customization at the Vite level using `vite.build.rolldownOptions.input`.
147
147
  * - **`"explicit"` (deprecated)**: You must provide the exports required by the host in the server entrypoint
148
148
  * using a `createExports()` function before passing them to `setAdapter()` as an [`exports`](#exports) list. This supports
149
149
  * adapters built using the Astro 5 version of the Adapter API. By default, all adapters will receive this value to allow backwards
@@ -13,7 +13,7 @@ function vitePluginAdapterConfig(settings) {
13
13
  environments: {
14
14
  [ASTRO_VITE_ENVIRONMENT_NAMES.ssr]: {
15
15
  build: {
16
- rollupOptions: {
16
+ rolldownOptions: {
17
17
  input: {
18
18
  index: typeof adapter.serverEntrypoint === "string" ? adapter.serverEntrypoint : fileURLToPath(adapter.serverEntrypoint)
19
19
  }
@@ -1,14 +1,12 @@
1
+ import type { Rolldown } from 'vite';
1
2
  import { type CompileProps, type CompileResult } from '../core/compile/index.js';
2
- import type { AstroLogger } from '../core/logger/core.js';
3
3
  import type { CompileMetadata } from './types.js';
4
- import type { SourceMapInput } from 'rollup';
5
4
  interface CompileAstroOption {
6
5
  compileProps: CompileProps;
7
6
  astroFileToCompileMetadata: Map<string, CompileMetadata>;
8
- logger: AstroLogger;
9
7
  }
10
8
  export interface CompileAstroResult extends Omit<CompileResult, 'map'> {
11
- map: SourceMapInput;
9
+ map: Rolldown.SourceMapInput;
12
10
  }
13
- export declare function compileAstro({ compileProps, astroFileToCompileMetadata, logger, }: CompileAstroOption): Promise<CompileAstroResult>;
11
+ export declare function compileAstro({ compileProps, astroFileToCompileMetadata, }: CompileAstroOption): Promise<CompileAstroResult>;
14
12
  export {};
@@ -1,38 +1,10 @@
1
- import { transformWithEsbuild } from "vite";
2
1
  import { compile } from "../core/compile/index.js";
3
2
  import { getFileInfo } from "../vite-plugin-utils/index.js";
4
- import { frontmatterRE } from "./utils.js";
5
3
  async function compileAstro({
6
4
  compileProps,
7
- astroFileToCompileMetadata,
8
- logger
5
+ astroFileToCompileMetadata
9
6
  }) {
10
- let transformResult;
11
- let esbuildResult;
12
- try {
13
- transformResult = await compile(compileProps);
14
- esbuildResult = await transformWithEsbuild(transformResult.code, compileProps.filename, {
15
- ...compileProps.viteConfig.esbuild,
16
- loader: "ts",
17
- sourcemap: "external",
18
- tsconfigRaw: {
19
- compilerOptions: {
20
- // Ensure client:only imports are treeshaken
21
- verbatimModuleSyntax: false,
22
- importsNotUsedAsValues: "remove"
23
- }
24
- }
25
- });
26
- } catch (err) {
27
- await enhanceCompileError({
28
- err,
29
- id: compileProps.filename,
30
- source: compileProps.source,
31
- config: compileProps.astroConfig,
32
- logger
33
- });
34
- throw err;
35
- }
7
+ const transformResult = await compile(compileProps);
36
8
  const { fileId: file, fileUrl: url } = getFileInfo(
37
9
  compileProps.filename,
38
10
  compileProps.astroConfig
@@ -58,38 +30,10 @@ const $$url = ${JSON.stringify(
58
30
  });
59
31
  return {
60
32
  ...transformResult,
61
- code: esbuildResult.code + SUFFIX,
62
- map: esbuildResult.map
33
+ code: transformResult.code + SUFFIX,
34
+ map: transformResult.map || null
63
35
  };
64
36
  }
65
- async function enhanceCompileError({
66
- err,
67
- id,
68
- source
69
- }) {
70
- const lineText = err.loc?.lineText;
71
- const scannedFrontmatter = frontmatterRE.exec(source);
72
- if (scannedFrontmatter) {
73
- const frontmatter = scannedFrontmatter[1].replace(/\breturn\s*;/g, "throw 0;").replace(/\breturn\b/g, "throw ");
74
- if (lineText && !frontmatter.includes(lineText)) throw err;
75
- try {
76
- await transformWithEsbuild(frontmatter, id, {
77
- loader: "ts",
78
- target: "esnext",
79
- sourcemap: false
80
- });
81
- } catch (frontmatterErr) {
82
- if (frontmatterErr?.message) {
83
- frontmatterErr.message = frontmatterErr.message.replace(
84
- "end of file",
85
- "end of frontmatter"
86
- );
87
- }
88
- throw frontmatterErr;
89
- }
90
- }
91
- throw err;
92
- }
93
37
  export {
94
38
  compileAstro
95
39
  };
@@ -3,7 +3,6 @@ import { ASTRO_VITE_ENVIRONMENT_NAMES } from "../core/constants.js";
3
3
  import { isAstroServerEnvironment } from "../environments.js";
4
4
  import { normalizeFilename, specialQueriesRE } from "../vite-plugin-utils/index.js";
5
5
  import { compileAstro } from "./compile.js";
6
- import { compileAstro as compileAstroRs } from "./compile-rs.js";
7
6
  import { handleHotUpdate } from "./hmr.js";
8
7
  import { parseAstroRequest } from "./query.js";
9
8
  import { loadId } from "./utils.js";
@@ -61,23 +60,15 @@ function astro({ settings, logger }) {
61
60
  async configResolved(viteConfig) {
62
61
  const toolbarEnabled = await settings.preferences.get("devToolbar.enabled");
63
62
  compile = (code, filename) => {
64
- const compileProps = {
65
- astroConfig: config,
66
- viteConfig,
67
- toolbarEnabled,
68
- filename,
69
- source: code
70
- };
71
- if (config.experimental.rustCompiler) {
72
- return compileAstroRs({
73
- compileProps,
74
- astroFileToCompileMetadata
75
- });
76
- }
77
63
  return compileAstro({
78
- compileProps,
79
- astroFileToCompileMetadata,
80
- logger
64
+ compileProps: {
65
+ astroConfig: config,
66
+ viteConfig,
67
+ toolbarEnabled,
68
+ filename,
69
+ source: code
70
+ },
71
+ astroFileToCompileMetadata
81
72
  });
82
73
  };
83
74
  },
@@ -143,7 +134,8 @@ function astro({ settings, logger }) {
143
134
  }
144
135
  if (isAstroServerEnvironment(this.environment)) {
145
136
  return {
146
- code: `/* client script, empty in SSR: ${id} */`
137
+ code: `/* client script, empty in SSR: ${id} */`,
138
+ moduleType: "ts"
147
139
  };
148
140
  }
149
141
  const script = compileMetadata.scripts[query.index];
@@ -165,6 +157,7 @@ File: ${id}`
165
157
  }
166
158
  const result = {
167
159
  code: "",
160
+ moduleType: "ts",
168
161
  meta: {
169
162
  vite: {
170
163
  lang: "ts"
@@ -173,13 +166,11 @@ File: ${id}`
173
166
  };
174
167
  switch (script.type) {
175
168
  case "inline": {
176
- const { code, map } = script;
177
- result.code = appendSourceMap(code, map);
169
+ result.code = script.code ?? "";
178
170
  break;
179
171
  }
180
172
  case "external": {
181
- const { src } = script;
182
- result.code = `import "${src}"`;
173
+ result.code = `import "${script.src}"`;
183
174
  break;
184
175
  }
185
176
  }
@@ -216,6 +207,7 @@ File: ${id}`
216
207
  );
217
208
  }
218
209
  : {};`,
210
+ moduleType: "ts",
219
211
  meta: { vite: { lang: "ts" } }
220
212
  };
221
213
  }
@@ -234,6 +226,7 @@ File: ${id}`
234
226
  return {
235
227
  code: transformResult.code,
236
228
  map: transformResult.map,
229
+ moduleType: "ts",
237
230
  meta: {
238
231
  astro: astroMetadata,
239
232
  vite: {
@@ -263,12 +256,6 @@ File: ${id}`
263
256
  }
264
257
  ];
265
258
  }
266
- function appendSourceMap(content, map) {
267
- if (!map) return content;
268
- return `${content}${"\n//#"} sourceMappingURL=data:application/json;charset=utf-8;base64,${Buffer.from(
269
- map
270
- ).toString("base64")}`;
271
- }
272
259
  export {
273
260
  astro as default,
274
261
  getAstroMetadata
@@ -1,9 +1,10 @@
1
- import type { HoistedScript, TransformResult } from '@astrojs/compiler';
1
+ import type { HoistedScript, TransformResult } from '@astrojs/compiler-rs';
2
2
  import type { CompileCssResult } from '../core/compile/types.js';
3
3
  import type { PropagationHint } from '../types/public/internal.js';
4
4
  interface PageOptions {
5
5
  prerender?: boolean;
6
6
  }
7
+ export type AstroComponent = TransformResult['hydratedComponents'][number];
7
8
  export interface PluginMetadata {
8
9
  astro: {
9
10
  hydratedComponents: TransformResult['hydratedComponents'];
@@ -1,4 +1,4 @@
1
- import { hasHeadInjectComment } from "../core/head-propagation/comment.js";
1
+ import { hasHeadPropagationCall } from "../core/head-propagation/hint.js";
2
2
  import {
3
3
  buildImporterGraphFromModuleInfo,
4
4
  computeInTreeAncestors
@@ -115,7 +115,7 @@ function configHeadVitePlugin() {
115
115
  if (info && getAstroMetadata(info)?.containsHead) {
116
116
  propagateMetadata.call(this, id, "containsHead", true);
117
117
  }
118
- if (hasHeadInjectComment(source)) {
118
+ if (hasHeadPropagationCall(source)) {
119
119
  propagateMetadata.call(this, id, "propagation", "in-tree");
120
120
  }
121
121
  invalidateComponentMetadataModule();
@@ -123,11 +123,17 @@ function configHeadVitePlugin() {
123
123
  };
124
124
  }
125
125
  function astroHeadBuildPlugin(internals) {
126
+ const headPropagationModuleIds = /* @__PURE__ */ new Set();
126
127
  return {
127
128
  name: "astro:head-metadata-build",
128
129
  applyToEnvironment(environment) {
129
130
  return environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr || environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.prerender;
130
131
  },
132
+ transform(source, id) {
133
+ if (hasHeadPropagationCall(source)) {
134
+ headPropagationModuleIds.add(id);
135
+ }
136
+ },
131
137
  generateBundle(_opts, bundle) {
132
138
  const map = internals.componentMetadata;
133
139
  const moduleIds = /* @__PURE__ */ new Set();
@@ -159,7 +165,7 @@ function astroHeadBuildPlugin(internals) {
159
165
  selfPropagationSeeds.add(id);
160
166
  }
161
167
  }
162
- if (mod.code && hasHeadInjectComment(mod.code)) {
168
+ if (mod.code && hasHeadPropagationCall(mod.code) || headPropagationModuleIds.has(id)) {
163
169
  commentPropagationSeeds.add(id);
164
170
  }
165
171
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Prevents Rollup from triggering other plugins in the process by masking the extension (hence the virtual file).
2
+ * Prevents Rolldown from triggering other plugins in the process by masking the extension (hence the virtual file).
3
3
  * Inverse function of getComponentFromVirtualModulePageName() below.
4
4
  * @param virtualModulePrefix The prefix used to create the virtual module
5
5
  * @param path Page component path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "6.2.1",
3
+ "version": "7.0.0-alpha.0",
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",
@@ -106,7 +106,7 @@
106
106
  "README.md"
107
107
  ],
108
108
  "dependencies": {
109
- "@astrojs/compiler": "^4.0.0",
109
+ "@astrojs/compiler-rs": "^0.1.10",
110
110
  "@capsizecss/unpack": "^4.0.0",
111
111
  "@clack/prompts": "^1.1.0",
112
112
  "@oslojs/encoding": "^1.1.0",
@@ -152,7 +152,7 @@
152
152
  "unist-util-visit": "^5.1.0",
153
153
  "unstorage": "^1.17.5",
154
154
  "vfile": "^6.0.3",
155
- "vite": "^7.3.2",
155
+ "vite": "^8.0.8",
156
156
  "vitefu": "^1.1.2",
157
157
  "xxhash-wasm": "^1.1.0",
158
158
  "yargs-parser": "^22.0.0",
@@ -165,7 +165,6 @@
165
165
  "sharp": "^0.34.0"
166
166
  },
167
167
  "devDependencies": {
168
- "@astrojs/compiler-rs": "^0.1.6",
169
168
  "@playwright/test": "1.58.2",
170
169
  "@types/aria-query": "^5.0.4",
171
170
  "@types/hast": "^3.0.4",
@@ -188,7 +187,6 @@
188
187
  "rehype-slug": "^6.0.0",
189
188
  "rehype-toc": "^3.0.2",
190
189
  "remark-code-titles": "^0.1.2",
191
- "rollup": "^4.58.0",
192
190
  "sass": "^1.98.0",
193
191
  "typescript": "^5.9.3",
194
192
  "undici": "^7.22.0",
@@ -1,4 +1,4 @@
1
- // astro-head-inject
1
+ 'use astro:head-inject';
2
2
  import {
3
3
  createDeprecatedFunction,
4
4
  createGetCollection,
@@ -1,2 +0,0 @@
1
- import type { Rollup } from 'vite';
2
- export declare function addRollupInput(inputOptions: Rollup.InputOptions, newInputs: string[]): Rollup.InputOptions;
@@ -1,25 +0,0 @@
1
- import type { ResolvedConfig } from 'vite';
2
- import type { AstroConfig } from '../../types/public/config.js';
3
- import type { CompileCssResult } from './types.js';
4
- export interface CompileProps {
5
- astroConfig: AstroConfig;
6
- viteConfig: ResolvedConfig;
7
- toolbarEnabled: boolean;
8
- filename: string;
9
- source: string;
10
- }
11
- export interface CompileResult {
12
- code: string;
13
- map: string;
14
- scope: string;
15
- css: CompileCssResult[];
16
- scripts: any[];
17
- hydratedComponents: any[];
18
- clientOnlyComponents: any[];
19
- serverComponents: any[];
20
- containsHead: boolean;
21
- propagation: boolean;
22
- styleError: string[];
23
- diagnostics: any[];
24
- }
25
- export declare function compile({ astroConfig, viteConfig, toolbarEnabled, filename, source, }: CompileProps): Promise<CompileResult>;