astro 3.6.2 → 4.0.0-beta.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 (135) hide show
  1. package/client.d.ts +19 -20
  2. package/components/Code.astro +0 -20
  3. package/components/ViewTransitions.astro +2 -2
  4. package/dist/@types/astro.d.ts +19 -81
  5. package/dist/assets/build/generate.js +2 -2
  6. package/dist/assets/internal.js +1 -1
  7. package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +3 -3
  8. package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +3 -3
  9. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +3 -3
  10. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +3 -3
  11. package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +3 -3
  12. package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +3 -3
  13. package/dist/cli/add/babel.d.ts +1 -1
  14. package/dist/cli/build/index.js +0 -1
  15. package/dist/cli/flags.js +0 -3
  16. package/dist/cli/info/index.d.ts +5 -0
  17. package/dist/cli/info/index.js +16 -7
  18. package/dist/cli/install-package.js +1 -1
  19. package/dist/cli/telemetry/index.js +6 -6
  20. package/dist/content/server-listeners.js +7 -7
  21. package/dist/content/types-generator.d.ts +1 -4
  22. package/dist/content/types-generator.js +31 -51
  23. package/dist/core/app/index.js +2 -4
  24. package/dist/core/build/buildPipeline.js +3 -3
  25. package/dist/core/build/generate.js +18 -39
  26. package/dist/core/build/index.js +10 -32
  27. package/dist/core/build/internal.js +3 -3
  28. package/dist/core/build/plugin.d.ts +2 -2
  29. package/dist/core/build/plugins/plugin-manifest.js +1 -4
  30. package/dist/core/build/plugins/plugin-pages.js +0 -3
  31. package/dist/core/build/plugins/plugin-renderers.d.ts +1 -1
  32. package/dist/core/build/plugins/plugin-ssr.js +5 -6
  33. package/dist/core/build/static-build.js +4 -7
  34. package/dist/core/build/types.d.ts +1 -1
  35. package/dist/core/build/util.js +1 -1
  36. package/dist/core/config/config.js +1 -2
  37. package/dist/core/config/schema.d.ts +209 -277
  38. package/dist/core/config/schema.js +5 -38
  39. package/dist/core/constants.js +1 -1
  40. package/dist/core/create-vite.d.ts +2 -2
  41. package/dist/core/create-vite.js +12 -1
  42. package/dist/core/dev/dev.js +6 -4
  43. package/dist/core/dev/restart.js +7 -7
  44. package/dist/core/endpoint/index.d.ts +2 -7
  45. package/dist/core/endpoint/index.js +3 -87
  46. package/dist/core/errors/dev/vite.js +0 -1
  47. package/dist/core/logger/console.d.ts +2 -4
  48. package/dist/core/logger/console.js +4 -28
  49. package/dist/core/logger/core.d.ts +17 -5
  50. package/dist/core/logger/core.js +27 -2
  51. package/dist/core/logger/node.d.ts +2 -32
  52. package/dist/core/logger/node.js +8 -69
  53. package/dist/core/messages.d.ts +4 -11
  54. package/dist/core/messages.js +43 -59
  55. package/dist/core/middleware/callMiddleware.d.ts +1 -2
  56. package/dist/core/middleware/callMiddleware.js +1 -12
  57. package/dist/core/middleware/index.d.ts +2 -2
  58. package/dist/core/middleware/sequence.d.ts +2 -2
  59. package/dist/core/pipeline.d.ts +2 -2
  60. package/dist/core/pipeline.js +8 -13
  61. package/dist/core/preview/static-preview-server.js +2 -4
  62. package/dist/core/preview/vite-plugin-astro-preview.js +31 -21
  63. package/dist/core/render/core.js +0 -6
  64. package/dist/core/render/index.d.ts +1 -1
  65. package/dist/core/render/result.js +1 -1
  66. package/dist/core/render/route-cache.js +2 -5
  67. package/dist/core/request.js +3 -3
  68. package/dist/core/routing/manifest/create.js +14 -12
  69. package/dist/core/routing/validation.js +4 -4
  70. package/dist/core/sync/index.js +2 -2
  71. package/dist/i18n/middleware.d.ts +2 -2
  72. package/dist/i18n/vite-plugin-i18n.js +1 -1
  73. package/dist/integrations/astroFeaturesValidation.d.ts +1 -1
  74. package/dist/integrations/astroFeaturesValidation.js +12 -18
  75. package/dist/integrations/index.js +28 -6
  76. package/dist/prefetch/vite-plugin-prefetch.js +3 -3
  77. package/dist/runtime/client/dev-overlay/entrypoint.js +14 -10
  78. package/dist/runtime/client/dev-overlay/overlay.js +1 -1
  79. package/dist/runtime/client/dev-overlay/plugins/astro.d.ts +14 -1
  80. package/dist/runtime/client/dev-overlay/plugins/astro.js +326 -15
  81. package/dist/runtime/client/dev-overlay/plugins/settings.js +26 -2
  82. package/dist/runtime/client/dev-overlay/plugins/utils/icons.d.ts +3 -0
  83. package/dist/runtime/client/dev-overlay/plugins/utils/icons.js +37 -0
  84. package/dist/runtime/client/dev-overlay/plugins/utils/window.d.ts +1 -2
  85. package/dist/runtime/client/dev-overlay/plugins/utils/window.js +25 -29
  86. package/dist/runtime/client/dev-overlay/ui-library/badge.d.ts +9 -0
  87. package/dist/runtime/client/dev-overlay/ui-library/badge.js +67 -0
  88. package/dist/runtime/client/dev-overlay/ui-library/button.d.ts +9 -0
  89. package/dist/runtime/client/dev-overlay/ui-library/button.js +83 -0
  90. package/dist/runtime/client/dev-overlay/ui-library/card.d.ts +1 -3
  91. package/dist/runtime/client/dev-overlay/ui-library/card.js +17 -25
  92. package/dist/runtime/client/dev-overlay/ui-library/highlight.js +1 -0
  93. package/dist/runtime/client/dev-overlay/ui-library/icon.d.ts +10 -0
  94. package/dist/runtime/client/dev-overlay/ui-library/icon.js +36 -0
  95. package/dist/runtime/client/dev-overlay/ui-library/icons.d.ts +21 -6
  96. package/dist/runtime/client/dev-overlay/ui-library/icons.js +22 -7
  97. package/dist/runtime/client/dev-overlay/ui-library/index.d.ts +8 -0
  98. package/dist/runtime/client/dev-overlay/ui-library/index.js +18 -0
  99. package/dist/runtime/client/dev-overlay/ui-library/window.d.ts +0 -4
  100. package/dist/runtime/client/dev-overlay/ui-library/window.js +0 -33
  101. package/dist/runtime/server/endpoint.d.ts +1 -1
  102. package/dist/runtime/server/endpoint.js +11 -22
  103. package/dist/transitions/vite-plugin-transitions.js +4 -4
  104. package/dist/virtual-modules/i18n.d.ts +1 -0
  105. package/dist/virtual-modules/i18n.js +1 -0
  106. package/dist/virtual-modules/middleware.d.ts +1 -0
  107. package/dist/virtual-modules/middleware.js +5 -0
  108. package/dist/virtual-modules/prefetch.d.ts +1 -0
  109. package/dist/virtual-modules/prefetch.js +1 -0
  110. package/dist/virtual-modules/transitions-events.d.ts +1 -0
  111. package/dist/virtual-modules/transitions-events.js +1 -0
  112. package/dist/virtual-modules/transitions-router.d.ts +1 -0
  113. package/dist/virtual-modules/transitions-router.js +1 -0
  114. package/dist/virtual-modules/transitions-types.d.ts +1 -0
  115. package/dist/virtual-modules/transitions-types.js +1 -0
  116. package/dist/virtual-modules/transitions.d.ts +1 -0
  117. package/dist/virtual-modules/transitions.js +1 -0
  118. package/dist/vite-plugin-astro/hmr.js +8 -14
  119. package/dist/vite-plugin-astro/index.js +28 -6
  120. package/dist/vite-plugin-astro-server/base.js +5 -5
  121. package/dist/vite-plugin-astro-server/response.js +1 -1
  122. package/dist/vite-plugin-astro-server/route.js +30 -6
  123. package/dist/vite-plugin-inject-env-ts/index.js +3 -3
  124. package/dist/vite-plugin-integrations-container/index.js +1 -1
  125. package/dist/vite-plugin-load-fallback/index.js +1 -3
  126. package/dist/vite-plugin-scanner/index.js +3 -6
  127. package/dist/vite-plugin-scripts/index.js +1 -1
  128. package/dist/vite-plugin-utils/index.d.ts +1 -0
  129. package/dist/vite-plugin-utils/index.js +5 -0
  130. package/package.json +56 -68
  131. package/dist/core/middleware/namespace.d.ts +0 -1
  132. package/dist/core/middleware/namespace.js +0 -5
  133. package/dist/vite-plugin-astro-server/common.d.ts +0 -2
  134. package/dist/vite-plugin-astro-server/common.js +0 -7
  135. package/import-meta.d.ts +0 -30
