@astrojs/cloudflare 14.0.0 → 14.0.1
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 = "14.0.
|
|
91
|
+
const version = "14.0.1";
|
|
92
92
|
const localPrefix = `${colors.dim("\u2503")} Local `;
|
|
93
93
|
const networkPrefix = `${colors.dim("\u2503")} Network `;
|
|
94
94
|
const emptyPrefix = " ".repeat(11);
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@astrojs/internal-helpers/path";
|
|
11
11
|
import { createRedirectsFromAstroRoutes, printAsRedirects } from "@astrojs/underscore-redirects";
|
|
12
12
|
import { cloudflare as cfVitePlugin } from "@cloudflare/vite-plugin";
|
|
13
|
-
import {
|
|
13
|
+
import { rolldownAstroFrontmatterScanPlugin } from "./rolldown-plugin-astro-frontmatter.js";
|
|
14
14
|
import { getParts } from "./utils/generate-routes-json.js";
|
|
15
15
|
import { buildAssetsHeadersContent } from "./utils/headers.js";
|
|
16
16
|
import {
|
|
@@ -218,6 +218,7 @@ function createIntegration({
|
|
|
218
218
|
"astro/jsx-runtime",
|
|
219
219
|
"astro/app/entrypoint/dev",
|
|
220
220
|
"astro/virtual-modules/middleware.js",
|
|
221
|
+
"astro/virtual-modules/transitions.js",
|
|
221
222
|
...isAstroPrismPackageInstalled ? prismFiles : [],
|
|
222
223
|
...Array.isArray(userOptimizeDeps?.include) ? userOptimizeDeps.include : []
|
|
223
224
|
],
|
|
@@ -230,14 +231,8 @@ function createIntegration({
|
|
|
230
231
|
"@astrojs/starlight",
|
|
231
232
|
...Array.isArray(userOptimizeDeps?.exclude) ? userOptimizeDeps.exclude : []
|
|
232
233
|
],
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
// https://github.com/vitejs/vite/issues/22004 — Vite's SSR transform
|
|
236
|
-
// incorrectly rewrites identifiers inside `import.meta` when an imported
|
|
237
|
-
// binding shares the same name (e.g. zod v4 exports `meta`).
|
|
238
|
-
banner: { js: "" },
|
|
239
|
-
plugins: [astroFrontmatterScanPlugin()],
|
|
240
|
-
...userOptimizeDeps?.esbuildOptions?.loader ? { loader: userOptimizeDeps.esbuildOptions.loader } : {}
|
|
234
|
+
rolldownOptions: {
|
|
235
|
+
plugins: [rolldownAstroFrontmatterScanPlugin()]
|
|
241
236
|
}
|
|
242
237
|
}
|
|
243
238
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* A Rolldown plugin that extracts frontmatter from .astro files during
|
|
4
|
+
* dependency optimization scanning. This allows Vite to discover imports
|
|
5
|
+
* in the server-side frontmatter code.
|
|
6
|
+
*
|
|
7
|
+
* This is the Rolldown equivalent of the esbuild plugin in
|
|
8
|
+
* `esbuild-plugin-astro-frontmatter.ts`, needed because Vite 8 uses Rolldown
|
|
9
|
+
* for dependency optimization and ignores `optimizeDeps.esbuildOptions`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function rolldownAstroFrontmatterScanPlugin(): Plugin;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---/;
|
|
3
|
+
const RETURN_REPLACE_RE = /(\/\/[^\n]*|\/\*[\s\S]*?\*\/|`(?:[^`\\]|\\.)*`|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')|(?<!\.)\breturn(\s*;|\b)/g;
|
|
4
|
+
function replaceTopLevelReturns(code) {
|
|
5
|
+
return code.replace(RETURN_REPLACE_RE, (_match, skip, tail) => {
|
|
6
|
+
if (skip !== void 0) return skip;
|
|
7
|
+
return tail.trim() === ";" ? "throw 0;" : "throw ";
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
function rolldownAstroFrontmatterScanPlugin() {
|
|
11
|
+
return {
|
|
12
|
+
name: "astro-frontmatter-scan",
|
|
13
|
+
async load(id) {
|
|
14
|
+
if (!id.endsWith(".astro")) return;
|
|
15
|
+
let code;
|
|
16
|
+
try {
|
|
17
|
+
code = await readFile(id, "utf-8");
|
|
18
|
+
} catch {
|
|
19
|
+
return { code: "export default {}", moduleType: "ts" };
|
|
20
|
+
}
|
|
21
|
+
const frontmatterMatch = FRONTMATTER_RE.exec(code);
|
|
22
|
+
if (frontmatterMatch) {
|
|
23
|
+
const contents = replaceTopLevelReturns(frontmatterMatch[1]);
|
|
24
|
+
return {
|
|
25
|
+
code: contents + "\nexport default {}",
|
|
26
|
+
moduleType: "ts"
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return { code: "export default {}", moduleType: "ts" };
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
rolldownAstroFrontmatterScanPlugin
|
|
35
|
+
};
|
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": "14.0.
|
|
4
|
+
"version": "14.0.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@cloudflare/vite-plugin": "^1.39.0",
|
|
43
43
|
"piccolore": "^0.1.3",
|
|
44
|
-
"tinyglobby": "^0.2.15",
|
|
45
44
|
"vite": "^8.0.13",
|
|
46
45
|
"@astrojs/internal-helpers": "0.10.0",
|
|
47
46
|
"@astrojs/underscore-redirects": "1.0.3"
|
|
@@ -57,7 +56,8 @@
|
|
|
57
56
|
"cheerio": "1.2.0",
|
|
58
57
|
"devalue": "^5.8.1",
|
|
59
58
|
"prismjs": "^1.30.0",
|
|
60
|
-
"
|
|
59
|
+
"tinyglobby": "^0.2.15",
|
|
60
|
+
"astro": "7.0.3",
|
|
61
61
|
"astro-scripts": "0.0.14"
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|