astro 7.2.8 → 7.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.d.ts CHANGED
@@ -282,6 +282,11 @@ declare module '*.mdx' {
282
282
  export default load;
283
283
  }
284
284
 
285
+ declare module '*.html' {
286
+ const Component: (opts?: { slots?: Record<string, string> }) => string;
287
+ export default Component;
288
+ }
289
+
285
290
  declare module 'astro:static-paths' {
286
291
  export const StaticPaths: typeof import('./dist/runtime/prerender/static-paths.js').StaticPaths;
287
292
  }
@@ -1,6 +1,6 @@
1
1
  class BuildTimeAstroVersionProvider {
2
2
  // Injected during the build through esbuild define
3
- version = "7.2.8";
3
+ version = "7.2.9";
4
4
  }
5
5
  export {
6
6
  BuildTimeAstroVersionProvider
@@ -196,7 +196,7 @@ ${contentConfig.error.message}`
196
196
  logger.info("Content config changed");
197
197
  shouldClear = true;
198
198
  }
199
- if (previousAstroVersion && previousAstroVersion !== "7.2.8") {
199
+ if (previousAstroVersion && previousAstroVersion !== "7.2.9") {
200
200
  logger.info("Astro version changed");
201
201
  shouldClear = true;
202
202
  }
@@ -204,8 +204,8 @@ ${contentConfig.error.message}`
204
204
  logger.info("Clearing content store");
205
205
  this.#store.clearAll();
206
206
  }
