@astrojs/cloudflare 2.1.0 → 3.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.
@@ -1,5 +1,5 @@
1
- @astrojs/cloudflare:build: cache hit, replaying output f779b2bf8afec1e9
2
- @astrojs/cloudflare:build: 
3
- @astrojs/cloudflare:build: > @astrojs/cloudflare@2.1.0 build /home/runner/work/astro/astro/packages/integrations/cloudflare
4
- @astrojs/cloudflare:build: > astro-scripts build "src/**/*.ts" && tsc
5
- @astrojs/cloudflare:build: 
1
+ @astrojs/cloudflare:build: cache hit, replaying output bb5a25392613b0d2
2
+ @astrojs/cloudflare:build: 
3
+ @astrojs/cloudflare:build: > @astrojs/cloudflare@3.1.0 build /home/runner/work/astro/astro/packages/integrations/cloudflare
4
+ @astrojs/cloudflare:build: > astro-scripts build "src/**/*.ts" && tsc
5
+ @astrojs/cloudflare:build: 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # @astrojs/cloudflare
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#5056](https://github.com/withastro/astro/pull/5056) [`e55af8a23`](https://github.com/withastro/astro/commit/e55af8a23233b6335f45b7a04b9d026990fb616c) Thanks [@matthewp](https://github.com/matthewp)! - # New build configuration
8
+
9
+ The ability to customize SSR build configuration more granularly is now available in Astro. You can now customize the output folder for `server` (the server code for SSR), `client` (your client-side JavaScript and assets), and `serverEntry` (the name of the entrypoint server module). Here are the defaults:
10
+
11
+ ```js
12
+ import { defineConfig } from 'astro/config';
13
+
14
+ export default defineConfig({
15
+ output: 'server',
16
+ build: {
17
+ server: './dist/server/',
18
+ client: './dist/client/',
19
+ serverEntry: 'entry.mjs',
20
+ },
21
+ });
22
+ ```
23
+
24
+ These new configuration options are only supported in SSR mode and are ignored when building to SSG (a static site).
25
+
26
+ ## Integration hook change
27
+
28
+ The integration hook `astro:build:start` includes a param `buildConfig` which includes all of these same options. You can continue to use this param in Astro 1.x, but it is deprecated in favor of the new `build.config` options. All of the built-in adapters have been updated to the new format. If you have an integration that depends on this param we suggest upgrading to do this instead:
29
+
30
+ ```js
31
+ export default function myIntegration() {
32
+ return {
33
+ name: 'my-integration',
34
+ hooks: {
35
+ 'astro:config:setup': ({ updateConfig }) => {
36
+ updateConfig({
37
+ build: {
38
+ server: '...',
39
+ },
40
+ });
41
+ },
42
+ },
43
+ };
44
+ }
45
+ ```
46
+
47
+ ## 3.0.0
48
+
49
+ ### Major Changes
50
+
51
+ - [#4888](https://github.com/withastro/astro/pull/4888) [`2dc582ac5`](https://github.com/withastro/astro/commit/2dc582ac5e2d6e1d434ccfe21616182e453feec3) Thanks [@AirBorne04](https://github.com/AirBorne04)! - adjusting the build settings for cloudflare (reverting back to platform browser over neutral)
52
+ adjusting the ssr settings for solidjs (to build for node)
53
+
3
54
  ## 2.1.0
4
55
 
5
56
  ### Minor Changes
package/dist/index.js CHANGED
@@ -19,13 +19,25 @@ const SHIM = `globalThis.process = {
19
19
  function createIntegration(args) {
20
20
  let _config;
21
21
  let _buildConfig;
22
+ let needsBuildConfig = false;
22
23
  const isModeDirectory = (args == null ? void 0 : args.mode) === "directory";
23
24
  return {
24
25
  name: "@astrojs/cloudflare",
25
26
  hooks: {
27
+ "astro:config:setup": ({ config, updateConfig }) => {
28
+ needsBuildConfig = !config.build.client;
29
+ updateConfig({
30
+ build: {
31
+ client: new URL("./static/", config.outDir),
32
+ server: new URL("./", config.outDir),
33
+ serverEntry: "_worker.js"
34
+ }
35
+ });
36
+ },
26
37
  "astro:config:done": ({ setAdapter, config }) => {
27
38
  setAdapter(getAdapter(isModeDirectory));
28
39
  _config = config;
40
+ _buildConfig = config.build;
29
41
  if (config.output === "static") {
30
42
  throw new Error(`
31
43
  [@astrojs/cloudflare] \`output: "server"\` is required to use this adapter. Otherwise, this adapter is not necessary to deploy a static site to Cloudflare.
@@ -33,12 +45,6 @@ function createIntegration(args) {
33
45
  `);
34
46
  }
35
47
  },
36
- "astro:build:start": ({ buildConfig }) => {
37
- _buildConfig = buildConfig;
38
- buildConfig.client = new URL("./static/", _config.outDir);
39
- buildConfig.serverEntry = "_worker.js";
40
- buildConfig.server = new URL("./", _config.outDir);
41
- },
42
48
  "astro:build:setup": ({ vite, target }) => {
43
49
  if (target === "server") {
44
50
  vite.resolve = vite.resolve || {};
@@ -51,10 +57,15 @@ function createIntegration(args) {
51
57
  vite.resolve.alias[alias.find] = alias.replacement;
52
58
  }
53
59
  }
54
- vite.ssr = {
55
- ...vite.ssr,
56
- target: "webworker"
57
- };
60
+ vite.ssr = vite.ssr || {};
61
+ vite.ssr.target = vite.ssr.target || "webworker";
62
+ }
63
+ },
64
+ "astro:build:start": ({ buildConfig }) => {
65
+ if (needsBuildConfig) {
66
+ buildConfig.client = new URL("./static/", _config.outDir);
67
+ buildConfig.server = new URL("./", _config.outDir);
68
+ buildConfig.serverEntry = "_worker.js";
58
69
  }
59
70
  },
