@astrojs/cloudflare 13.0.0-beta.6 → 13.0.0-beta.7

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.
@@ -83,7 +83,7 @@ function serverStart({
83
83
  host,
84
84
  base
85
85
  }) {
86
- const version = "13.0.0-beta.6";
86
+ const version = "13.0.0-beta.7";
87
87
  const localPrefix = `${colors.dim("\u2503")} Local `;
88
88
  const networkPrefix = `${colors.dim("\u2503")} Network `;
89
89
  const emptyPrefix = " ".repeat(11);
@@ -0,0 +1,9 @@
1
+ import type { DepOptimizationConfig } from 'vite';
2
+ type ESBuildPlugin = NonNullable<NonNullable<DepOptimizationConfig['esbuildOptions']>['plugins']>[0];
3
+ /**
4
+ * An esbuild plugin that extracts frontmatter from .astro files during
5
+ * dependency optimization scanning. This allows Vite to discover imports
6
+ * in the server-side frontmatter code.
7
+ */
8
+ export declare function astroFrontmatterScanPlugin(): ESBuildPlugin;
9
+ export {};
@@ -0,0 +1,29 @@
1
+ import { readFile } from "node:fs/promises";
2
+ const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---/;
3
+ function astroFrontmatterScanPlugin() {
4
+ return {
5
+ name: "astro-frontmatter-scan",
6
+ setup(build) {
7
+ build.onLoad({ filter: /\.astro$/ }, async (args) => {
8
+ try {
9
+ const code = await readFile(args.path, "utf-8");
10
+ const frontmatterMatch = FRONTMATTER_RE.exec(code);
11
+ if (frontmatterMatch) {
12
+ return {
13
+ contents: frontmatterMatch[1],
14
+ loader: "ts"
15
+ };
16
+ }
17
+ } catch {
18
+ }
19
+ return {
20
+ contents: "",
21
+ loader: "ts"
22
+ };
23
+ });
24
+ }
25
+ };
26
+ }
27
+ export {
28
+ astroFrontmatterScanPlugin
29
+ };
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import { createInterface } from "node:readline/promises";
4
4
  import { removeLeadingForwardSlash } from "@astrojs/internal-helpers/path";
5
5
  import { createRedirectsFromAstroRoutes, printAsRedirects } from "@astrojs/underscore-redirects";
6
6
  import { cloudflare as cfVitePlugin } from "@cloudflare/vite-plugin";
7
+ import { astroFrontmatterScanPlugin } from "./esbuild-plugin-astro-frontmatter.js";
7
8
  import { createRoutesFile, getParts } from "./utils/generate-routes-json.js";
8
9
  import { setImageConfig } from "./utils/image-config.js";
9
10
  import { createConfigPlugin } from "./vite-plugin-config.js";
@@ -65,7 +66,6 @@ function createIntegration(args) {
65
66
  build: {
66
67
  client: new URL(`./client/`, config.outDir),
67
68
  server: new URL("./_worker.js/", config.outDir),
68
- serverEntry: config.build.serverEntry ?? "index.js",
69
69
  redirects: false
70
70
  },
71
71
  session,
@@ -118,7 +118,10 @@ function createIntegration(args) {
118
118
  "virtual:astro:*",
119
119
  "virtual:astro-cloudflare:*",
120
120
  "virtual:@astrojs/*"
121
- ]
121
+ ],
122
+ esbuildOptions: {
123
+ plugins: [astroFrontmatterScanPlugin()]
124
+ }
122
125
  }
123
126
  };
124
127
  } else if (environmentName === "client") {
@@ -14,7 +14,7 @@ export declare function setImageConfig(service: ImageService, config: AstroConfi
14
14
  pathname?: string | undefined;
15
15
  }[];
16
16
  responsiveStyles: boolean;
17
- layout?: "none" | "fixed" | "constrained" | "full-width" | undefined;
17
+ layout?: "fixed" | "none" | "constrained" | "full-width" | undefined;
18
18
  objectFit?: string | undefined;
19
19
  objectPosition?: string | undefined;
20
20
  breakpoints?: number[] | undefined;
@@ -31,7 +31,7 @@ export declare function setImageConfig(service: ImageService, config: AstroConfi
31
31
  pathname?: string | undefined;
32
32
  }[];
33
33
  responsiveStyles: boolean;
34
- layout?: "none" | "fixed" | "constrained" | "full-width" | undefined;
34
+ layout?: "fixed" | "none" | "constrained" | "full-width" | undefined;
35
35
  objectFit?: string | undefined;
36
36
  objectPosition?: string | undefined;
37
37
  breakpoints?: number[] | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astrojs/cloudflare",
3
3
  "description": "Deploy your site to Cloudflare Workers/Pages",
4
- "version": "13.0.0-beta.6",
4
+ "version": "13.0.0-beta.7",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -51,7 +51,7 @@
51
51
  "@types/node": "^25.2.2",
52
52
  "cheerio": "1.2.0",
53
53
  "devalue": "^5.6.2",
54
- "astro": "6.0.0-beta.10",
54
+ "astro": "6.0.0-beta.11",
55
55
  "astro-scripts": "0.0.14"
56
56
  },
57
57
  "publishConfig": {