astro 2.6.3 → 2.6.5

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.
@@ -399,7 +399,7 @@ export interface AstroUserConfig {
399
399
  /**
400
400
  * @docs
401
401
  * @name redirects (Experimental)
402
- * @type {RedirectConfig}
402
+ * @type {Record<string, RedirectConfig>}
403
403
  * @default `{}`
404
404
  * @version 2.6.0
405
405
  * @description Specify a mapping of redirects where the key is the route to match
@@ -439,7 +439,7 @@ export interface AstroUserConfig {
439
439
  * }
440
440
  * ```
441
441
  */
442
- redirects?: RedirectConfig;
442
+ redirects?: Record<string, RedirectConfig>;
443
443
  /**
444
444
  * @docs
445
445
  * @name site
@@ -12,6 +12,7 @@ import {
12
12
  hasPrerenderedPages
13
13
  } from "../../core/build/internal.js";
14
14
  import {
15
+ isRelativePath,
15
16
  prependForwardSlash,
16
17
  removeLeadingForwardSlash,
17
18
  removeTrailingForwardSlash
@@ -181,7 +182,11 @@ async function generatePage(opts, internals, pageData, ssrEntry, builtPaths) {
181
182
  renderers
182
183
  };
183
184
  const icon = pageData.route.type === "page" ? green("\u25B6") : magenta("\u03BB");
184
- info(opts.logging, null, `${icon} ${pageData.route.component}`);
185
+ if (isRelativePath(pageData.route.component)) {
186
+ info(opts.logging, null, `${icon} ${pageData.route.route}`);
187
+ } else {
188
+ info(opts.logging, null, `${icon} ${pageData.route.component}`);
189
+ }
185
190
  const paths = await getPathsForRoute(pageData, pageModule, opts, builtPaths);
186
191
  for (let i = 0; i < paths.length; i++) {
187
192
  const path = paths[i];
@@ -102,7 +102,7 @@ ${bgMagenta(black(" finalizing server assets "))}
102
102
  }
103
103
  async function ssrBuild(opts, internals, input, container) {
104
104
  var _a, _b, _c, _d, _e;
105
- const { settings, viteConfig } = opts;
105
+ const { allPages, settings, viteConfig } = opts;
106
106
  const ssr = isServerLikeOutput(settings.config);
107
107
  const out = ssr ? opts.buildConfig.server : getOutDirWithinCwd(settings.config.outDir);
108
108
  const { lastVitePlugins, vitePlugins } = container.runBeforeHook("ssr", input);
@@ -133,7 +133,7 @@ async function ssrBuild(opts, internals, input, container) {
133
133
  entryFileNames(chunkInfo) {
134
134
  var _a2;
135
135
  if ((_a2 = chunkInfo.facadeModuleId) == null ? void 0 : _a2.startsWith(ASTRO_PAGE_RESOLVED_MODULE_ID)) {
136
- return makeAstroPageEntryPointFileName(chunkInfo.facadeModuleId);
136
+ return makeAstroPageEntryPointFileName(chunkInfo.facadeModuleId, allPages);
137
137
  } else if (
138
138
  // checks if the path of the module we have middleware, e.g. middleware.js / middleware/index.js
139
139
  chunkInfo.moduleIds.find((m) => m.includes("middleware")) !== void 0 && // checks if the file actually export the `onRequest` function
@@ -324,8 +324,13 @@ async function ssrMoveAssets(opts) {
324
324
  removeEmptyDirs(serverAssets);
325
325
  }
326
326
  }
327
- function makeAstroPageEntryPointFileName(facadeModuleId) {
328
- return `${facadeModuleId.replace(ASTRO_PAGE_RESOLVED_MODULE_ID, "").replace("src/", "").replaceAll("[", "_").replaceAll("]", "_").replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, ".")}.mjs`;
327
+ function makeAstroPageEntryPointFileName(facadeModuleId, pages) {
328
+ var _a, _b;
329
+ const pageModuleId = facadeModuleId.replace(ASTRO_PAGE_RESOLVED_MODULE_ID, "").replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, ".");
330
+ let name = ((_b = (_a = pages[pageModuleId]) == null ? void 0 : _a.route) == null ? void 0 : _b.route) ?? pageModuleId;
331
+ if (name.endsWith("/"))
332
+ name += "index";
333
+ return `pages${name.replaceAll("[", "_").replaceAll("]", "_").replaceAll("...", "---")}.mjs`;
329
334
  }
330
335
  export {
331
336
  staticBuild,
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "2.6.3";
1
+ const ASTRO_VERSION = "2.6.5";
2
2
  const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
3
3
  ".markdown",
4
4
  ".mdown",
@@ -53,7 +53,7 @@ async function dev(settings, options) {
53
53
  isRestart: options.isRestart
54
54
  })
55
55
  );
56
- const currentVersion = "2.6.3";
56
+ const currentVersion = "2.6.5";
57
57
  if (currentVersion.includes("-")) {
58
58
  warn(options.logging, null, msg.prerelease({ currentVersion }));
59
59
  }
@@ -11,10 +11,14 @@ import { codeFrame } from "../printer.js";
11
11
  import { normalizeLF } from "../utils.js";
12
12
  function collectErrorMetadata(e, rootFolder) {
13
13
  const err = AggregateError.is(e) || Array.isArray(e.errors) ? e.errors : [e];
14
- err.forEach((error) => {
14
+ err.forEach((error, idx) => {
15
15
  var _a, _b;
16
- if (error.stack) {
17
- error = collectInfoFromStacktrace(e);
16
+ if (e.stack) {
17
+ const stackInfo = collectInfoFromStacktrace(e);
18
+ error.stack = stackInfo.stack;
19
+ error.loc = stackInfo.loc;
20
+ error.plugin = stackInfo.plugin;
21
+ error.pluginCode = stackInfo.pluginCode;
18
22
  }
19
23
  const normalizedFile = normalizePath(((_a = error.loc) == null ? void 0 : _a.file) || "");
20
24
  const normalizedRootFolder = removeLeadingForwardSlashWindows((rootFolder == null ? void 0 : rootFolder.pathname) || "");
@@ -91,11 +95,15 @@ See https://docs.astro.build/en/guides/troubleshooting/#document-or-window-is-no
91
95
  }
92
96
  function collectInfoFromStacktrace(error) {
93
97
  var _a, _b, _c;
94
- if (!error.stack)
95
- return error;
96
- error.stack = normalizeLF(error.stack);
98
+ let stackInfo = {
99
+ stack: error.stack,
100
+ plugin: error.plugin,
101
+ pluginCode: error.pluginCode,
102
+ loc: error.loc
103
+ };
104
+ stackInfo.stack = normalizeLF(error.stack);
97
105
  const stackText = stripAnsi(error.stack);
98
- if (!error.loc || !error.loc.column && !error.loc.line) {
106
+ if (!stackInfo.loc || !stackInfo.loc.column && !stackInfo.loc.line) {
99
107
  const possibleFilePath = ((_a = error.loc) == null ? void 0 : _a.file) || error.pluginCode || error.id || // TODO: this could be better, `src` might be something else
100
108
  stackText.split("\n").find((ln) => ln.includes("src") || ln.includes("node_modules"));
101
109
  const source = possibleFilePath == null ? void 0 : possibleFilePath.replace(/^[^(]+\(([^)]+).*$/, "$1").replace(/^\s+at\s+/, "");
@@ -108,18 +116,18 @@ function collectInfoFromStacktrace(error) {
108
116
  file = fileURLToPath(file);
109
117
  } catch {
110
118
  }
111
- error.loc = {
119
+ stackInfo.loc = {
112
120
  file,
113
121
  line: Number.parseInt(line),
114
122
  column: Number.parseInt(column)
115
123
  };
116
124
  }
117
125
  }
118
- if (!error.plugin) {
119
- error.plugin = ((_b = /withastro\/astro\/packages\/integrations\/([\w-]+)/gim.exec(stackText)) == null ? void 0 : _b.at(1)) || ((_c = /(@astrojs\/[\w-]+)\/(server|client|index)/gim.exec(stackText)) == null ? void 0 : _c.at(1)) || void 0;
126
+ if (!stackInfo.plugin) {
127
+ stackInfo.plugin = ((_b = /withastro\/astro\/packages\/integrations\/([\w-]+)/gim.exec(stackText)) == null ? void 0 : _b.at(1)) || ((_c = /(@astrojs\/[\w-]+)\/(server|client|index)/gim.exec(stackText)) == null ? void 0 : _c.at(1)) || void 0;
120
128
  }
121
- error.stack = cleanErrorStack(error.stack);
122
- return error;
129
+ stackInfo.stack = cleanErrorStack(error.stack);
130
+ return stackInfo;
123
131
  }
124
132
  function cleanErrorStack(stack) {
125
133
  return stack.split(/\n/g).map((l) => l.replace(/\/@fs\//g, "/")).join("\n");
@@ -913,9 +913,9 @@ export declare const AstroErrorData: {
913
913
  /**
914
914
  * @docs
915
915
  * @see
916
- * - [The reserved entry `slug` field](https://docs.astro.build/en/guides/content-collections/)
916
+ * - [The reserved entry `slug` field](https://docs.astro.build/en/guides/content-collections/#defining-custom-slugs)
917
917
  * @description
918
- * A content collection schema should not contain the `slug` field. This is reserved by Astro for generating entry slugs. Remove the `slug` field from your schema, or choose a different name.
918
+ * A content collection schema should not contain the `slug` field. This is reserved by Astro for generating entry slugs. Remove `slug` from your schema. You can still use custom slugs in your frontmatter.
919
919
  */
920
920
  readonly ContentSchemaContainsSlugError: {
921
921
  readonly title: "Content Schema should not contain `slug`.";
@@ -976,6 +976,7 @@ export declare const AstroErrorData: {
976
976
  };
977
977
  /**
978
978
  * @docs
979
+ * @message `COLLECTION_NAME` contains multiple entries with the same slug: `SLUG`. Slugs must be unique.
979
980
  * @description
980
981
  * Content collection entries must have unique slugs. Duplicates are often caused by the `slug` frontmatter property.
981
982
  */
@@ -965,9 +965,9 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
965
965
  /**
966
966
  * @docs
967
967
  * @see
968
- * - [The reserved entry `slug` field](https://docs.astro.build/en/guides/content-collections/)
968
+ * - [The reserved entry `slug` field](https://docs.astro.build/en/guides/content-collections/#defining-custom-slugs)
969
969
  * @description
970
- * A content collection schema should not contain the `slug` field. This is reserved by Astro for generating entry slugs. Remove the `slug` field from your schema, or choose a different name.
970
+ * A content collection schema should not contain the `slug` field. This is reserved by Astro for generating entry slugs. Remove `slug` from your schema. You can still use custom slugs in your frontmatter.
971
971
  */
972
972
  ContentSchemaContainsSlugError: {
973
973
  title: "Content Schema should not contain `slug`.",
@@ -1034,6 +1034,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
1034
1034
  },
1035
1035
  /**
1036
1036
  * @docs
1037
+ * @message `COLLECTION_NAME` contains multiple entries with the same slug: `SLUG`. Slugs must be unique.
1037
1038
  * @description
1038
1039
  * Content collection entries must have unique slugs. Duplicates are often caused by the `slug` frontmatter property.
1039
1040
  */
@@ -47,7 +47,7 @@ function serverStart({
47
47
  base,
48
48
  isRestart = false
49
49
  }) {
50
- const version = "2.6.3";
50
+ const version = "2.6.5";
51
51
  const localPrefix = `${dim("\u2503")} Local `;
52
52
  const networkPrefix = `${dim("\u2503")} Network `;
53
53
  const emptyPrefix = " ".repeat(11);
@@ -233,7 +233,7 @@ function printHelp({
233
233
  message.push(
234
234
  linebreak(),
235
235
  ` ${bgGreen(black(` ${commandName} `))} ${green(
236
- `v${"2.6.3"}`
236
+ `v${"2.6.5"}`
237
237
  )} ${headline}`
238
238
  );
239
239
  }
@@ -1,18 +1,9 @@
1
1
  import { AstroTelemetry } from "@astrojs/telemetry";
2
- import { createRequire } from "module";
2
+ import { version as viteVersion } from "vite";
3
3
  import { ASTRO_VERSION } from "../core/constants.js";
4
- const require2 = createRequire(import.meta.url);
5
- function getViteVersion() {
6
- try {
7
- const { version } = require2("vite/package.json");
8
- return version;
9
- } catch (e) {
10
- }
11
- return void 0;
12
- }
13
4
  const telemetry = new AstroTelemetry({
14
5
  astroVersion: ASTRO_VERSION,
15
- viteVersion: getViteVersion()
6
+ viteVersion
16
7
  });
17
8
  export * from "./error.js";
18
9
  export * from "./session.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "2.6.3",
3
+ "version": "2.6.5",
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",