astro 6.3.1 → 7.0.0-alpha.1

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 (61) hide show
  1. package/dist/assets/endpoint/generic.js +16 -7
  2. package/dist/assets/utils/assets.d.ts +4 -5
  3. package/dist/assets/utils/node.d.ts +2 -2
  4. package/dist/assets/vite-plugin-assets.js +1 -1
  5. package/dist/cli/add/index.js +0 -54
  6. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  7. package/dist/content/content-layer.js +3 -3
  8. package/dist/content/runtime-assets.d.ts +2 -2
  9. package/dist/content/utils.d.ts +2 -3
  10. package/dist/content/vite-plugin-content-assets.js +1 -0
  11. package/dist/core/build/add-rolldown-input.d.ts +2 -0
  12. package/dist/core/build/{add-rollup-input.js → add-rolldown-input.js} +3 -3
  13. package/dist/core/build/graph.d.ts +8 -8
  14. package/dist/core/build/plugins/plugin-analyzer.js +1 -1
  15. package/dist/core/build/plugins/plugin-component-entry.d.ts +1 -1
  16. package/dist/core/build/plugins/plugin-component-entry.js +3 -3
  17. package/dist/core/build/plugins/plugin-internals.js +1 -1
  18. package/dist/core/build/plugins/plugin-prerender.js +1 -1
  19. package/dist/core/build/static-build.d.ts +2 -2
  20. package/dist/core/build/static-build.js +31 -31
  21. package/dist/core/build/util.d.ts +2 -2
  22. package/dist/core/build/util.js +2 -2
  23. package/dist/core/compile/compile.d.ts +1 -1
  24. package/dist/core/compile/compile.js +20 -16
  25. package/dist/core/config/schemas/base.d.ts +0 -2
  26. package/dist/core/config/schemas/base.js +0 -2
  27. package/dist/core/config/schemas/relative.d.ts +0 -3
  28. package/dist/core/constants.js +1 -1
  29. package/dist/core/create-vite.js +2 -0
  30. package/dist/core/dev/dev.js +1 -13
  31. package/dist/core/errors/dev/utils.js +1 -1
  32. package/dist/core/head-propagation/hint.d.ts +4 -0
  33. package/dist/core/head-propagation/hint.js +7 -0
  34. package/dist/core/messages/runtime.d.ts +0 -3
  35. package/dist/core/messages/runtime.js +1 -9
  36. package/dist/core/middleware/vite-plugin.js +2 -2
  37. package/dist/core/preview/static-preview-server.js +1 -3
  38. package/dist/toolbar/vite-plugin-dev-toolbar.js +1 -23
  39. package/dist/types/public/config.d.ts +0 -1
  40. package/dist/types/public/content.d.ts +3 -3
  41. package/dist/types/public/integrations.d.ts +2 -2
  42. package/dist/vite-plugin-adapter-config/index.js +1 -1
  43. package/dist/vite-plugin-astro/compile.d.ts +3 -5
  44. package/dist/vite-plugin-astro/compile.js +4 -60
  45. package/dist/vite-plugin-astro/index.js +15 -28
  46. package/dist/vite-plugin-astro/types.d.ts +2 -1
  47. package/dist/vite-plugin-astro/utils.d.ts +0 -1
  48. package/dist/vite-plugin-astro/utils.js +1 -9
  49. package/dist/vite-plugin-head/index.js +9 -3
  50. package/dist/vite-plugin-pages/util.d.ts +1 -1
  51. package/package.json +9 -9
  52. package/templates/content/module.mjs +1 -1
  53. package/dist/assets/endpoint/loadImage.d.ts +0 -11
  54. package/dist/assets/endpoint/loadImage.js +0 -19
  55. package/dist/core/build/add-rollup-input.d.ts +0 -2
  56. package/dist/core/compile/compile-rs.d.ts +0 -25
  57. package/dist/core/compile/compile-rs.js +0 -111
  58. package/dist/core/head-propagation/comment.d.ts +0 -7
  59. package/dist/core/head-propagation/comment.js +0 -7
  60. package/dist/vite-plugin-astro/compile-rs.d.ts +0 -12
  61. package/dist/vite-plugin-astro/compile-rs.js +0 -39
@@ -402,7 +402,6 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
402
402
  swr: z.ZodOptional<z.ZodNumber>;
403
403
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
404
404
  }, z.core.$strip>>>;
