@astrojs/cloudflare 12.2.1 → 12.2.3

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,69 +1,52 @@
1
- /**
2
- * A Vite bundle analyzer that identifies chunks that are not used for server rendering.
3
- *
4
- * The chunks injected by Astro for prerendering are flagged as non-server chunks.
5
- * Any chunks that is only used by a non-server chunk are also flagged as non-server chunks.
6
- * This continues transitively until all non-server chunks are found.
7
- */
8
- export class NonServerChunkDetector {
9
- nonServerChunks;
10
- getPlugin() {
11
- return {
12
- name: 'non-server-chunk-detector',
13
- generateBundle: (_, bundle) => {
14
- // Skip if we bundle for client
15
- if (!bundle['index.js'])
16
- return;
17
- this.processBundle(bundle);
18
- },
19
- };
1
+ class NonServerChunkDetector {
2
+ nonServerChunks;
3
+ getPlugin() {
4
+ return {
5
+ name: "non-server-chunk-detector",
6
+ generateBundle: (_, bundle) => {
7
+ if (!bundle["index.js"]) return;
8
+ this.processBundle(bundle);
9
+ }
10
+ };
11
+ }
12
+ processBundle(bundle) {
13
+ const chunkNamesToFiles = /* @__PURE__ */ new Map();
14
+ const entryChunks = [];
15
+ const chunkToDependencies = /* @__PURE__ */ new Map();
16
+ for (const chunk of Object.values(bundle)) {
17
+ if (chunk.type !== "chunk") continue;
18
+ chunkNamesToFiles.set(chunk.name, chunk.fileName);
19
+ chunkToDependencies.set(chunk.fileName, [...chunk.imports, ...chunk.dynamicImports]);
20
+ if (chunk.isEntry) {
21
+ entryChunks.push(chunk.fileName);
22
+ }
20
23
  }
21
- processBundle(bundle) {
22
- const chunkNamesToFiles = new Map();
23
- const entryChunks = [];
24
- const chunkToDependencies = new Map();
25
- for (const chunk of Object.values(bundle)) {
26
- if (chunk.type !== 'chunk')
27
- continue;
28
- // Construct a mapping from a chunk name to its file name
29
- chunkNamesToFiles.set(chunk.name, chunk.fileName);
30
- // Construct a mapping from a chunk file to all the modules it imports
31
- chunkToDependencies.set(chunk.fileName, [...chunk.imports, ...chunk.dynamicImports]);
32
- if (chunk.isEntry) {
33
- // Entry chunks should always be kept around since they are to be imported by the runtime
34
- entryChunks.push(chunk.fileName);
35
- }
36
- }
37
- const chunkDecisions = new Map();
38
- for (const entry of entryChunks) {
39
- // Entry chunks are used on the server
40
- chunkDecisions.set(entry, true);
41
- }
42
- for (const chunk of ['prerender', 'prerender@_@astro']) {
43
- // Prerender chunks are not used on the server
44
- const fileName = chunkNamesToFiles.get(chunk);
45
- if (fileName) {
46
- chunkDecisions.set(fileName, false);
47
- }
48
- }
49
- // Start a stack of chunks that are used on the server
50
- const chunksToWalk = [...entryChunks];
51
- // Iterate over the chunks, traversing the transitive dependencies of the chunks used on the server
52
- for (let chunk = chunksToWalk.pop(); chunk; chunk = chunksToWalk.pop()) {
53
- for (const dep of chunkToDependencies.get(chunk) ?? []) {
54
- // Skip dependencies already flagged, dependencies may be repeated and/or circular
55
- if (chunkDecisions.has(dep))
56
- continue;
57
- // A dependency of a module used on the server is also used on the server
58
- chunkDecisions.set(dep, true);
59
- // Add the dependency to the stack so its own dependencies are also flagged
60
- chunksToWalk.push(dep);
61
- }
62
- }
63
- // Any chunk not flagged as used on the server is a non-server chunk
64
- this.nonServerChunks = Array.from(chunkToDependencies.keys()).filter((chunk) => !chunkDecisions.get(chunk));
24
+ const chunkDecisions = /* @__PURE__ */ new Map();
25
+ for (const entry of entryChunks) {
26
+ chunkDecisions.set(entry, true);
65
27
  }
66
- getNonServerChunks() {
67
- return this.nonServerChunks ?? [];
28
+ for (const chunk of ["prerender", "prerender@_@astro"]) {
29
+ const fileName = chunkNamesToFiles.get(chunk);
30
+ if (fileName) {
31
+ chunkDecisions.set(fileName, false);
32
+ }
68
33
  }
34
+ const chunksToWalk = [...entryChunks];
35
+ for (let chunk = chunksToWalk.pop(); chunk; chunk = chunksToWalk.pop()) {
36
+ for (const dep of chunkToDependencies.get(chunk) ?? []) {
37
+ if (chunkDecisions.has(dep)) continue;
38
+ chunkDecisions.set(dep, true);
39
+ chunksToWalk.push(dep);
40
+ }
41
+ }
42
+ this.nonServerChunks = Array.from(chunkToDependencies.keys()).filter(
43
+ (chunk) => !chunkDecisions.get(chunk)
44
+ );
45
+ }
46
+ getNonServerChunks() {
47
+ return this.nonServerChunks ?? [];
48
+ }
69
49
  }
50
+ export {
51
+ NonServerChunkDetector
52
+ };
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@astrojs/cloudflare",
3
3
  "description": "Deploy your site to Cloudflare Workers/Pages",
4
- "version": "12.2.1",
4
+ "version": "12.2.3",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/withastro/adapters.git",
12
- "directory": "packages/cloudflare"
11
+ "url": "https://github.com/withastro/astro.git",
12
+ "directory": "packages/integrations/cloudflare"
13
13
  },
14
14
  "keywords": [
15
15
  "withastro",
16
16
  "astro-adapter"
17
17
  ],
18
- "bugs": "https://github.com/withastro/adapters/issues",
18
+ "bugs": "https://github.com/withastro/astro/issues",
19
19
  "homepage": "https://docs.astro.build/en/guides/integrations-guide/cloudflare/",
20
20
  "exports": {
21
21
  ".": "./dist/index.js",
@@ -29,35 +29,33 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@astrojs/internal-helpers": "0.4.2",
33
- "@astrojs/underscore-redirects": "^0.6.0",
34
32
  "@cloudflare/workers-types": "^4.20250109.0",
35
- "esbuild": "^0.24.0",
33
+ "esbuild": "^0.25.0",
36
34
  "estree-walker": "^3.0.3",
37
35
  "magic-string": "^0.30.17",
38
36
  "miniflare": "^3.20241230.1",
39
- "tiny-glob": "^0.2.9",
40
- "vite": "^6.0.7",
41
- "wrangler": "^3.101.0"
37
+ "tinyglobby": "^0.2.12",
38
+ "vite": "^6.2.0",
39
+ "wrangler": "^3.101.0",
40
+ "@astrojs/internal-helpers": "0.6.0",
41
+ "@astrojs/underscore-redirects": "0.6.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "astro": "^5.0.0"
45
45
  },
46
46
  "devDependencies": {
47
- "astro": "^5.1.6",
48
47
  "cheerio": "1.0.0",
49
48
  "execa": "^8.0.1",
50
- "fast-glob": "^3.3.3",
51
49
  "rollup": "^4.30.1",
52
50
  "strip-ansi": "^7.1.0",
53
- "@astrojs/test-utils": "0.0.2",
51
+ "astro": "5.4.0",
54
52
  "astro-scripts": "0.0.14"
55
53
  },
56
54
  "publishConfig": {
57
55
  "provenance": true
58
56
  },
59
57
  "scripts": {
60
- "build": "tsc",
58
+ "build": "astro-scripts build \"src/**/*.ts\" && tsc",
61
59
  "test": "astro-scripts test \"test/**/*.test.js\""
62
60
  }
63
61
  }