@astrojs/cloudflare 13.5.2 → 13.5.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.
|
@@ -88,7 +88,7 @@ function serverStart({
|
|
|
88
88
|
host,
|
|
89
89
|
base
|
|
90
90
|
}) {
|
|
91
|
-
const version = "13.5.
|
|
91
|
+
const version = "13.5.4";
|
|
92
92
|
const localPrefix = `${colors.dim("\u2503")} Local `;
|
|
93
93
|
const networkPrefix = `${colors.dim("\u2503")} Network `;
|
|
94
94
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -4,12 +4,6 @@ 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).
|
|
13
7
|
*/
|
|
14
8
|
export declare function astroFrontmatterScanPlugin(): ESBuildPlugin;
|
|
15
9
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { dirname, isAbsolute, resolve } from "node:path";
|
|
3
2
|
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---/;
|
|
4
3
|
const RETURN_REPLACE_RE = /(\/\/[^\n]*|\/\*[\s\S]*?\*\/|`(?:[^`\\]|\\.)*`|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')|(?<!\.)\breturn(\s*;|\b)/g;
|
|
5
4
|
function replaceTopLevelReturns(code) {
|
|
@@ -8,19 +7,11 @@ function replaceTopLevelReturns(code) {
|
|
|
8
7
|
return tail.trim() === ";" ? "throw 0;" : "throw ";
|
|
9
8
|
});
|
|
10
9
|
}
|
|
11
|
-
const ASTRO_FRONTMATTER_NAMESPACE = "astro-frontmatter";
|
|
12
10
|
function astroFrontmatterScanPlugin() {
|
|
13
11
|
return {
|
|
14
12
|
name: "astro-frontmatter-scan",
|
|
15
13
|
setup(build) {
|
|
16
|
-
build.
|
|
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) => {
|
|
14
|
+
build.onLoad({ filter: /\.astro$/, namespace: "file" }, async (args) => {
|
|
24
15
|
try {
|
|
25
16
|
const code = await readFile(args.path, "utf-8");
|
|
26
17
|
const frontmatterMatch = FRONTMATTER_RE.exec(code);
|
|
@@ -28,16 +19,14 @@ function astroFrontmatterScanPlugin() {
|
|
|
28
19
|
const contents = replaceTopLevelReturns(frontmatterMatch[1]);
|
|
29
20
|
return {
|
|
30
21
|
contents: contents + "\nexport default {}",
|
|
31
|
-
loader: "ts"
|
|
32
|
-
resolveDir: dirname(args.path)
|
|
22
|
+
loader: "ts"
|
|
33
23
|
};
|
|
34
24
|
}
|
|
35
25
|
} catch {
|
|
36
26
|
}
|
|
37
27
|
return {
|
|
38
28
|
contents: "export default {}",
|
|
39
|
-
loader: "ts"
|
|
40
|
-
resolveDir: dirname(args.path)
|
|
29
|
+
loader: "ts"
|
|
41
30
|
};
|
|
42
31
|
});
|
|
43
32
|
}
|
package/dist/index.js
CHANGED
|
@@ -133,6 +133,7 @@ function createIntegration({
|
|
|
133
133
|
"@astrojs/prism > prismjs/dependencies.js"
|
|
134
134
|
];
|
|
135
135
|
const isAstroPrismPackageInstalled = await getIsAstroPrismInstalled(config.root);
|
|
136
|
+
const userOptimizeDeps = config.vite?.optimizeDeps;
|
|
136
137
|
updateConfig({
|
|
137
138
|
build: {
|
|
138
139
|
redirects: false
|
|
@@ -195,12 +196,8 @@ function createIntegration({
|
|
|
195
196
|
"astro/jsx-runtime",
|
|
196
197
|
"astro/app/entrypoint/dev",
|
|
197
198
|
"astro/virtual-modules/middleware.js",
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
"astro/virtual-modules/transitions-types.js",
|
|
201
|
-
"astro/virtual-modules/transitions-events.js",
|
|
202
|
-
"astro/virtual-modules/transitions-swap-functions.js",
|
|
203
|
-
...isAstroPrismPackageInstalled ? prismFiles : []
|
|
199
|
+
...isAstroPrismPackageInstalled ? prismFiles : [],
|
|
200
|
+
...Array.isArray(userOptimizeDeps?.include) ? userOptimizeDeps.include : []
|
|
204
201
|
],
|
|
205
202
|
exclude: [
|
|
206
203
|
"unstorage/drivers/cloudflare-kv-binding",
|
|
@@ -208,16 +205,17 @@ function createIntegration({
|
|
|
208
205
|
"virtual:astro:*",
|
|
209
206
|
"virtual:astro-cloudflare:*",
|
|
210
207
|
"virtual:@astrojs/*",
|
|
211
|
-
"@astrojs/starlight"
|
|
208
|
+
"@astrojs/starlight",
|
|
209
|
+
...Array.isArray(userOptimizeDeps?.exclude) ? userOptimizeDeps.exclude : []
|
|
212
210
|
],
|
|
213
|
-
ignoreOutdatedRequests: true,
|
|
214
211
|
esbuildOptions: {
|
|
215
212
|
// Suppress Vite's `createRequire(import.meta.url)` banner to work around
|
|
216
213
|
// https://github.com/vitejs/vite/issues/22004 — Vite's SSR transform
|
|
217
214
|
// incorrectly rewrites identifiers inside `import.meta` when an imported
|
|
218
215
|
// binding shares the same name (e.g. zod v4 exports `meta`).
|
|
219
216
|
banner: { js: "" },
|
|
220
|
-
plugins: [astroFrontmatterScanPlugin()]
|
|
217
|
+
plugins: [astroFrontmatterScanPlugin()],
|
|
218
|
+
...userOptimizeDeps?.esbuildOptions?.loader ? { loader: userOptimizeDeps.esbuildOptions.loader } : {}
|
|
221
219
|
}
|
|
222
220
|
}
|
|
223
221
|
};
|
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.
|
|
4
|
+
"version": "13.5.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@cloudflare/workers-types": "^4.20260228.0",
|
|
51
|
-
"@types/node": "^
|
|
51
|
+
"@types/node": "^22.10.6",
|
|
52
52
|
"@types/prismjs": "1.26.6",
|
|
53
53
|
"cheerio": "1.2.0",
|
|
54
54
|
"devalue": "^5.6.3",
|
|
55
55
|
"prismjs": "^1.30.0",
|
|
56
|
-
"astro": "6.3.
|
|
56
|
+
"astro": "6.3.7",
|
|
57
57
|
"astro-scripts": "0.0.14"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|