@astrojs/cloudflare 11.2.0 → 12.0.0-beta.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.
- package/dist/entrypoints/image-service.js +1 -3
- package/dist/entrypoints/middleware.js +2 -0
- package/dist/index.js +7 -11
- package/dist/utils/generate-routes-json.d.ts +3 -3
- package/dist/utils/generate-routes-json.js +1 -0
- package/dist/utils/image-config.d.ts +16 -1
- package/dist/utils/image-config.js +4 -3
- package/package.json +10 -10
|
@@ -26,9 +26,7 @@ const service = {
|
|
|
26
26
|
// If it's not an imported image, nor is it allowed using the current domains or remote patterns, we'll just return the original URL
|
|
27
27
|
return options.src;
|
|
28
28
|
}
|
|
29
|
-
const imageEndpoint = joinPaths(
|
|
30
|
-
// @ts-expect-error - Property 'env' does not exist on type 'ImportMeta'.ts(2339)
|
|
31
|
-
import.meta.env.BASE_URL, '/cdn-cgi/image', resizingParams.join(','), imageSource);
|
|
29
|
+
const imageEndpoint = joinPaths(import.meta.env.BASE_URL, '/cdn-cgi/image', resizingParams.join(','), imageSource);
|
|
32
30
|
return imageEndpoint;
|
|
33
31
|
},
|
|
34
32
|
};
|
|
@@ -6,7 +6,9 @@ const middlewares = {
|
|
|
6
6
|
[When.DevServer]: (_, next) => next(),
|
|
7
7
|
[When.Server]: (_, next) => next(),
|
|
8
8
|
[When.Prerender]: (ctx, next) => {
|
|
9
|
+
// @ts-expect-error
|
|
9
10
|
if (ctx.locals.runtime === undefined) {
|
|
11
|
+
// @ts-expect-error
|
|
10
12
|
ctx.locals.runtime = {
|
|
11
13
|
env: process.env,
|
|
12
14
|
};
|
package/dist/index.js
CHANGED
|
@@ -15,8 +15,8 @@ function wrapWithSlashes(path) {
|
|
|
15
15
|
}
|
|
16
16
|
function setProcessEnv(config, env) {
|
|
17
17
|
const getEnv = createGetEnv(env);
|
|
18
|
-
if (config.
|
|
19
|
-
for (const key of Object.keys(config.
|
|
18
|
+
if (config.env?.schema) {
|
|
19
|
+
for (const key of Object.keys(config.env.schema)) {
|
|
20
20
|
const value = getEnv(key);
|
|
21
21
|
if (value !== undefined) {
|
|
22
22
|
process.env[key] = value;
|
|
@@ -72,9 +72,9 @@ export default function createIntegration(args) {
|
|
|
72
72
|
order: 'pre',
|
|
73
73
|
});
|
|
74
74
|
},
|
|
75
|
-
'astro:config:done': ({ setAdapter, config }) => {
|
|
76
|
-
if (
|
|
77
|
-
|
|
75
|
+
'astro:config:done': ({ setAdapter, config, buildOutput, logger }) => {
|
|
76
|
+
if (buildOutput === 'static') {
|
|
77
|
+
logger.warn('[@astrojs/cloudflare] This adapter is intended to be used with server rendered pages, which this project does not contain any of. As such, this adapter is unnecessary.');
|
|
78
78
|
}
|
|
79
79
|
_config = config;
|
|
80
80
|
setAdapter({
|
|
@@ -82,19 +82,15 @@ export default function createIntegration(args) {
|
|
|
82
82
|
serverEntrypoint: '@astrojs/cloudflare/entrypoints/server.js',
|
|
83
83
|
exports: ['default'],
|
|
84
84
|
adapterFeatures: {
|
|
85
|
-
functionPerRoute: false,
|
|
86
85
|
edgeMiddleware: false,
|
|
86
|
+
buildOutput: 'server',
|
|
87
87
|
},
|
|
88
88
|
supportedAstroFeatures: {
|
|
89
89
|
serverOutput: 'stable',
|
|
90
90
|
hybridOutput: 'stable',
|
|
91
91
|
staticOutput: 'unsupported',
|
|
92
92
|
i18nDomains: 'experimental',
|
|
93
|
-
|
|
94
|
-
supportKind: 'stable',
|
|
95
|
-
isSharpCompatible: false,
|
|
96
|
-
isSquooshCompatible: false,
|
|
97
|
-
},
|
|
93
|
+
sharpImageService: 'limited',
|
|
98
94
|
envGetSecret: 'experimental',
|
|
99
95
|
},
|
|
100
96
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { AstroConfig, AstroIntegrationLogger,
|
|
1
|
+
import type { AstroConfig, AstroIntegrationLogger, IntegrationRouteData, RoutePart } from 'astro';
|
|
2
2
|
export declare function getParts(part: string): RoutePart[];
|
|
3
|
-
export declare function createRoutesFile(_config: AstroConfig, logger: AstroIntegrationLogger, routes:
|
|
3
|
+
export declare function createRoutesFile(_config: AstroConfig, logger: AstroIntegrationLogger, routes: IntegrationRouteData[], pages: {
|
|
4
4
|
pathname: string;
|
|
5
|
-
}[], redirects:
|
|
5
|
+
}[], redirects: IntegrationRouteData['segments'][], includeExtends: {
|
|
6
6
|
pattern: string;
|
|
7
7
|
}[] | undefined, excludeExtends: {
|
|
8
8
|
pattern: string;
|
|
@@ -164,6 +164,7 @@ export async function createRoutesFile(_config, logger, routes, pages, redirects
|
|
|
164
164
|
const convertedPath = segmentsToCfSyntax(route.segments, _config);
|
|
165
165
|
if (route.pathname === '/404' && route.prerender === true)
|
|
166
166
|
hasPrerendered404 = true;
|
|
167
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
167
168
|
switch (route.type) {
|
|
168
169
|
case 'page':
|
|
169
170
|
if (route.prerender === false)
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import type { AstroConfig, AstroIntegrationLogger, HookParameters } from 'astro';
|
|
2
2
|
export declare function setImageConfig(service: string, config: AstroConfig['image'], command: HookParameters<'astro:config:setup'>['command'], logger: AstroIntegrationLogger): {
|
|
3
3
|
service: import("astro").ImageServiceConfig<Record<string, any>>;
|
|
4
|
+
endpoint: {
|
|
5
|
+
route: string;
|
|
6
|
+
entrypoint?: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
domains: string[];
|
|
9
|
+
remotePatterns: {
|
|
10
|
+
port?: string | undefined;
|
|
11
|
+
protocol?: string | undefined;
|
|
12
|
+
hostname?: string | undefined;
|
|
13
|
+
pathname?: string | undefined;
|
|
14
|
+
}[];
|
|
15
|
+
} | {
|
|
16
|
+
service: import("astro").ImageServiceConfig<Record<string, any>>;
|
|
17
|
+
endpoint: {
|
|
18
|
+
entrypoint: string | undefined;
|
|
19
|
+
};
|
|
4
20
|
domains: string[];
|
|
5
21
|
remotePatterns: {
|
|
6
22
|
port?: string | undefined;
|
|
@@ -8,5 +24,4 @@ export declare function setImageConfig(service: string, config: AstroConfig['ima
|
|
|
8
24
|
hostname?: string | undefined;
|
|
9
25
|
pathname?: string | undefined;
|
|
10
26
|
}[];
|
|
11
|
-
endpoint?: string | undefined;
|
|
12
27
|
};
|
|
@@ -14,13 +14,14 @@ export function setImageConfig(service, config, command, logger) {
|
|
|
14
14
|
return {
|
|
15
15
|
...config,
|
|
16
16
|
service: sharpImageService(),
|
|
17
|
-
endpoint:
|
|
17
|
+
endpoint: {
|
|
18
|
+
entrypoint: command === 'dev' ? undefined : '@astrojs/cloudflare/image-endpoint',
|
|
19
|
+
},
|
|
18
20
|
};
|
|
19
21
|
case 'custom':
|
|
20
22
|
return { ...config };
|
|
21
23
|
default:
|
|
22
|
-
if (config.service.entrypoint === 'astro/assets/services/sharp'
|
|
23
|
-
config.service.entrypoint === 'astro/assets/services/squoosh') {
|
|
24
|
+
if (config.service.entrypoint === 'astro/assets/services/sharp') {
|
|
24
25
|
logger.warn(`The current configuration does not support image optimization. To allow your project to build with the original, unoptimized images, the image service has been automatically switched to the 'noop' option. See https://docs.astro.build/en/reference/configuration-reference/#imageservice`);
|
|
25
26
|
return { ...config, service: passthroughImageService() };
|
|
26
27
|
}
|
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": "
|
|
4
|
+
"version": "12.0.0-beta.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -30,27 +30,27 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@astrojs/internal-helpers": "0.4.1",
|
|
33
|
-
"@astrojs/underscore-redirects": "^0.
|
|
33
|
+
"@astrojs/underscore-redirects": "^0.4.0-alpha.0",
|
|
34
34
|
"@cloudflare/workers-types": "^4.20241022.0",
|
|
35
|
-
"
|
|
35
|
+
"@inox-tools/astro-when": "^0.2.4",
|
|
36
|
+
"esbuild": "^0.24.0",
|
|
36
37
|
"estree-walker": "^3.0.3",
|
|
37
38
|
"magic-string": "^0.30.12",
|
|
38
|
-
"miniflare": "^3.
|
|
39
|
+
"miniflare": "^3.20241022.0",
|
|
39
40
|
"tiny-glob": "^0.2.9",
|
|
40
|
-
"wrangler": "^3.
|
|
41
|
-
"@inox-tools/astro-when": "^0.2.4"
|
|
41
|
+
"wrangler": "^3.84.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"astro": "^
|
|
44
|
+
"astro": "^5.0.0-alpha.8"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"astro": "^
|
|
47
|
+
"astro": "^5.0.0-alpha.8",
|
|
48
48
|
"cheerio": "1.0.0",
|
|
49
49
|
"execa": "^8.0.1",
|
|
50
50
|
"fast-glob": "^3.3.2",
|
|
51
|
-
"rollup": "^4.24.
|
|
51
|
+
"rollup": "^4.24.3",
|
|
52
52
|
"strip-ansi": "^7.1.0",
|
|
53
|
-
"vite": "
|
|
53
|
+
"vite": "6.0.0-beta.2",
|
|
54
54
|
"@astrojs/test-utils": "0.0.1",
|
|
55
55
|
"astro-scripts": "0.0.14"
|
|
56
56
|
},
|