@astrojs/cloudflare 13.5.1 → 13.5.2

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.
@@ -88,7 +88,7 @@ function serverStart({
88
88
  host,
89
89
  base
90
90
  }) {
91
- const version = "13.5.1";
91
+ const version = "13.5.2";
92
92
  const localPrefix = `${colors.dim("\u2503")} Local `;
93
93
  const networkPrefix = `${colors.dim("\u2503")} Network `;
94
94
  const emptyPrefix = " ".repeat(11);
@@ -4,6 +4,12 @@ type ESBuildPlugin = NonNullable<NonNullable<DepOptimizationConfig['esbuildOptio
4
4
  * An esbuild plugin that extracts frontmatter from .astro files during
5
5
  * dependency optimization scanning. This allows Vite to discover imports
6
6
  * in the server-side frontmatter code.
7
+ *
8
+ * This plugin uses an `onResolve` handler to intercept `.astro` files before
9
+ * Vite's built-in `vite:dep-scan` plugin routes them to the `html` namespace.
10
+ * Without this, Vite's scanner only extracts `<script>` tags from `.astro`
11
+ * files, completely missing frontmatter imports (which is where SSR-side
12
+ * dependencies like `zod`, `nanostores`, `astro:transitions`, etc. live).
7
13
  */
8
14
  export declare function astroFrontmatterScanPlugin(): ESBuildPlugin;
9
15
  export {};
@@ -1,4 +1,5 @@
1
1
  import { readFile } from "node:fs/promises";
2
+ import { dirname, isAbsolute, resolve } from "node:path";
2
3
  const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---/;
3
4
  const RETURN_REPLACE_RE = /(\/\/[^\n]*|\/\*[\s\S]*?\*\/|`(?:[^`\\]|\\.)*`|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')|(?<!\.)\breturn(\s*;|\b)/g;
4
5
  function replaceTopLevelReturns(code) {
@@ -7,11 +8,19 @@ function replaceTopLevelReturns(code) {
7
8
  return tail.trim() === ";" ? "throw 0;" : "throw ";
8
9
  });
9
10
  }
11
+ const ASTRO_FRONTMATTER_NAMESPACE = "astro-frontmatter";
10
12
  function astroFrontmatterScanPlugin() {
11
13
  return {
12
14
  name: "astro-frontmatter-scan",
13
15
  setup(build) {
14
- build.onLoad({ filter: /\.astro$/, namespace: "file" }, async (args) => {
16
+ build.onResolve({ filter: /\.astro$/ }, (args) => {
17
+ if (args.namespace !== "file" && args.namespace !== "" && args.namespace !== void 0) {
18
+ return void 0;
19
+ }
20
+ const resolvedPath = isAbsolute(args.path) ? args.path : resolve(args.resolveDir, args.path);
21
+ return { path: resolvedPath, namespace: ASTRO_FRONTMATTER_NAMESPACE };
22
+ });
23
+ build.onLoad({ filter: /\.astro$/, namespace: ASTRO_FRONTMATTER_NAMESPACE }, async (args) => {
15
24
  try {
16
25
  const code = await readFile(args.path, "utf-8");
17
26
  const frontmatterMatch = FRONTMATTER_RE.exec(code);
@@ -19,14 +28,16 @@ function astroFrontmatterScanPlugin() {
19
28
  const contents = replaceTopLevelReturns(frontmatterMatch[1]);
20
29
  return {
21
30
  contents: contents + "\nexport default {}",
22
- loader: "ts"
31
+ loader: "ts",
32
+ resolveDir: dirname(args.path)
23
33
  };
24
34
  }
25
35
  } catch {
26
36
  }
27
37
  return {
28
38
  contents: "export default {}",
29
- loader: "ts"
39
+ loader: "ts",
40
+ resolveDir: dirname(args.path)
30
41
  };
31
42
  });
32
43
  }
package/dist/index.js CHANGED
@@ -195,6 +195,11 @@ function createIntegration({
195
195
  "astro/jsx-runtime",
196
196
  "astro/app/entrypoint/dev",
197
197
  "astro/virtual-modules/middleware.js",
198
+ "astro/virtual-modules/transitions.js",
199
+ "astro/virtual-modules/transitions-router.js",
200
+ "astro/virtual-modules/transitions-types.js",
201
+ "astro/virtual-modules/transitions-events.js",
202
+ "astro/virtual-modules/transitions-swap-functions.js",
198
203
  ...isAstroPrismPackageInstalled ? prismFiles : []
199
204
  ],
200
205
  exclude: [
@@ -205,6 +210,7 @@ function createIntegration({
205
210
  "virtual:@astrojs/*",
206
211
  "@astrojs/starlight"
207
212
  ],
213
+ ignoreOutdatedRequests: true,
208
214
  esbuildOptions: {
209
215
  // Suppress Vite's `createRequire(import.meta.url)` banner to work around
210
216
  // https://github.com/vitejs/vite/issues/22004 — Vite's SSR transform
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astrojs/cloudflare",
3
3
  "description": "Deploy your site to Cloudflare Workers",
4
- "version": "13.5.1",
4
+ "version": "13.5.2",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -49,11 +49,11 @@
49
49
  "devDependencies": {
50
50
  "@cloudflare/workers-types": "^4.20260228.0",
51
51
  "@types/node": "^25.2.2",
52
+ "@types/prismjs": "1.26.6",
52
53
  "cheerio": "1.2.0",
53
54
  "devalue": "^5.6.3",
54
55
  "prismjs": "^1.30.0",
55
- "@types/prismjs": "1.26.6",
56
- "astro": "6.3.2",
56
+ "astro": "6.3.4",
57
57
  "astro-scripts": "0.0.14"
58
58
  },
59
59
  "publishConfig": {