@astrojs/cloudflare 12.0.0-beta.1 → 12.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.
@@ -26,7 +26,9 @@ 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(import.meta.env.BASE_URL, '/cdn-cgi/image', resizingParams.join(','), imageSource);
29
+ const imageEndpoint = joinPaths(
30
+ // @ts-expect-error Can't recognise import.meta.env
31
+ import.meta.env.BASE_URL, '/cdn-cgi/image', resizingParams.join(','), imageSource);
30
32
  return imageEndpoint;
31
33
  },
32
34
  };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { AstroIntegration } from 'astro';
2
+ import { type GetPlatformProxyOptions } from 'wrangler';
2
3
  export type { Runtime } from './entrypoints/server.js';
3
4
  export type Options = {
4
5
  /** Options for handling images. */
@@ -30,17 +31,9 @@ export type Options = {
30
31
  /**
31
32
  * Proxy configuration for the platform.
32
33
  */
33
- platformProxy?: {
34
+ platformProxy?: GetPlatformProxyOptions & {
34
35
  /** Toggle the proxy. Default `undefined`, which equals to `true`. */
35
36
  enabled?: boolean;
36
- /** Path to the configuration file. Default `wrangler.toml`. */
37
- configPath?: string;
38
- /** Enable experimental support for JSON configuration. Default `false`. */
39
- experimentalJsonConfig?: boolean;
40
- /** Configuration persistence settings. Default '.wrangler/state/v3' */
41
- persist?: boolean | {
42
- path: string;
43
- };
44
37
  };
45
38
  /**
46
39
  * Allow bundling cloudflare worker specific file types as importable modules. Defaults to true.
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ import { appendForwardSlash, prependForwardSlash, removeLeadingForwardSlash, } f
5
5
  import { createRedirectsFromAstroRoutes } from '@astrojs/underscore-redirects';
6
6
  import astroWhen from '@inox-tools/astro-when';
7
7
  import { AstroError } from 'astro/errors';
8
+ import { defaultServerConditions } from 'vite';
8
9
  import { getPlatformProxy } from 'wrangler';
9
10
  import { cloudflareModuleLoader, } from './utils/cloudflare-module-loader.js';
10
11
  import { createGetEnv } from './utils/env.js';
@@ -24,13 +25,6 @@ function setProcessEnv(config, env) {
24
25
  }
25
26
  }
26
27
  }
27
- function createPlatformProxy(platformProxy) {
28
- return getPlatformProxy({
29
- configPath: platformProxy?.configPath,
30
- experimentalJsonConfig: platformProxy?.experimentalJsonConfig ?? false,
31
- persist: platformProxy?.persist ?? true,
32
- });
33
- }
34
28
  export default function createIntegration(args) {
35
29
  let _config;
36
30
  const cloudflareModulePlugin = cloudflareModuleLoader(args?.cloudflareModules ?? true);
@@ -97,7 +91,7 @@ export default function createIntegration(args) {
97
91
  },
98
92
  'astro:server:setup': async ({ server }) => {
99
93
  if ((args?.platformProxy?.enabled ?? true) === true) {
100
- const platformProxy = await createPlatformProxy(args?.platformProxy);
94
+ const platformProxy = await getPlatformProxy(args?.platformProxy);
101
95
  setProcessEnv(_config, platformProxy.env);
102
96
  const clientLocalsSymbol = Symbol.for('astro.locals');
103
97
  server.middlewares.use(async function middleware(req, res, next) {
@@ -137,11 +131,12 @@ export default function createIntegration(args) {
137
131
  vite.resolve.alias[alias.find] = alias.replacement;
138
132
  }
139
133
  }
140
- vite.resolve.conditions ||= [];
141
- // We need those conditions, previous these conditions where applied at the esbuild step which we removed
142
- // https://github.com/withastro/astro/pull/7092
143
- vite.resolve.conditions.push('workerd', 'worker');
134
+ // Support `workerd` and `worker` conditions for the ssr environment
135
+ // (previously supported in esbuild instead: https://github.com/withastro/astro/pull/7092)
144
136
  vite.ssr ||= {};
137
+ vite.ssr.resolve ||= {};
138
+ vite.ssr.resolve.conditions ||= [...defaultServerConditions];
139
+ vite.ssr.resolve.conditions.push('workerd', 'worker');
145
140
  vite.ssr.target = 'webworker';
146
141
  vite.ssr.noExternal = true;
147
142
  if (typeof _config.vite.ssr?.external === 'undefined')
@@ -168,18 +163,6 @@ export default function createIntegration(args) {
168
163
  ...vite.define,
169
164
  };
170
165
  }
171
- // we thought that vite config inside `if (target === 'server')` would not apply for client
172
- // but it seems like the same `vite` reference is used for both
173
- // so we need to reset the previous conflicting setting
174
- // in the future we should look into a more robust solution
175
- if (target === 'client') {
176
- vite.resolve ||= {};
177
- vite.resolve.conditions ||= [];
178
- vite.resolve.conditions = vite.resolve.conditions.filter((c) => c !== 'workerd' && c !== 'worker');
179
- vite.build ||= {};
180
- vite.build.rollupOptions ||= {};
181
- vite.build.rollupOptions.output ||= {};
182
- }
183
166
  },
184
167
  'astro:build:done': async ({ pages, routes, dir, logger }) => {
185
168
  await cloudflareModulePlugin.afterBuildCompleted(_config);
@@ -12,6 +12,10 @@ export declare function setImageConfig(service: string, config: AstroConfig['ima
12
12
  hostname?: string | undefined;
13
13
  pathname?: string | undefined;
14
14
  }[];
15
+ experimentalLayout?: "fixed" | "none" | "responsive" | "full-width" | undefined;
16
+ experimentalObjectFit?: string | undefined;
17
+ experimentalObjectPosition?: string | undefined;
18
+ experimentalBreakpoints?: number[] | undefined;
15
19
  } | {
16
20
  service: import("astro").ImageServiceConfig<Record<string, any>>;
17
21
  endpoint: {
@@ -24,4 +28,8 @@ export declare function setImageConfig(service: string, config: AstroConfig['ima
24
28
  hostname?: string | undefined;
25
29
  pathname?: string | undefined;
26
30
  }[];
31
+ experimentalLayout?: "fixed" | "none" | "responsive" | "full-width" | undefined;
32
+ experimentalObjectFit?: string | undefined;
33
+ experimentalObjectPosition?: string | undefined;
34
+ experimentalBreakpoints?: number[] | undefined;
27
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/Pages",
4
- "version": "12.0.0-beta.1",
4
+ "version": "12.0.1",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -31,26 +31,26 @@
31
31
  "dependencies": {
32
32
  "@astrojs/internal-helpers": "0.4.1",
33
33
  "@astrojs/underscore-redirects": "^0.4.0-alpha.0",
34
- "@cloudflare/workers-types": "^4.20241022.0",
34
+ "@cloudflare/workers-types": "^4.20241112.0",
35
35
  "@inox-tools/astro-when": "^0.2.4",
36
36
  "esbuild": "^0.24.0",
37
37
  "estree-walker": "^3.0.3",
38
- "magic-string": "^0.30.12",
39
- "miniflare": "^3.20241022.0",
38
+ "magic-string": "^0.30.14",
39
+ "miniflare": "^3.20241106.1",
40
40
  "tiny-glob": "^0.2.9",
41
- "wrangler": "^3.84.0"
41
+ "vite": "^6.0.2",
42
+ "wrangler": "^3.91.0"
42
43
  },
43
44
  "peerDependencies": {
44
- "astro": "^5.0.0-alpha.8"
45
+ "astro": "^5.0.0"
45
46
  },
46
47
  "devDependencies": {
47
- "astro": "^5.0.0-alpha.8",
48
+ "astro": "^5.0.0",
48
49
  "cheerio": "1.0.0",
49
50
  "execa": "^8.0.1",
50
51
  "fast-glob": "^3.3.2",
51
- "rollup": "^4.24.3",
52
+ "rollup": "^4.27.4",
52
53
  "strip-ansi": "^7.1.0",
53
- "vite": "6.0.0-beta.2",
54
54
  "@astrojs/test-utils": "0.0.1",
55
55
  "astro-scripts": "0.0.14"
56
56
  },