60
71
  "astro:build:done": async () => {
@@ -62,9 +73,7 @@ function createIntegration(args) {
62
73
  const pkg = fileURLToPath(entryUrl);
63
74
  await esbuild.build({
64
75
  target: "es2020",
65
- platform: "neutral",
66
- mainFields: ["main", "module"],
67
- conditions: ["worker", "node"],
76
+ platform: "browser",
68
77
  entryPoints: [pkg],
69
78
  outfile: pkg,
70
79
  allowOverwrite: true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astrojs/cloudflare",
3
3
  "description": "Deploy your site to cloudflare pages functions",
4
- "version": "2.1.0",
4
+ "version": "3.1.0",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -27,7 +27,7 @@
27
27
  "esbuild": "^0.14.42"
28
28
  },
29
29
  "devDependencies": {
30
- "astro": "1.4.0",
30
+ "astro": "1.5.0",
31
31
  "astro-scripts": "0.0.8",
32
32
  "chai": "^4.3.6",
33
33
  "cheerio": "^1.0.0-rc.11",
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AstroAdapter, AstroConfig, AstroIntegration, BuildConfig } from 'astro';
1
+ import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro';
2
2
  import esbuild from 'esbuild';
3
3
  import * as fs from 'fs';
4
4
  import { fileURLToPath } from 'url';
@@ -7,6 +7,12 @@ type Options = {
7
7
  mode: 'directory' | 'advanced';
8
8
  };
9
9
 
10
+ interface BuildConfig {
11
+ server: URL;
12
+ client: URL;
13
+ serverEntry: string;
14
+ }
15
+
10
16
  export function getAdapter(isModeDirectory: boolean): AstroAdapter {
11
17
  return isModeDirectory
12
18
  ? {
@@ -29,14 +35,26 @@ const SHIM = `globalThis.process = {
29
35
  export default function createIntegration(args?: Options): AstroIntegration {
30
36
  let _config: AstroConfig;
31
37
  let _buildConfig: BuildConfig;
38
+ let needsBuildConfig = false;
32
39
  const isModeDirectory = args?.mode === 'directory';
33
40
 
34
41
  return {
35
42
  name: '@astrojs/cloudflare',
36
43
  hooks: {
44
+ 'astro:config:setup': ({ config, updateConfig }) => {
45
+ needsBuildConfig = !config.build.client;
46
+ updateConfig({
47
+ build: {
48
+ client: new URL('./static/', config.outDir),
49
+ server: new URL('./', config.outDir),
50
+ serverEntry: '_worker.js',
51
+ },
52
+ });
53
+ },
37
54
  'astro:config:done': ({ setAdapter, config }) => {
38
55
  setAdapter(getAdapter(isModeDirectory));
39
56
  _config = config;
57
+ _buildConfig = config.build;
40
58
 
41
59
  if (config.output === 'static') {
42
60
  throw new Error(`
@@ -45,12 +63,6 @@ export default function createIntegration(args?: Options): AstroIntegration {
45
63
  `);
46
64
  }
47
65
  },
48
- 'astro:build:start': ({ buildConfig }) => {
49
- _buildConfig = buildConfig;
50
- buildConfig.client = new URL('./static/', _config.outDir);
51
- buildConfig.serverEntry = '_worker.js';
52
- buildConfig.server = new URL('./', _config.outDir);
53
- },
54
66
  'astro:build:setup': ({ vite, target }) => {
55
67
  if (target === 'server') {
56
68
  vite.resolve = vite.resolve || {};
@@ -65,11 +77,16 @@ export default function createIntegration(args?: Options): AstroIntegration {
65
77
  (vite.resolve.alias as Record<string, string>)[alias.find] = alias.replacement;
66
78
  }
67
79
  }
68
-
69
- vite.ssr = {
70
- ...vite.ssr,
71
- target: 'webworker',
72
- };
80
+ vite.ssr = vite.ssr || {};
81
+ vite.ssr.target = vite.ssr.target || 'webworker';
82
+ }
83
+ },
84
+ 'astro:build:start': ({ buildConfig }) => {
85
+ // Backwards compat
86
+ if (needsBuildConfig) {
87
+ buildConfig.client = new URL('./static/', _config.outDir);
88
+ buildConfig.server = new URL('./', _config.outDir);
89
+ buildConfig.serverEntry = '_worker.js';
73
90
  }
74
91
  },
75
92
  'astro:build:done': async () => {
@@ -77,9 +94,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
77
94
  const pkg = fileURLToPath(entryUrl);
78
95
  await esbuild.build({
79
96
  target: 'es2020',
80
- platform: 'neutral',
81
- mainFields: ['main', 'module'],
82
- conditions: ['worker', 'node'],
97
+ platform: 'browser',
83
98
  entryPoints: [pkg],
84
99
  outfile: pkg,
85
100
  allowOverwrite: true,