405
- rustCompiler: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
406
405
  queuedRendering: z.ZodPrefault<z.ZodOptional<z.ZodObject<{
407
406
  enabled: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
408
407
  poolSize: z.ZodOptional<z.ZodNumber>;
@@ -580,7 +579,6 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
580
579
  clientPrerender: boolean;
581
580
  contentIntellisense: boolean;
582
581
  chromeDevtoolsWorkspace: boolean;
583
- rustCompiler: boolean;
584
582
  queuedRendering: {
585
583
  enabled: boolean;
586
584
  poolSize?: number | undefined;
@@ -830,7 +828,6 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
830
828
  clientPrerender: boolean;
831
829
  contentIntellisense: boolean;
832
830
  chromeDevtoolsWorkspace: boolean;
833
- rustCompiler: boolean;
834
831
  queuedRendering: {
835
832
  enabled: boolean;
836
833
  poolSize?: number | undefined;
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "6.3.1";
1
+ const ASTRO_VERSION = "7.0.0-alpha.1";
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";
@@ -294,6 +294,7 @@ const COMMON_PREFIXES_NOT_ASTRO = [
294
294
  "@webcomponents/",
295
295
  "@fontsource/",
296
296
  "@postcss-plugins/",
297
+ "@rolldown/",
297
298
  "@rollup/",
298
299
  "@astrojs/renderer-",
299
300
  "@types/",
@@ -304,6 +305,7 @@ const COMMON_PREFIXES_NOT_ASTRO = [
304
305
  "prettier-plugin-",
305
306
  "remark-",
306
307
  "rehype-",
308
+ "rolldown-plugin-",
307
309
  "rollup-plugin-",
308
310
  "vite-plugin-"
309
311
  ];
@@ -1,5 +1,4 @@
1
1
  import fs from "node:fs";
2
- import { createRequire } from "node:module";
3
2
  import { performance } from "node:perf_hooks";
4
3
  import colors from "piccolore";
5
4
  import { gt, major, minor, patch } from "semver";
@@ -21,23 +20,13 @@ import {
21
20
  } from "./update-check.js";
22
21
  import { BuildTimeAstroVersionProvider } from "../../cli/infra/build-time-astro-version-provider.js";
23
22
  import { piccoloreTextStyler } from "../../cli/infra/piccolore-text-styler.js";
24
- function warnIfVite8({ root, logger }) {
25
- try {
26
- const require2 = createRequire(root);
27
- const { version } = require2("vite/package.json");
28
- if (major(version) >= 8) {
29
- logger.warn("SKIP_FORMAT", msg.vite8Warning({ viteVersion: version }));
30
- }
31
- } catch {
32
- }
33
- }
34
23
  async function dev(inlineConfig) {
35
24
  ensureProcessNodeEnv("development");
36
25
  const devStart = performance.now();
37
26
  await telemetry.record([]);
38
27
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
39
28
  const logger = restart.container.logger;
40
- const currentVersion = "6.3.1";
29
+ const currentVersion = "7.0.0-alpha.1";
41
30
  const isPrerelease = currentVersion.includes("-");
42
31
  if (!isPrerelease) {
43
32
  try {
@@ -111,7 +100,6 @@ async function dev(inlineConfig) {
111
100
  if (restart.container.viteServer.config.server?.fs?.strict === false) {
112
101
  logger.warn("SKIP_FORMAT", msg.fsStrictWarning());
113
102
  }
114
- setImmediate(() => warnIfVite8({ root: restart.container.settings.config.root, logger }));
115
103
  logger.info(null, colors.green("watching for file changes..."));
116
104
  return {
117
105
  address: devServerAddressInfo,
@@ -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;
@@ -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
+ };
@@ -41,9 +41,6 @@ export declare function preferenceReset(name: string): string;
41
41
  export declare function telemetryDisabled(): string;
42
42
  export declare function telemetryReset(): string;
43
43
  export declare function fsStrictWarning(): string;
44
- export declare function vite8Warning({ viteVersion }: {
45
- viteVersion: string;
46
- }): string;
47
44
  export declare function prerelease({ currentVersion }: {
48
45
  currentVersion: string;
49
46
  }): string;
@@ -134,13 +134,6 @@ function fsStrictWarning() {
134
134
  ${subtitle}
135
135
  `;
136
136
  }
137
- function vite8Warning({ viteVersion }) {
138
- const title = yellow(`\u25B6 Vite ${bold(viteVersion)} detected in your project.`);
139
- const subtitle = ` Astro requires Vite 7. Add ${bold('"overrides": { "vite": "^7" }')} to your ${bold("package.json")} to avoid issues.`;
140
- return `${title}
141
- ${subtitle}
142
- `;
143
- }
144
137
  function prerelease({ currentVersion }) {
145
138
  const tag = currentVersion.split("-").slice(1).join("-").replace(/\..*$/, "") || "unknown";
146
139
  const badge = bgYellow(black(` ${tag} `));
@@ -276,7 +269,7 @@ function printHelp({
276
269
  message.push(
277
270
  linebreak(),
278
271
  ` ${bgGreen(black(` ${commandName} `))} ${green(
279
- `v${"6.3.1"}`
272
+ `v${"7.0.0-alpha.1"}`
280
273
  )} ${headline}`
281
274
  );
282
275
  }
@@ -334,6 +327,5 @@ export {
334
327
  telemetryEnabled,
335
328
  telemetryNotice,
336
329
  telemetryReset,
337
- vite8Warning,
338
330
  warnIfCspWithShiki
339
331
  };
@@ -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
  },
@@ -67,11 +67,9 @@ async function createStaticPreviewServer(settings, logger) {
67
67
  previewServer.httpServer.addListener("error", reject);
68
68
  });
69
69
  }
70
- const address = previewServer.httpServer.address();
71
- const actualPort = address && typeof address === "object" ? address.port : settings.config.server.port;
72
70
  return {
73
71
  host: getResolvedHostForHttpServer(settings.config.server.host),
74
- port: actualPort,
72
+ port: settings.config.server.port,
75
73
  closed,
76
74
  server: previewServer.httpServer,
77
75
  stop: previewServer.close.bind(previewServer)
@@ -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
  },
@@ -2845,7 +2845,6 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2845
2845
  * ```
2846
2846
  */
2847
2847
  routeRules?: RouteRules;
2848
- rustCompiler?: boolean;
2849
2848
  /**
2850
2849
  * @name experimental.queuedRendering
2851
2850
  * @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, replaceTopLevelReturns } 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 = replaceTopLevelReturns(scannedFrontmatter[1]);
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,3 @@
1
1
  import type { PluginContainer } from 'vite';
2
2
  export declare const frontmatterRE: RegExp;
3
- export declare function replaceTopLevelReturns(code: string): string;
4
3
  export declare function loadId(pluginContainer: PluginContainer, id: string): Promise<string | undefined>;
@@ -1,12 +1,5 @@
1
1
  import fs from "node:fs/promises";
2
2
  const frontmatterRE = /^---(.*?)^---/ms;
3
- const RETURN_REPLACE_RE = /(\/\/[^\n]*|\/\*[\s\S]*?\*\/|`(?:[^`\\]|\\.)*`|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')|(?<!\.)\breturn(\s*;|\b)/g;
4
- function replaceTopLevelReturns(code) {
5
- return code.replace(RETURN_REPLACE_RE, (_match, skip, tail) => {
6
- if (skip !== void 0) return skip;
7
- return tail.trim() === ";" ? "throw 0;" : "throw ";
8
- });
9
- }
10
3
  async function loadId(pluginContainer, id) {
11
4
  const result = await pluginContainer.load(id, { ssr: true });
12
5
  if (result) {
@@ -23,6 +16,5 @@ async function loadId(pluginContainer, id) {
23
16
  }
24
17
  export {
25
18
  frontmatterRE,
26
- loadId,
27
- replaceTopLevelReturns
19
+ loadId
28
20
  };
@@ -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
@@ -132,7 +132,7 @@ function configHeadVitePlugin() {
132
132
  if (info && getAstroMetadata(info)?.containsHead) {
133
133
  propagateMetadata.call(this, id, "containsHead", true);
134
134
  }
135
- if (hasHeadInjectComment(source)) {
135
+ if (hasHeadPropagationCall(source)) {
136
136
  propagateMetadata.call(this, id, "propagation", "in-tree");
137
137
  }
138
138
  invalidateComponentMetadataModule();
@@ -140,11 +140,17 @@ function configHeadVitePlugin() {
140
140
  };
141
141
  }
142
142
  function astroHeadBuildPlugin(internals) {
143
+ const headPropagationModuleIds = /* @__PURE__ */ new Set();
143
144
  return {
144
145
  name: "astro:head-metadata-build",
145
146
  applyToEnvironment(environment) {
146
147
  return environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr || environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.prerender;
147
148
  },
149
+ transform(source, id) {
150
+ if (hasHeadPropagationCall(source)) {
151
+ headPropagationModuleIds.add(id);
152
+ }
153
+ },
148
154
  generateBundle(_opts, bundle) {
149
155
  const map = internals.componentMetadata;
150
156
  const moduleIds = /* @__PURE__ */ new Set();
@@ -176,7 +182,7 @@ function astroHeadBuildPlugin(internals) {
176
182
  selfPropagationSeeds.add(id);
177
183
  }
178
184
  }
179
- if (mod.code && hasHeadInjectComment(mod.code)) {
185
+ if (mod.code && hasHeadPropagationCall(mod.code) || headPropagationModuleIds.has(id)) {
180
186
  commentPropagationSeeds.add(id);
181
187
  }
182
188
  }
@@ -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.3.1",
3
+ "version": "7.0.0-alpha.1",
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",
@@ -112,7 +112,7 @@
112
112
  "README.md"
113
113
  ],
114
114
  "dependencies": {
115
- "@astrojs/compiler": "^4.0.0",
115
+ "@astrojs/compiler-rs": "^0.1.10",
116
116
  "@capsizecss/unpack": "^4.0.0",
117
117
  "@clack/prompts": "^1.1.0",
118
118
  "@oslojs/encoding": "^1.1.0",
@@ -134,8 +134,8 @@
134
134
  "github-slugger": "^2.0.0",
135
135
  "html-escaper": "3.0.3",
136
136
  "http-cache-semantics": "^4.2.0",
137
- "js-yaml": "^4.1.1",
138
137
  "jsonc-parser": "^3.3.1",
138
+ "js-yaml": "^4.1.1",
139
139
  "magic-string": "^0.30.21",
140
140
  "magicast": "^0.5.2",
141
141
  "mrmime": "^2.0.1",
@@ -159,20 +159,19 @@
159
159
  "unist-util-visit": "^5.1.0",
160
160
  "unstorage": "^1.17.5",
161
161
  "vfile": "^6.0.3",
162
- "vite": "^7.3.2",
162
+ "vite": "^8.0.8",
163
163
  "vitefu": "^1.1.2",
164
164
  "xxhash-wasm": "^1.1.0",
165
165
  "yargs-parser": "^22.0.0",
166
166
  "zod": "^4.3.6",
167
- "@astrojs/internal-helpers": "0.9.0",
168
167
  "@astrojs/markdown-remark": "7.1.1",
169
- "@astrojs/telemetry": "3.3.2"
168
+ "@astrojs/telemetry": "3.3.2",
169
+ "@astrojs/internal-helpers": "0.9.0"
170
170
  },
171
171
  "optionalDependencies": {
172
172
  "sharp": "^0.34.0"
173
173
  },
174
174
  "devDependencies": {
175
- "@astrojs/compiler-rs": "^0.1.6",
176
175
  "@playwright/test": "1.58.2",
177
176
  "@types/aria-query": "^5.0.4",
178
177
  "@types/hast": "^3.0.4",
@@ -196,7 +195,6 @@
196
195
  "rehype-slug": "^6.0.0",
197
196
  "rehype-toc": "^3.0.2",
198
197
  "remark-code-titles": "^0.1.2",
199
- "rollup": "^4.58.0",
200
198
  "sass": "^1.98.0",
201
199
  "typescript": "^5.9.3",
202
200
  "undici": "^7.22.0",
@@ -231,6 +229,8 @@
231
229
  "test:e2e:firefox": "playwright test --config playwright.firefox.config.js",
232
230
  "test:types": "tsc --build test/types/tsconfig.json",
233
231
  "test:unit": "astro-scripts test \"test/units/**/*.test.ts\" --strip-types --teardown ./test/units/teardown.ts",
234
- "test:integration": "astro-scripts test \"test/*.test.ts\" --parallel --strip-types"
232
+ "test:integration": "pnpm run test:integration:js && pnpm run test:integration:ts",
233
+ "test:integration:js": "astro-scripts test \"test/*.test.js\"",
234
+ "test:integration:ts": "astro-scripts test \"test/*.test.ts\" --strip-types"
235
235
  }
236
236
  }
@@ -1,4 +1,4 @@
1
- // astro-head-inject
1
+ 'use astro:head-inject';
2
2
  import {
3
3
  createDeprecatedFunction,
4
4
  createGetCollection,