astro 6.0.0-beta.3 → 6.0.0-beta.4

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.
@@ -1,6 +1,6 @@
1
1
  class BuildTimeAstroVersionProvider {
2
2
  // Injected during the build through esbuild define
3
- version = "6.0.0-beta.3";
3
+ version = "6.0.0-beta.4";
4
4
  }
5
5
  export {
6
6
  BuildTimeAstroVersionProvider
@@ -174,7 +174,7 @@ ${contentConfig.error.message}`
174
174
  logger.info("Content config changed");
175
175
  shouldClear = true;
176
176
  }
177
- if (previousAstroVersion && previousAstroVersion !== "6.0.0-beta.3") {
177
+ if (previousAstroVersion && previousAstroVersion !== "6.0.0-beta.4") {
178
178
  logger.info("Astro version changed");
179
179
  shouldClear = true;
180
180
  }
@@ -182,8 +182,8 @@ ${contentConfig.error.message}`
182
182
  logger.info("Clearing content store");
183
183
  this.#store.clearAll();
184
184
  }
185
- if ("6.0.0-beta.3") {
186
- await this.#store.metaStore().set("astro-version", "6.0.0-beta.3");
185
+ if ("6.0.0-beta.4") {
186
+ await this.#store.metaStore().set("astro-version", "6.0.0-beta.4");
187
187
  }
188
188
  if (currentConfigDigest) {
189
189
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "6.0.0-beta.3";
1
+ const ASTRO_VERSION = "6.0.0-beta.4";
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";
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
22
22
  await telemetry.record([]);
23
23
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
24
24
  const logger = restart.container.logger;
25
- const currentVersion = "6.0.0-beta.3";
25
+ const currentVersion = "6.0.0-beta.4";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -28,7 +28,7 @@ function serverStart({
28
28
  host,
29
29
  base
30
30
  }) {
31
- const version = "6.0.0-beta.3";
31
+ const version = "6.0.0-beta.4";
32
32
  const localPrefix = `${dim("\u2503")} Local `;
33
33
  const networkPrefix = `${dim("\u2503")} Network `;
34
34
  const emptyPrefix = " ".repeat(11);
@@ -265,7 +265,7 @@ function printHelp({
265
265
  message.push(
266
266
  linebreak(),
267
267
  ` ${bgGreen(black(` ${commandName} `))} ${green(
268
- `v${"6.0.0-beta.3"}`
268
+ `v${"6.0.0-beta.4"}`
269
269
  )} ${headline}`
270
270
  );
271
271
  }
@@ -25,6 +25,7 @@ import { baseMiddleware } from "./base.js";
25
25
  import { createController } from "./controller.js";
26
26
  import { recordServerError } from "./error.js";
27
27
  import { setRouteError } from "./server-state.js";
28
+ import { routeGuardMiddleware } from "./route-guard.js";
28
29
  import { trailingSlashMiddleware } from "./trailing-slash.js";
29
30
  import { sessionConfigToManifest } from "../core/session/utils.js";
30
31
  function createVitePluginAstroServer({
@@ -75,6 +76,10 @@ function createVitePluginAstroServer({
75
76
  route: "",
76
77
  handle: trailingSlashMiddleware(settings)
77
78
  });
79
+ viteServer.middlewares.stack.unshift({
80
+ route: "",
81
+ handle: routeGuardMiddleware(settings)
82
+ });
78
83
  viteServer.middlewares.use(async function astroDevHandler(request, response) {
79
84
  if (request.url === void 0 || !request.method) {
80
85
  response.writeHead(500, "Incomplete request");
@@ -0,0 +1,10 @@
1
+ import type * as vite from 'vite';
2
+ import type { AstroSettings } from '../types/astro.js';
3
+ /**
4
+ * Middleware that prevents Vite from serving files that exist outside
5
+ * of srcDir and publicDir when accessed via direct URL navigation.
6
+ *
7
+ * This fixes the issue where files like /README.md are served
8
+ * when they exist at the project root but aren't part of Astro's routing.
9
+ */
10
+ export declare function routeGuardMiddleware(settings: AstroSettings): vite.Connect.NextHandleFunction;
@@ -0,0 +1,54 @@
1
+ import * as fs from "node:fs";
2
+ import { notFoundTemplate } from "../template/4xx.js";
3
+ import { writeHtmlResponse } from "./response.js";
4
+ const VITE_INTERNAL_PREFIXES = [
5
+ "/@vite/",
6
+ "/@fs/",
7
+ "/@id/",
8
+ "/__vite",
9
+ "/@react-refresh",
10
+ "/node_modules/",
11
+ "/.astro/"
12
+ ];
13
+ function routeGuardMiddleware(settings) {
14
+ const { config } = settings;
15
+ return function devRouteGuard(req, res, next) {
16
+ const url = req.url;
17
+ if (!url) {
18
+ return next();
19
+ }
20
+ const accept = req.headers.accept || "";
21
+ if (!accept.includes("text/html")) {
22
+ return next();
23
+ }
24
+ let pathname;
25
+ try {
26
+ pathname = decodeURI(new URL(url, "http://localhost").pathname);
27
+ } catch {
28
+ return next();
29
+ }
30
+ if (VITE_INTERNAL_PREFIXES.some((prefix) => pathname.startsWith(prefix))) {
31
+ return next();
32
+ }
33
+ if (url.includes("?")) {
34
+ return next();
35
+ }
36
+ const publicFilePath = new URL("." + pathname, config.publicDir);
37
+ if (fs.existsSync(publicFilePath)) {
38
+ return next();
39
+ }
40
+ const srcFilePath = new URL("." + pathname, config.srcDir);
41
+ if (fs.existsSync(srcFilePath)) {
42
+ return next();
43
+ }
44
+ const rootFilePath = new URL("." + pathname, config.root);
45
+ if (fs.existsSync(rootFilePath)) {
46
+ const html = notFoundTemplate(pathname);
47
+ return writeHtmlResponse(res, 404, html);
48
+ }
49
+ return next();
50
+ };
51
+ }
52
+ export {
53
+ routeGuardMiddleware
54
+ };
@@ -1,4 +1,4 @@
1
- import { type Plugin } from 'vite';
1
+ import type { Plugin } from 'vite';
2
2
  import type { RoutesList } from '../types/astro.js';
3
3
  interface AstroVitePluginOptions {
4
4
  routesList: RoutesList;
@@ -1,5 +1,4 @@
1
1
  import { prependForwardSlash } from "@astrojs/internal-helpers/path";
2
- import { isRunnableDevEnvironment } from "vite";
3
2
  import { ASTRO_VITE_ENVIRONMENT_NAMES } from "../core/constants.js";
4
3
  import { wrapId } from "../core/util.js";
5
4
  import { inlineRE, isBuildableCSSRequest, rawRE } from "../vite-plugin-astro-server/util.js";
@@ -76,9 +75,7 @@ function astroDevCssPlugin({ routesList, command }) {
76
75
  );
77
76
  const cssWithOrder = /* @__PURE__ */ new Map();
78
77
  const componentPageId = getVirtualModulePageNameForComponent(componentPath);
79
- if (ssrEnvironment && isRunnableDevEnvironment(ssrEnvironment)) {
80
- await ssrEnvironment.runner?.import(componentPageId);
81
- }
78
+ await ssrEnvironment?.fetchModule(componentPageId);
82
79
  const resolved = await ssrEnvironment?.pluginContainer.resolveId(componentPageId);
83
80
  if (!resolved?.id) {
84
81
  return {
@@ -1,5 +1,5 @@
1
1
  import { fileURLToPath } from "node:url";
2
- import ancestor from "common-ancestor-path";
2
+ import { commonAncestorPath } from "common-ancestor-path";
3
3
  import {
4
4
  appendExtension,
5
5
  appendForwardSlash,
@@ -23,7 +23,7 @@ function getFileInfo(id, config) {
23
23
  function normalizeFilename(filename, root) {
24
24
  if (filename.startsWith("/@fs")) {
25
25
  filename = filename.slice("/@fs".length);
26
- } else if (filename.startsWith("/") && !ancestor(filename, fileURLToPath(root))) {
26
+ } else if (filename.startsWith("/") && !commonAncestorPath(filename, fileURLToPath(root))) {
27
27
  const url = new URL("." + filename, root);
28
28
  filename = viteID(url);
29
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "6.0.0-beta.3",
3
+ "version": "6.0.0-beta.4",
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",
@@ -107,7 +107,7 @@
107
107
  "boxen": "8.0.1",
108
108
  "ci-info": "^4.3.1",
109
109
  "clsx": "^2.1.1",
110
- "common-ancestor-path": "^1.0.1",
110
+ "common-ancestor-path": "^2.0.0",
111
111
  "cookie": "^1.1.1",
112
112
  "cssesc": "^3.0.0",
113
113
  "debug": "^4.4.3",
@@ -116,7 +116,7 @@
116
116
  "diff": "^8.0.3",
117
117
  "dlv": "^1.1.3",
118
118
  "dset": "^3.1.4",
119
- "es-module-lexer": "^1.7.0",
119
+ "es-module-lexer": "^2.0.0",
120
120
  "esbuild": "^0.25.0",
121
121
  "flattie": "^1.1.1",
122
122
  "fontace": "~0.4.0",
@@ -128,8 +128,8 @@
128
128
  "magicast": "^0.5.1",
129
129
  "mrmime": "^2.0.1",
130
130
  "neotraverse": "^0.6.18",
131
- "p-limit": "^6.2.0",
132
- "p-queue": "^8.1.1",
131
+ "p-limit": "^7.2.0",
132
+ "p-queue": "^9.1.0",
133
133
  "package-manager-detector": "^1.6.0",
134
134
  "piccolore": "^0.1.3",
135
135
  "picomatch": "^4.0.3",
@@ -150,8 +150,8 @@
150
150
  "vite": "^7.1.7",
151
151
  "vitefu": "^1.1.1",
152
152
  "xxhash-wasm": "^1.1.0",
153
- "yargs-parser": "^21.1.1",
154
- "yocto-spinner": "^0.2.3",
153
+ "yargs-parser": "^22.0.0",
154
+ "yocto-spinner": "^1.0.0",
155
155
  "zod": "^4.0.0",
156
156
  "@astrojs/internal-helpers": "0.7.5",
157
157
  "@astrojs/markdown-remark": "7.0.0-beta.2",
@@ -163,7 +163,6 @@
163
163
  "devDependencies": {
164
164
  "@playwright/test": "1.57.0",
165
165
  "@types/aria-query": "^5.0.4",
166
- "@types/common-ancestor-path": "^1.0.2",
167
166
  "@types/cssesc": "^3.0.2",
168
167
  "@types/debug": "^4.1.12",
169
168
  "@types/dlv": "^1.1.5",
@@ -171,7 +170,7 @@
171
170
  "@types/html-escaper": "3.0.4",
172
171
  "@types/http-cache-semantics": "^4.0.4",
173
172
  "@types/js-yaml": "^4.0.9",
174
- "@types/picomatch": "^3.0.2",
173
+ "@types/picomatch": "^4.0.2",
175
174
  "@types/prompts": "^2.4.9",
176
175
  "@types/semver": "^7.7.1",
177
176
  "@types/yargs-parser": "^21.0.3",
@@ -190,7 +189,7 @@
190
189
  "rollup": "^4.55.1",
191
190
  "sass": "^1.97.2",
192
191
  "typescript": "^5.9.3",
193
- "undici": "^6.23.0",
192
+ "undici": "^7.19.1",
194
193
  "unified": "^11.0.5",
195
194
  "vitest": "^3.2.4",
196
195
  "@astrojs/check": "0.9.7-beta.1",