@astrojs/cloudflare 12.0.0 → 12.1.0

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.
Files changed (2) hide show
  1. package/dist/index.js +14 -18
  2. package/package.json +4 -4
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 { defaultClientConditions } 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';
@@ -58,8 +59,14 @@ export default function createIntegration(args) {
58
59
  integrations: [astroWhen()],
59
60
  image: setImageConfig(args?.imageService ?? 'compile', config.image, command, logger),
60
61
  });
61
- addWatchFile(new URL('./wrangler.toml', config.root));
62
- addWatchFile(new URL('./wrangler.json', config.root));
62
+ if (args?.platformProxy?.configPath) {
63
+ addWatchFile(new URL(args.platformProxy.configPath, config.root));
64
+ }
65
+ else {
66
+ addWatchFile(new URL('./wrangler.toml', config.root));
67
+ addWatchFile(new URL('./wrangler.json', config.root));
68
+ addWatchFile(new URL('./wrangler.jsonc', config.root));
69
+ }
63
70
  addMiddleware({
64
71
  entrypoint: '@astrojs/cloudflare/entrypoints/middleware.js',
65
72
  order: 'pre',
@@ -130,11 +137,12 @@ export default function createIntegration(args) {
130
137
  vite.resolve.alias[alias.find] = alias.replacement;
131
138
  }
132
139
  }
133
- vite.resolve.conditions ||= [];
134
- // We need those conditions, previous these conditions where applied at the esbuild step which we removed
135
- // https://github.com/withastro/astro/pull/7092
136
- vite.resolve.conditions.push('workerd', 'worker');
140
+ // Support `workerd` and `worker` conditions for the ssr environment
141
+ // (previously supported in esbuild instead: https://github.com/withastro/astro/pull/7092)
137
142
  vite.ssr ||= {};
143
+ vite.ssr.resolve ||= {};
144
+ vite.ssr.resolve.conditions ||= [...defaultClientConditions];
145
+ vite.ssr.resolve.conditions.push('workerd', 'worker');
138
146
  vite.ssr.target = 'webworker';
139
147
  vite.ssr.noExternal = true;
140
148
  if (typeof _config.vite.ssr?.external === 'undefined')
@@ -161,18 +169,6 @@ export default function createIntegration(args) {
161
169
  ...vite.define,
162
170
  };
163
171
  }
164
- // we thought that vite config inside `if (target === 'server')` would not apply for client
165
- // but it seems like the same `vite` reference is used for both
166
- // so we need to reset the previous conflicting setting
167
- // in the future we should look into a more robust solution
168
- if (target === 'client') {
169
- vite.resolve ||= {};
170
- vite.resolve.conditions ||= [];
171
- vite.resolve.conditions = vite.resolve.conditions.filter((c) => c !== 'workerd' && c !== 'worker');
172
- vite.build ||= {};
173
- vite.build.rollupOptions ||= {};
174
- vite.build.rollupOptions.output ||= {};
175
- }
176
172
  },
177
173
  'astro:build:done': async ({ pages, routes, dir, logger }) => {
178
174
  await cloudflareModulePlugin.afterBuildCompleted(_config);
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",
4
+ "version": "12.1.0",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -32,25 +32,25 @@
32
32
  "@astrojs/internal-helpers": "0.4.1",
33
33
  "@astrojs/underscore-redirects": "^0.4.0-alpha.0",
34
34
  "@cloudflare/workers-types": "^4.20241112.0",
35
- "@inox-tools/astro-when": "^0.2.4",
35
+ "@inox-tools/astro-when": "^1.0.1",
36
36
  "esbuild": "^0.24.0",
37
37
  "estree-walker": "^3.0.3",
38
38
  "magic-string": "^0.30.14",
39
39
  "miniflare": "^3.20241106.1",
40
40
  "tiny-glob": "^0.2.9",
41
+ "vite": "^6.0.2",
41
42
  "wrangler": "^3.91.0"
42
43
  },
43
44
  "peerDependencies": {
44
45
  "astro": "^5.0.0"
45
46
  },
46
47
  "devDependencies": {
47
- "astro": "^5.0.0-alpha.15",
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
52
  "rollup": "^4.27.4",
52
53
  "strip-ansi": "^7.1.0",
53
- "vite": "6.0.1",
54
54
  "@astrojs/test-utils": "0.0.1",
55
55
  "astro-scripts": "0.0.14"
56
56
  },