@astrojs/cloudflare 6.6.1 → 6.6.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.
- package/dist/index.js +34 -18
- package/dist/server.directory.d.ts +1 -1
- package/dist/server.directory.js +3 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRedirectsFromAstroRoutes } from "@astrojs/underscore-redirects";
|
|
2
2
|
import esbuild from "esbuild";
|
|
3
|
-
import * as fs from "fs";
|
|
4
|
-
import * as os from "os";
|
|
5
|
-
import {
|
|
3
|
+
import * as fs from "node:fs";
|
|
4
|
+
import * as os from "node:os";
|
|
5
|
+
import { sep } from "node:path";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
7
|
import glob from "tiny-glob";
|
|
7
|
-
import { fileURLToPath, pathToFileURL } from "url";
|
|
8
8
|
function getAdapter(isModeDirectory) {
|
|
9
9
|
return isModeDirectory ? {
|
|
10
10
|
name: "@astrojs/cloudflare",
|
|
@@ -68,6 +68,10 @@ function createIntegration(args) {
|
|
|
68
68
|
}
|
|
69
69
|
vite.ssr ||= {};
|
|
70
70
|
vite.ssr.target = "webworker";
|
|
71
|
+
vite.define = {
|
|
72
|
+
"process.env": "process.env",
|
|
73
|
+
...vite.define
|
|
74
|
+
};
|
|
71
75
|
}
|
|
72
76
|
},
|
|
73
77
|
"astro:build:ssr": ({ entryPoints }) => {
|
|
@@ -80,11 +84,11 @@ function createIntegration(args) {
|
|
|
80
84
|
await fs.promises.mkdir(functionsUrl, { recursive: true });
|
|
81
85
|
}
|
|
82
86
|
if (isModeDirectory && _buildConfig.split) {
|
|
83
|
-
const entryPointsRouteData = [..._entryPoints.keys()];
|
|
84
87
|
const entryPointsURL = [..._entryPoints.values()];
|
|
85
88
|
const entryPaths = entryPointsURL.map((entry) => fileURLToPath(entry));
|
|
86
|
-
const
|
|
87
|
-
const
|
|
89
|
+
const outputUrl = new URL("$astro", _buildConfig.server);
|
|
90
|
+
const outputDir = fileURLToPath(outputUrl);
|
|
91
|
+
await esbuild.build({
|
|
88
92
|
target: "es2020",
|
|
89
93
|
platform: "browser",
|
|
90
94
|
conditions: ["workerd", "worker", "browser"],
|
|
@@ -99,19 +103,31 @@ function createIntegration(args) {
|
|
|
99
103
|
},
|
|
100
104
|
logOverride: {
|
|
101
105
|
"ignored-bare-import": "silent"
|
|
102
|
-
}
|
|
103
|
-
write: false
|
|
106
|
+
}
|
|
104
107
|
});
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
const outputFiles = await glob(`**/*`, {
|
|
109
|
+
cwd: outputDir,
|
|
110
|
+
filesOnly: true
|
|
111
|
+
});
|
|
112
|
+
for (const outputFile of outputFiles) {
|
|
113
|
+
const path = outputFile.split(sep);
|
|
114
|
+
const finalSegments = path.map(
|
|
115
|
+
(segment) => segment.replace(/(\_)(\w+)(\_)/g, (_, __, prop) => {
|
|
116
|
+
return `[${prop}]`;
|
|
117
|
+
}).replace(/(\_\-\-\-)(\w+)(\_)/g, (_, __, prop) => {
|
|
118
|
+
return `[[${prop}]]`;
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
finalSegments[finalSegments.length - 1] = finalSegments[finalSegments.length - 1].replace("entry.", "").replace(/(.*)\.(\w+)\.(\w+)$/g, (_, fileName, __, newExt) => {
|
|
122
|
+
return `${fileName}.${newExt}`;
|
|
108
123
|
});
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
124
|
+
const finalDirPath = finalSegments.slice(0, -1).join(sep);
|
|
125
|
+
const finalPath = finalSegments.join(sep);
|
|
126
|
+
const newDirUrl = new URL(finalDirPath, functionsUrl);
|
|
127
|
+
await fs.promises.mkdir(newDirUrl, { recursive: true });
|
|
128
|
+
const oldFileUrl = new URL(`$astro/${outputFile}`, outputUrl);
|
|
129
|
+
const newFileUrl = new URL(finalPath, functionsUrl);
|
|
130
|
+
await fs.promises.rename(oldFileUrl, newFileUrl);
|
|
115
131
|
}
|
|
116
132
|
} else {
|
|
117
133
|
const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server));
|
|
@@ -5,6 +5,6 @@ export declare function createExports(manifest: SSRManifest): {
|
|
|
5
5
|
request: Request & CFRequest;
|
|
6
6
|
next: (request: Request) => void;
|
|
7
7
|
waitUntil: EventContext<unknown, any, unknown>['waitUntil'];
|
|
8
|
-
} & Record<string, unknown>) => Promise<
|
|
8
|
+
} & Record<string, unknown>) => Promise<import("@cloudflare/workers-types").Response | Response>;
|
|
9
9
|
manifest: SSRManifest;
|
|
10
10
|
};
|
package/dist/server.directory.js
CHANGED
|
@@ -13,7 +13,9 @@ function createExports(manifest) {
|
|
|
13
13
|
process.env = runtimeEnv.env;
|
|
14
14
|
const { pathname } = new URL(request.url);
|
|
15
15
|
if (manifest.assets.has(pathname)) {
|
|
16
|
-
return
|
|
16
|
+
return runtimeEnv.env.ASSETS.fetch(
|
|
17
|
+
request
|
|
18
|
+
);
|
|
17
19
|
}
|
|
18
20
|
let routeData = app.match(request, { matchNotFound: true });
|
|
19
21
|
if (routeData) {
|
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": "6.6.
|
|
4
|
+
"version": "6.6.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"tiny-glob": "^0.2.9"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"astro": "^2.8.
|
|
41
|
+
"astro": "^2.8.4"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"chai": "^4.3.7",
|
|
45
45
|
"cheerio": "1.0.0-rc.12",
|
|
46
46
|
"mocha": "^9.2.2",
|
|
47
47
|
"wrangler": "^2.0.23",
|
|
48
|
-
"astro": "2.8.
|
|
48
|
+
"astro": "2.8.4",
|
|
49
49
|
"astro-scripts": "0.0.14"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|