@@ -5,16 +5,17 @@ import prompts from "prompts";
5
5
  import { resolveConfig } from "../../core/config/index.js";
6
6
  import { ASTRO_VERSION } from "../../core/constants.js";
7
7
  import { flagsToAstroInlineConfig } from "../flags.js";
8
- async function printInfo({ flags }) {
8
+ async function getInfoOutput({
9
+ userConfig,
10
+ print
11
+ }) {
9
12
  const rows = [
10
13
  ["Astro", `v${ASTRO_VERSION}`],
11
14
  ["Node", process.version],
12
15
  ["System", getSystem()],
13
16
  ["Package Manager", getPackageManager()]
14
17
  ];
15
- const inlineConfig = flagsToAstroInlineConfig(flags);
16
18
  try {
17
- const { userConfig } = await resolveConfig(inlineConfig, "info");
18
19
  rows.push(["Output", userConfig.output ?? "static"]);
19
20
  rows.push(["Adapter", userConfig.adapter?.name ?? "none"]);
20
21
  const integrations = (userConfig?.integrations ?? []).filter(Boolean).flat().map((i) => i?.name).filter(Boolean);
@@ -23,9 +24,14 @@ async function printInfo({ flags }) {
23
24
  }
24
25
  let output = "";
25
26
  for (const [label, value] of rows) {
26
- output += printRow(label, value);
27
+ output += printRow(label, value, print);
27
28
  }
28
- await copyToClipboard(output.trim());
29
+ return output.trim();
30
+ }
31
+ async function printInfo({ flags }) {
32
+ const { userConfig } = await resolveConfig(flagsToAstroInlineConfig(flags), "info");
33
+ const output = await getInfoOutput({ userConfig, print: true });
34
+ await copyToClipboard(output);
29
35
  }
30
36
  async function copyToClipboard(text) {
31
37
  const system = platform();
@@ -84,7 +90,7 @@ function getPackageManager() {
84
90
  return name === "npminstall" ? "cnpm" : name;
85
91
  }
86
92
  const MAX_PADDING = 25;
87
- function printRow(label, value) {
93
+ function printRow(label, value, print) {
88
94
  const padding = MAX_PADDING - label.length;
89
95
  const [first, ...rest] = Array.isArray(value) ? value : [value];
90
96
  let plaintext = `${label}${" ".repeat(padding)}${first}`;
@@ -98,9 +104,12 @@ ${" ".repeat(MAX_PADDING)}${colors.green(entry)}`;
98
104
  }
99
105
  }
100
106
  plaintext += "\n";
101
- console.log(richtext);
107
+ if (print) {
108
+ console.log(richtext);
109
+ }
102
110
  return plaintext;
103
111
  }
104
112
  export {
113
+ getInfoOutput,
105
114
  printInfo
106
115
  };
@@ -13,7 +13,7 @@ async function getPackage(packageName, logger, options, otherDeps = []) {
13
13
  packageImport = await import(packageName);
14
14
  } catch (e) {
15
15
  logger.info(
16
- "",
16
+ null,
17
17
  `To continue, Astro requires the following dependency to be installed: ${bold(packageName)}.`
18
18
  );
19
19
  const result = await installPackage([packageName, ...otherDeps], options, logger);
@@ -1,15 +1,15 @@
1
- import whichPm from "which-pm";
2
1
  import * as msg from "../../core/messages.js";
3
2
  import { telemetry } from "../../events/index.js";
3
+ import { createLoggerFromFlags } from "../flags.js";
4
4
  async function notify() {
5
- const packageManager = (await whichPm(process.cwd()))?.name ?? "npm";
6
5
  await telemetry.notify(() => {
7
- console.log(msg.telemetryNotice(packageManager) + "\n");
6
+ console.log(msg.telemetryNotice() + "\n");
8
7
  return true;
9
8
  });
10
9
  }
11
10
  async function update(subcommand, { flags }) {
12
11
  const isValid = ["enable", "disable", "reset"].includes(subcommand);
12
+ const logger = createLoggerFromFlags(flags);
13
13
  if (flags.help || flags.h || !isValid) {
14
14
  msg.printHelp({
15
15
  commandName: "astro telemetry",
@@ -27,17 +27,17 @@ async function update(subcommand, { flags }) {
27
27
  switch (subcommand) {
28
28
  case "enable": {
29
29
  telemetry.setEnabled(true);
30
- console.log(msg.telemetryEnabled());
30
+ logger.info("SKIP_FORMAT", msg.telemetryEnabled());
31
31
  return;
32
32
  }
33
33
  case "disable": {
34
34
  telemetry.setEnabled(false);
35
- console.log(msg.telemetryDisabled());
35
+ logger.info("SKIP_FORMAT", msg.telemetryDisabled());
36
36
  return;
37
37
  }
38
38
  case "reset": {
39
39
  telemetry.clear();
40
- console.log(msg.telemetryReset());
40
+ logger.info("SKIP_FORMAT", msg.telemetryReset());
41
41
  return;
42
42
  }
43
43
  }
@@ -1,4 +1,4 @@
1
- import { bold, cyan } from "kleur/colors";
1
+ import { bold, cyan, underline } from "kleur/colors";
2
2
  import path from "node:path";
3
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
4
  import { loadTSConfig } from "../core/config/tsconfig.js";
@@ -13,7 +13,7 @@ async function attachContentServerListeners({
13
13
  }) {
14
14
  const contentPaths = getContentPaths(settings.config, fs);
15
15
  if (fs.existsSync(contentPaths.contentDir)) {
16
- logger.info(
16
+ logger.debug(
17
17
  "content",
18
18
  `Watching ${cyan(
19
19
  contentPaths.contentDir.href.replace(settings.config.root.href, "")
@@ -27,7 +27,7 @@ async function attachContentServerListeners({
27
27
  viteServer.watcher.on("addDir", contentDirListener);
28
28
  async function contentDirListener(dir) {
29
29
  if (appendForwardSlash(pathToFileURL(dir).href) === contentPaths.contentDir.href) {
30
- logger.info("content", `Content dir found. Watching for changes`);
30
+ logger.debug("content", `Content directory found. Watching for changes`);
31
31
  await attachListeners();
32
32
  viteServer.watcher.removeListener("addDir", contentDirListener);
33
33
  }
@@ -42,7 +42,7 @@ async function attachContentServerListeners({
42
42
  contentConfigObserver: globalContentConfigObserver
43
43
  });
44
44
  await contentGenerator.init();
45
- logger.info("content", "Types generated");
45
+ logger.debug("content", "Types generated");
46
46
  viteServer.watcher.on("add", (entry) => {
47
47
  contentGenerator.queueEvent({ name: "add", entry });
48
48
  });
@@ -74,9 +74,9 @@ function warnAllowJsIsFalse({
74
74
  "true"
75
75
  )} in your ${bold(tsConfigFileName)} file to have autocompletion in your ${bold(
76
76
  contentConfigFileName
77
- )} file.
78
- See ${bold("https://www.typescriptlang.org/tsconfig#allowJs")} for more information.
79
- `
77
+ )} file. See ${underline(
78
+ cyan("https://www.typescriptlang.org/tsconfig#allowJs")
79
+ )} for more information.`
80
80
  );
81
81
  }
82
82
  async function getTSConfigStatsWhenAllowJsFalse({
@@ -17,9 +17,6 @@ type CreateContentGeneratorParams = {
17
17
  viteServer: ViteDevServer;
18
18
  fs: typeof fsMod;
19
19
  };
20
- type EventOpts = {
21
- logLevel: 'info' | 'warn';
22
- };
23
20
  export declare function createContentTypesGenerator({ contentConfigObserver, fs, logger, settings, viteServer, }: CreateContentGeneratorParams): Promise<{
24
21
  init: () => Promise<{
25
22
  typesGenerated: true;
@@ -27,6 +24,6 @@ export declare function createContentTypesGenerator({ contentConfigObserver, fs,
27
24
  typesGenerated: false;
28
25
  reason: 'no-content-dir';
29
26
  }>;
30
- queueEvent: (rawEvent: RawContentEvent, opts?: EventOpts) => void;
27
+ queueEvent: (rawEvent: RawContentEvent) => void;
31
28
  }>;
32
29
  export {};
@@ -1,5 +1,5 @@
1
1
  import glob from "fast-glob";
2
- import { cyan } from "kleur/colors";
2
+ import { bold, cyan } from "kleur/colors";
3
3
  import * as path from "node:path";
4
4
  import { fileURLToPath, pathToFileURL } from "node:url";
5
5
  import { normalizePath } from "vite";
@@ -39,10 +39,7 @@ async function createContentTypesGenerator({
39
39
  if (!fs.existsSync(contentPaths.contentDir)) {
40
40
  return { typesGenerated: false, reason: "no-content-dir" };
41
41
  }
42
- events.push({
43
- type: { name: "add", entry: contentPaths.config.url },
44
- opts: { logLevel: "warn" }
45
- });
42
+ events.push({ name: "add", entry: contentPaths.config.url });
46
43
  const globResult = await glob("**", {
47
44
  cwd: fileURLToPath(contentPaths.contentDir),
48
45
  fs: {
@@ -58,19 +55,15 @@ async function createContentTypesGenerator({
58
55
  if (entryURL.href.startsWith(contentPaths.config.url.href))
59
56
  continue;
60
57
  if (entry.dirent.isFile()) {
61
- events.push({
62
- type: { name: "add", entry: entryURL },
63
- opts: { logLevel: "warn" }
64
- });
58
+ events.push({ name: "add", entry: entryURL });
65
59
  } else if (entry.dirent.isDirectory()) {
66
- events.push({ type: { name: "addDir", entry: entryURL }, opts: { logLevel: "warn" } });
60
+ events.push({ name: "addDir", entry: entryURL });
67
61
  }
68
62
  }
69
63
  await runEvents();
70
64
  return { typesGenerated: true };
71
65
  }
72
- async function handleEvent(event, opts) {
73
- const logLevel = opts?.logLevel ?? "info";
66
+ async function handleEvent(event) {
74
67
  if (event.name === "addDir" || event.name === "unlinkDir") {
75
68
  const collection2 = normalizePath(
76
69
  path.relative(fileURLToPath(contentPaths.contentDir), fileURLToPath(event.entry))
@@ -82,9 +75,7 @@ async function createContentTypesGenerator({
82
75
  switch (event.name) {
83
76
  case "addDir":
84
77
  collectionEntryMap[JSON.stringify(collection2)] = { type: "unknown", entries: {} };
85
- if (logLevel === "info") {
86
- logger.info("content", `${cyan(collection2)} collection added`);
87
- }
78
+ logger.debug("content", `${cyan(collection2)} collection added`);
88
79
  break;
89
80
  case "unlinkDir":
90
81
  if (collectionKey2 in collectionEntryMap) {
@@ -125,16 +116,14 @@ async function createContentTypesGenerator({
125
116
  const { contentDir } = contentPaths;
126
117
  const collection = getEntryCollectionName({ entry, contentDir });
127
118
  if (collection === void 0) {
128
- if (["info", "warn"].includes(logLevel)) {
129
- logger.warn(
130
- "content",
131
- `${cyan(
132
- normalizePath(
133
- path.relative(fileURLToPath(contentPaths.contentDir), fileURLToPath(event.entry))
134
- )
135
- )} must be nested in a collection directory. Skipping.`
136
- );
137
- }
119
+ logger.warn(
120
+ "content",
121
+ `${bold(
122
+ normalizePath(
123
+ path.relative(fileURLToPath(contentPaths.contentDir), fileURLToPath(event.entry))
124
+ )
125
+ )} must live in a ${bold("content/...")} collection subdirectory.`
126
+ );
138
127
  return { shouldGenerateTypes: false };
139
128
  }
140
129
  if (fileType === "data") {
@@ -234,21 +223,18 @@ async function createContentTypesGenerator({
234
223
  return { shouldGenerateTypes: false };
235
224
  }
236
225
  }
237
- function queueEvent(rawEvent, opts) {
226
+ function queueEvent(rawEvent) {
238
227
  const event = {
239
- type: {
240
- entry: pathToFileURL(rawEvent.entry),
241
- name: rawEvent.name
242
- },
243
- opts
228
+ entry: pathToFileURL(rawEvent.entry),
229
+ name: rawEvent.name
244
230
  };
245
- if (!event.type.entry.pathname.startsWith(contentPaths.contentDir.pathname))
231
+ if (!event.entry.pathname.startsWith(contentPaths.contentDir.pathname))
246
232
  return;
247
233
  events.push(event);
248
234
  debounceTimeout && clearTimeout(debounceTimeout);
249
235
  const runEventsSafe = async () => {
250
236
  try {
251
- await runEvents(opts);
237
+ await runEvents();
252
238
  } catch {
253
239
  }
254
240
  };
@@ -258,29 +244,23 @@ async function createContentTypesGenerator({
258
244
  /* debounce to batch chokidar events */
259
245
  );
260
246
  }
261
- async function runEvents(opts) {
262
- const logLevel = opts?.logLevel ?? "info";
247
+ async function runEvents() {
263
248
  const eventResponses = [];
264
249
  for (const event of events) {
265
- const response = await handleEvent(event.type, event.opts);
250
+ const response = await handleEvent(event);
266
251
  eventResponses.push(response);
267
252
  }
268
253
  events = [];
269
- let unsupportedFiles = [];
270
254
  for (const response of eventResponses) {
271
255
  if (response.error instanceof UnsupportedFileTypeError) {
272
- unsupportedFiles.push(response.error.message);
256
+ logger.warn(
257
+ "content",
258
+ `Unsupported file type ${bold(
259
+ response.error.message
260
+ )} found. Prefix filename with an underscore (\`_\`) to ignore.`
261
+ );
273
262
  }
274
263
  }
275
- if (unsupportedFiles.length > 0 && ["info", "warn"].includes(logLevel)) {
276
- logger.warn(
277
- "content",
278
- `Unsupported file types found. Prefix with an underscore (\`_\`) to ignore:
279
- - ${unsupportedFiles.join(
280
- "\n"
281
- )}`
282
- );
283
- }
284
264
  const observable = contentConfigObserver.get();
285
265
  if (eventResponses.some((r) => r.shouldGenerateTypes)) {
286
266
  await writeContentFiles({
@@ -293,7 +273,7 @@ async function createContentTypesGenerator({
293
273
  viteServer
294
274
  });
295
275
  invalidateVirtualMod(viteServer);
296
- if (observable.status === "loaded" && ["info", "warn"].includes(logLevel)) {
276
+ if (observable.status === "loaded") {
297
277
  warnNonexistentCollections({
298
278
  logger,
299
279
  contentConfig: observable.config,
@@ -424,9 +404,9 @@ function warnNonexistentCollections({
424
404
  if (!collectionEntryMap[JSON.stringify(configuredCollection)]) {
425
405
  logger.warn(
426
406
  "content",
427
- `The ${JSON.stringify(
428
- configuredCollection
429
- )} collection does not have an associated folder in your \`content\` directory. Make sure the folder exists, or check your content config for typos.`
407
+ `The ${bold(configuredCollection)} collection is defined but no ${bold(
408
+ "content/" + configuredCollection
409
+ )} folder exists in the content directory. Create a new folder for the collection, or check your content configuration file for typos.`
430
410
  );
431
411
  }
432
412
  }
@@ -143,9 +143,7 @@ class App {
143
143
  );
144
144
  if (i18nMiddleware) {
145
145
  if (mod.onRequest) {
146
- this.#pipeline.setMiddlewareFunction(
147
- sequence(i18nMiddleware, mod.onRequest)
148
- );
146
+ this.#pipeline.setMiddlewareFunction(sequence(i18nMiddleware, mod.onRequest));
149
147
  } else {
150
148
  this.#pipeline.setMiddlewareFunction(i18nMiddleware);
151
149
  }
@@ -160,7 +158,7 @@ class App {
160
158
  if (err instanceof EndpointNotFoundError) {
161
159
  return this.#renderError(request, { status: 404, response: err.originalResponse });
162
160
  } else {
163
- this.#logger.error("ssr", err.stack || err.message || String(err));
161
+ this.#logger.error(null, err.stack || err.message || String(err));
164
162
  return this.#renderError(request, { status: 500 });
165
163
  }
166
164
  }
@@ -114,9 +114,9 @@ class BuildPipeline extends Pipeline {
114
114
  */
115
115
  retrieveRoutesToGenerate() {
116
116
  const pages = /* @__PURE__ */ new Map();
117
- for (const [entryPoint, filePath] of this.#internals.entrySpecifierToBundleMap) {
118
- if (entryPoint.includes(ASTRO_PAGE_RESOLVED_MODULE_ID) || entryPoint.includes(RESOLVED_SPLIT_MODULE_ID)) {
119
- const [, pageName] = entryPoint.split(":");
117
+ for (const [entrypoint, filePath] of this.#internals.entrySpecifierToBundleMap) {
118
+ if (entrypoint.includes(ASTRO_PAGE_RESOLVED_MODULE_ID) || entrypoint.includes(RESOLVED_SPLIT_MODULE_ID)) {
119
+ const [, pageName] = entrypoint.split(":");
120
120
  const pageData = this.#internals.pagesByComponent.get(
121
121
  `${pageName.replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, ".")}`
122
122
  );
@@ -1,5 +1,4 @@
1
- import * as colors from "kleur/colors";
2
- import { bgGreen, black, cyan, dim, green, magenta } from "kleur/colors";
1
+ import { bgGreen, black, blue, bold, dim, green, magenta, red } from "kleur/colors";
3
2
  import fs from "node:fs";
4
3
  import os from "node:os";
5
4
  import { fileURLToPath } from "node:url";
@@ -79,13 +78,6 @@ async function getEntryForFallbackRoute(route, internals, outFolder) {
79
78
  }
80
79
  return RedirectSinglePageBuiltModule;
81
80
  }
82
- function shouldSkipDraft(pageModule, settings) {
83
- return (
84
- // Drafts are disabled
85
- !settings.config.markdown.drafts && // This is a draft post
86
- "frontmatter" in pageModule && pageModule.frontmatter?.draft === true
87
- );
88
- }
89
81
  function rootRelativeFacadeId(facadeId, settings) {
90
82
  return facadeId.slice(fileURLToPath(settings.config.root).length);
91
83
  }
@@ -103,7 +95,7 @@ function chunkIsPage(settings, output, internals) {
103
95
  return false;
104
96
  }
105
97
  async function generatePages(opts, internals) {
106
- const timer = performance.now();
98
+ const generatePagesTimer = performance.now();
107
99
  const ssr = isServerLikeOutput(opts.settings.config);
108
100
  let manifest;
109
101
  if (ssr) {
@@ -126,7 +118,7 @@ async function generatePages(opts, internals) {
126
118
  return;
127
119
  }
128
120
  const verb = ssr ? "prerendering" : "generating";
129
- logger.info(null, `
121
+ logger.info("SKIP_FORMAT", `
130
122
  ${bgGreen(black(` ${verb} static routes `))}`);
131
123
  const builtPaths = /* @__PURE__ */ new Set();
132
124
  const pagesToGenerate = pipeline.retrieveRoutesToGenerate();
@@ -135,10 +127,7 @@ ${bgGreen(black(` ${verb} static routes `))}`);
135
127
  if (pageData.route.prerender) {
136
128
  const ssrEntryURLPage = createEntryURL(filePath, outFolder);
137
129
  const ssrEntryPage = await import(ssrEntryURLPage.toString());
138
- if (
139
- // TODO: remove in Astro 4.0
140
- opts.settings.config.build.split || opts.settings.adapter?.adapterFeatures?.functionPerRoute
141
- ) {
130
+ if (opts.settings.adapter?.adapterFeatures?.functionPerRoute) {
142
131
  const ssrEntry = ssrEntryPage?.pageModule;
143
132
  if (ssrEntry) {
144
133
  await generatePage(pageData, ssrEntry, builtPaths, pipeline);
@@ -168,12 +157,14 @@ ${bgGreen(black(` ${verb} static routes `))}`);
168
157
  }
169
158
  }
170
159
  }
171
- logger.info(null, dim(`Completed in ${getTimeStat(timer, performance.now())}.
172
- `));
160
+ logger.info(
161
+ null,
162
+ green(`\u2713 Completed in ${getTimeStat(generatePagesTimer, performance.now())}.
163
+ `)
164
+ );
173
165
  const staticImageList = getStaticImageList();
174
166
  if (staticImageList.size) {
175
- logger.info(null, `
176
- ${bgGreen(black(` generating optimized images `))}`);
167
+ logger.info("SKIP_FORMAT", `${bgGreen(black(` generating optimized images `))}`);
177
168
  const totalCount = Array.from(staticImageList.values()).map((x) => x.transforms.size).reduce((a, b) => a + b, 0);
178
169
  const cpuCount = os.cpus().length;
179
170
  const assetsCreationEnvironment = await prepareAssetsGenerationEnv(pipeline, totalCount);
@@ -184,7 +175,7 @@ ${bgGreen(black(` generating optimized images `))}`);
184
175
  }
185
176
  await queue.onIdle();
186
177
  const assetsTimeEnd = performance.now();
187
- logger.info(null, dim(`Completed in ${getTimeStat(assetsTimer, assetsTimeEnd)}.
178
+ logger.info(null, green(`\u2713 Completed in ${getTimeStat(assetsTimer, assetsTimeEnd)}.
188
179
  `));
189
180
  delete globalThis?.astroAsset?.addStaticImage;
190
181
  }
@@ -210,9 +201,7 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
210
201
  );
211
202
  if (config.experimental.i18n && i18nMiddleware) {
212
203
  if (onRequest) {
213
- pipeline.setMiddlewareFunction(
214
- sequence(i18nMiddleware, onRequest)
215
- );
204
+ pipeline.setMiddlewareFunction(sequence(i18nMiddleware, onRequest));
216
205
  } else {
217
206
  pipeline.setMiddlewareFunction(i18nMiddleware);
218
207
  }
@@ -226,14 +215,6 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
226
215
  );
227
216
  }
228
217
  const pageModule = await pageModulePromise();
229
- if (shouldSkipDraft(pageModule, pipeline.getSettings())) {
230
- logger.info(null, `${magenta("\u26A0\uFE0F")} Skipping draft ${pageData.route.component}`);
231
- logger.warn(
232
- "astro",
233
- `The drafts feature is deprecated. You should migrate to content collections instead. See https://docs.astro.build/en/guides/content-collections/#filtering-collection-queries for more information.`
234
- );
235
- return;
236
- }
237
218
  const generationOptions = {
238
219
  pageData,
239
220
  linkIds,
@@ -241,7 +222,7 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
241
222
  styles,
242
223
  mod: pageModule
243
224
  };
244
- const icon = pageData.route.type === "page" || pageData.route.type === "redirect" || pageData.route.type === "fallback" ? green("\u25B6") : magenta("\u03BB");
225
+ const icon = pageData.route.type === "page" || pageData.route.type === "redirect" || pageData.route.type === "fallback" ? blue("\u25B6") : magenta("\u03BB");
245
226
  if (isRelativePath(pageData.route.component)) {
246
227
  logger.info(null, `${icon} ${pageData.route.route}`);
247
228
  for (const fallbackRoute of pageData.route.fallbackRoutes) {
@@ -257,10 +238,10 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
257
238
  await generatePath(path, generationOptions, pipeline);
258
239
  const timeEnd = performance.now();
259
240
  const timeChange = getTimeStat(prevTimeEnd, timeEnd);
260
- const timeIncrease = `(+${timeChange})`;
241
+ const timeIncrease = `(${timeChange})`;
261
242
  const filePath = getOutputFilename(pipeline.getConfig(), path, pageData.route.type);
262
243
  const lineIcon = i === paths.length - 1 ? "\u2514\u2500" : "\u251C\u2500";
263
- logger.info(null, ` ${cyan(lineIcon)} ${dim(filePath)} ${dim(timeIncrease)}`);
244
+ logger.info(null, ` ${blue(lineIcon)} ${dim(filePath)} ${dim(timeIncrease)}`);
264
245
  prevTimeEnd = timeEnd;
265
246
  }
266
247
  }
@@ -292,13 +273,13 @@ async function getPathsForRoute(pageData, mod, pipeline, builtPaths) {
292
273
  logger,
293
274
  ssr: isServerLikeOutput(opts.settings.config)
294
275
  }).catch((err) => {
295
- logger.debug("build", `\u251C\u2500\u2500 ${colors.bold(colors.red("\u2717"))} ${route.component}`);
276
+ logger.debug("build", `\u251C\u2500\u2500 ${bold(red("\u2717"))} ${route.component}`);
296
277
  throw err;
297
278
  });
298
279
  const label = staticPaths.length === 1 ? "page" : "pages";
299
280
  logger.debug(
300
281
  "build",
301
- `\u251C\u2500\u2500 ${colors.bold(colors.green("\u2714"))} ${route.component} \u2192 ${colors.magenta(
282
+ `\u251C\u2500\u2500 ${bold(green("\u2714"))} ${route.component} \u2192 ${magenta(
302
283
  `[${staticPaths.length} ${label}]`
303
284
  )}`
304
285
  );
@@ -435,7 +416,6 @@ async function generatePath(pathname, gopts, pipeline) {
435
416
  defaultLocale: i18n?.defaultLocale
436
417
  });
437
418
  let body;
438
- let encoding;
439
419
  let response;
440
420
  try {
441
421
  response = await pipeline.renderRoute(renderContext, mod);
@@ -472,13 +452,12 @@ async function generatePath(pathname, gopts, pipeline) {
472
452
  if (!response.body)
473
453
  return;
474
454
  body = Buffer.from(await response.arrayBuffer());
475
- encoding = response.headers.get("X-Astro-Encoding") ?? "utf-8";
476
455
  }
477
456
  const outFolder = getOutFolder(pipeline.getConfig(), pathname, route.type);
478
457
  const outFile = getOutFile(pipeline.getConfig(), outFolder, pathname, route.type);
479
458
  route.distURL = outFile;
480
459
  await fs.promises.mkdir(outFolder, { recursive: true });
481
- await fs.promises.writeFile(outFile, body, encoding);
460
+ await fs.promises.writeFile(outFile, body);
482
461
  }
483
462
  }
484
463
  function createBuildManifest(settings, internals, renderers) {
@@ -1,4 +1,4 @@
1
- import * as colors from "kleur/colors";
1
+ import { blue, bold, green } from "kleur/colors";
2
2
  import fs from "node:fs";
3
3
  import { performance } from "node:perf_hooks";
4
4
  import { fileURLToPath } from "node:url";
@@ -31,8 +31,9 @@ async function build(inlineConfig, options = {}) {
31
31
  if (astroConfig.experimental.contentCollectionCache && options.force) {
32
32
  const contentCacheDir = new URL("./content/", astroConfig.cacheDir);
33
33
  if (fs.existsSync(contentCacheDir)) {
34
- logger.warn("content", "clearing cache");
34
+ logger.debug("content", "clearing content cache");
35
35
  await fs.promises.rm(contentCacheDir, { force: true, recursive: true });
36
+ logger.warn("content", "content cache cleared (force)");
36
37
  }
37
38
  }
38
39
  const settings = await createSettings(astroConfig, fileURLToPath(astroConfig.root));
@@ -100,9 +101,10 @@ class AstroBuilder {
100
101
  async build({ viteConfig }) {
101
102
  await runHookBuildStart({ config: this.settings.config, logging: this.logger });
102
103
  this.validateConfig();
103
- this.logger.info("build", `output target: ${colors.green(this.settings.config.output)}`);
104
+ this.logger.info("build", `output: ${blue('"' + this.settings.config.output + '"')}`);
105
+ this.logger.info("build", `directory: ${blue(fileURLToPath(this.settings.config.outDir))}`);
104
106
  if (this.settings.adapter) {
105
- this.logger.info("build", `deploy adapter: ${colors.green(this.settings.adapter.name)}`);
107
+ this.logger.info("build", `adapter: ${green(this.settings.adapter.name)}`);
106
108
  }
107
109
  this.logger.info("build", "Collecting build info...");
108
110
  this.timer.loadStart = performance.now();
@@ -116,7 +118,7 @@ class AstroBuilder {
116
118
  this.timer.buildStart = performance.now();
117
119
  this.logger.info(
118
120
  "build",
119
- colors.dim(`Completed in ${getTimeStat(this.timer.init, performance.now())}.`)
121
+ green(`\u2713 Completed in ${getTimeStat(this.timer.init, performance.now())}.`)
120
122
  );
121
123
  const opts = {
122
124
  allPages,
@@ -174,30 +176,6 @@ class AstroBuilder {
174
176
  `the outDir cannot be the root folder. Please build to a folder such as dist.`
175
177
  );
176
178
  }
177
- if (config.build.split === true) {
178
- if (config.output === "static") {
179
- this.logger.warn(
180
- "configuration",
181
- 'The option `build.split` won\'t take effect, because `output` is not `"server"` or `"hybrid"`.'
182
- );
183
- }
184
- this.logger.warn(
185
- "configuration",
186
- "The option `build.split` is deprecated. Use the adapter options."
187
- );
188
- }
189
- if (config.build.excludeMiddleware === true) {
190
- if (config.output === "static") {
191
- this.logger.warn(
192
- "configuration",
193
- 'The option `build.excludeMiddleware` won\'t take effect, because `output` is not `"server"` or `"hybrid"`.'
194
- );
195
- }
196
- this.logger.warn(
197
- "configuration",
198
- "The option `build.excludeMiddleware` is deprecated. Use the adapter options."
199
- );
200
- }
201
179
  }
202
180
  /** Stats */
203
181
  async printStats({
@@ -209,12 +187,12 @@ class AstroBuilder {
209
187
  const total = getTimeStat(timeStart, performance.now());
210
188
  let messages = [];
211
189
  if (buildMode === "static") {
212
- messages = [`${pageCount} page(s) built in`, colors.bold(total)];
190
+ messages = [`${pageCount} page(s) built in`, bold(total)];
213
191
  } else {
214
- messages = ["Server built in", colors.bold(total)];
192
+ messages = ["Server built in", bold(total)];
215
193
  }
216
194
  logger.info("build", messages.join(" "));
217
- logger.info("build", `${colors.bold("Complete!")}`);
195
+ logger.info("build", `${bold("Complete!")}`);
218
196
  }
219
197
  }
220
198
  export {
@@ -99,9 +99,9 @@ function* eachPageFromAllPages(allPages) {
99
99
  }
100
100
  }
101
101
  function* eachPageDataFromEntryPoint(internals) {
102
- for (const [entryPoint, filePath] of internals.entrySpecifierToBundleMap) {
103
- if (entryPoint.includes(ASTRO_PAGE_RESOLVED_MODULE_ID) || entryPoint.includes(RESOLVED_SPLIT_MODULE_ID)) {
104
- const [, pageName] = entryPoint.split(":");
102
+ for (const [entrypoint, filePath] of internals.entrySpecifierToBundleMap) {
103
+ if (entrypoint.includes(ASTRO_PAGE_RESOLVED_MODULE_ID) || entrypoint.includes(RESOLVED_SPLIT_MODULE_ID)) {
104
+ const [, pageName] = entrypoint.split(":");
105
105
  const pageData = internals.pagesByComponent.get(
106
106
  `${pageName.replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, ".")}`
107
107
  );
@@ -31,8 +31,8 @@ export declare function createPluginContainer(options: StaticBuildOptions, inter
31
31
  internals: BuildInternals;
32
32
  register(plugin: AstroBuildPlugin): void;
33
33
  runBeforeHook(target: BuildTarget, input: Set<string>): Promise<{
34
- vitePlugins: (VitePlugin | VitePlugin[])[];
35
- lastVitePlugins: (VitePlugin | VitePlugin[])[];
34
+ vitePlugins: (VitePlugin<any> | VitePlugin<any>[])[];
35
+ lastVitePlugins: (VitePlugin<any> | VitePlugin<any>[])[];
36
36
  }>;
37
37
  runPostHook(ssrReturn: ViteBuildReturn, clientReturn: ViteBuildReturn | null): Promise<Map<string, {
38
38
  targets: BuildTarget[];
@@ -76,10 +76,7 @@ function pluginManifest(options, internals) {
76
76
  throw new Error(`Did not generate an entry chunk for SSR`);
77
77
  }
78
78
  const manifest = await createManifest(options, internals);
79
- const shouldPassMiddlewareEntryPoint = (
80
- // TODO: remove in Astro 4.0
81
- options.settings.config.build.excludeMiddleware || options.settings.adapter?.adapterFeatures?.edgeMiddleware
82
- );
79
+ const shouldPassMiddlewareEntryPoint = options.settings.adapter?.adapterFeatures?.edgeMiddleware;
83
80
  await runHookBuildSsr({
84
81
  config: options.settings.config,
85
82
  manifest,