207
- if ("7.2.8") {
208
- this.#store.metaStore().set("astro-version", "7.2.8");
207
+ if ("7.2.9") {
208
+ this.#store.metaStore().set("astro-version", "7.2.9");
209
209
  }
210
210
  if (currentConfigDigest) {
211
211
  this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -25,6 +25,14 @@ export interface BuildInternals {
25
25
  */
26
26
  inlinedScripts: Map<string, string>;
27
27
  entrySpecifierToBundleMap: Map<string, string>;
28
+ /**
29
+ * Specifiers written to `entrySpecifierToBundleMap` by the prerender environment
30
+ * that have not been overwritten by the SSR or client environments. These point
31
+ * to chunk files inside the prerender output directory, which is deleted after
32
+ * page generation. They must be stripped from the SSR manifest to avoid dangling
33
+ * references.
34
+ */
35
+ prerenderOnlyEntrySpecifiers: Set<string>;
28
36
  /**
29
37
  * A map for page-specific information.
30
38
  */
@@ -7,6 +7,7 @@ function createBuildInternals() {
7
7
  prerenderCssAssetByModuleKey: /* @__PURE__ */ new Map(),
8
8
  inlinedScripts: /* @__PURE__ */ new Map(),
9
9
  entrySpecifierToBundleMap: /* @__PURE__ */ new Map(),
10
+ prerenderOnlyEntrySpecifiers: /* @__PURE__ */ new Set(),
10
11
  pagesByKeys: /* @__PURE__ */ new Map(),
11
12
  pagesByViteID: /* @__PURE__ */ new Map(),
12
13
  pagesByClientOnly: /* @__PURE__ */ new Map(),
@@ -56,6 +56,7 @@ function pluginInternals(options, internals) {
56
56
  );
57
57
  }
58
58
  await Promise.all(promises);
59
+ const isPrerender = this.environment?.name === ASTRO_VITE_ENVIRONMENT_NAMES.prerender;
59
60
  for (const [_, chunk] of Object.entries(bundle)) {
60
61
  if (chunk.fileName.startsWith(options.settings.config.build.assets)) {
61
62
  internals.clientChunksAndAssets.add(chunk.fileName);
@@ -63,7 +64,13 @@ function pluginInternals(options, internals) {
63
64
  if (chunk.type === "chunk" && chunk.facadeModuleId) {
64
65
  const specifiers = mapping.get(chunk.facadeModuleId) || /* @__PURE__ */ new Set([chunk.facadeModuleId]);
65
66
  for (const specifier of specifiers) {
66
- internals.entrySpecifierToBundleMap.set(normalizeEntryId(specifier), chunk.fileName);
67
+ const normalizedId = normalizeEntryId(specifier);
68
+ internals.entrySpecifierToBundleMap.set(normalizedId, chunk.fileName);
69
+ if (isPrerender) {
70
+ internals.prerenderOnlyEntrySpecifiers.add(normalizedId);
71
+ } else {
72
+ internals.prerenderOnlyEntrySpecifiers.delete(normalizedId);
73
+ }
67
74
  }
68
75
  }
69
76
  }
@@ -49,7 +49,8 @@ async function manifestBuildPostHook(options, internals, {
49
49
  logger: options.logger,
50
50
  middlewareEntryPoint: shouldPassMiddlewareEntryPoint ? internals.middlewareEntryPoint : void 0
51
51
  });
52
- const ssrManifest = stripPrerenderedRouteStyles(manifest);
52
+ let ssrManifest = stripPrerenderedRouteStyles(manifest);
53
+ ssrManifest = stripPrerenderOnlyEntryModules(ssrManifest, internals);
53
54
  const code = injectManifest(ssrManifest, ssrManifestChunk.code);
54
55
  mutate(ssrManifestChunk.fileName, code, false);
55
56
  }
@@ -94,6 +95,15 @@ function stripPrerenderedRouteStyles(manifest) {
94
95
  });
95
96
  return stripped ? { ...manifest, routes } : manifest;
96
97
  }
98
+ function stripPrerenderOnlyEntryModules(manifest, internals) {
99
+ if (internals.prerenderOnlyEntrySpecifiers.size === 0) return manifest;
100
+ const filtered = Object.fromEntries(
101
+ Object.entries(manifest.entryModules).filter(
102
+ ([key]) => !internals.prerenderOnlyEntrySpecifiers.has(key)
103
+ )
104
+ );
105
+ return { ...manifest, entryModules: filtered };
106
+ }
97
107
  async function buildManifest(opts, internals, staticFiles, encodedKey) {
98
108
  const { settings } = opts;
99
109
  const routes = [];
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "7.2.8";
1
+ const ASTRO_VERSION = "7.2.9";
2
2
  const ASTRO_GENERATOR = `Astro v${ASTRO_VERSION}`;
3
3
  const ASTRO_ERROR_HEADER = "X-Astro-Error";
4
4
  const DEFAULT_404_COMPONENT = "astro-default-404.astro";
@@ -26,7 +26,7 @@ async function dev(inlineConfig) {
26
26
  await telemetry.record([]);
27
27
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
28
28
  const logger = restart.container.logger;
29
- const currentVersion = "7.2.8";
29
+ const currentVersion = "7.2.9";
30
30
  const isPrerelease = currentVersion.includes("-");
31
31
  if (!isPrerelease) {
32
32
  try {
@@ -722,10 +722,14 @@ class FetchState {
722
722
  */
723
723
  #stripHtmlExtension() {
724
724
  if (this.routeData && this.routeData.type === "page" && !routeHasHtmlExtension(this.routeData)) {
725
+ const original = this.pathname;
725
726
  this.pathname = this.pathname.replace(/\/index\.html$/, "/").replace(/\.html$/, "");
726
727
  if (this.manifest.trailingSlash === "always" && this.pathname !== "" && !this.pathname.endsWith("/")) {
727
728
  this.pathname += "/";
728
729
  }
730
+ if (this.pathname !== original && this.routeData.pattern.test(original) && !this.routeData.pattern.test(this.pathname)) {
731
+ this.pathname = original;
732
+ }
729
733
  }
730
734
  }
731
735
  #resolveRouteData() {
@@ -270,7 +270,7 @@ function printHelp({
270
270
  message.push(
271
271
  linebreak(),
272
272
  ` ${bgGreen(black(` ${commandName} `))} ${green(
273
- `v${"7.2.8"}`
273
+ `v${"7.2.9"}`
274
274
  )} ${headline}`
275
275
  );
276
276
  }
@@ -1,4 +1,4 @@
1
- import { Fragment, markHTMLString, Renderer } from "../runtime/server/index.js";
1
+ import { escapeHTML, Fragment, markHTMLString, Renderer } from "../runtime/server/index.js";
2
2
  const AstroJSX = "astro:jsx";
3
3
  const Empty = /* @__PURE__ */ Symbol("empty");
4
4
  const toSlotName = (slotAttr) => slotAttr;
@@ -48,7 +48,8 @@ function transformSetDirectives(vnode) {
48
48
  return;
49
49
  }
50
50
  if ("set:text" in vnode.props) {
51
- const children = vnode.props["set:text"];
51
+ const value = vnode.props["set:text"];
52
+ const children = typeof value === "string" ? markHTMLString(escapeHTML(value)) : value;
52
53
  delete vnode.props["set:text"];
53
54
  Object.assign(vnode.props, { children });
54
55
  return;
package/env.d.ts CHANGED
@@ -16,8 +16,3 @@ type Astro = import('./dist/types/public/context.js').AstroGlobal;
16
16
  declare const Astro: Readonly<Astro>;
17
17
 
18
18
  declare const Fragment: any;
19
-
20
- declare module '*.html' {
21
- const Component: (opts?: { slots?: Record<string, string> }) => string;
22
- export default Component;
23
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "7.2.8",
3
+ "version": "7.2.9",
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",