@astrojs/cloudflare 10.2.1 → 10.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.
package/dist/index.js CHANGED
@@ -274,8 +274,13 @@ export default function createIntegration(args) {
274
274
  // Those modules are build only for prerendering routes.
275
275
  const chunksToDelete = chunkAnalyzer.getNonServerChunks();
276
276
  for (const chunk of chunksToDelete) {
277
- // Chunks are located on `./_worker.js` directory inside of the output directory
278
- await unlink(new URL(`./_worker.js/${chunk}`, _config.outDir));
277
+ try {
278
+ // Chunks are located on `./_worker.js` directory inside of the output directory
279
+ await unlink(new URL(`./_worker.js/${chunk}`, _config.outDir));
280
+ }
281
+ catch (error) {
282
+ logger.warn(`Issue while trying to delete unused file from server bundle: ${new URL(`./_worker.js/${chunk}`, _config.outDir).toString()}`);
283
+ }
279
284
  }
280
285
  },
281
286
  },
@@ -14,11 +14,17 @@ export function mutatePageMapInPlace(node, constsToRemove, s) {
14
14
  if (!arrayExpression.elements[1] || arrayExpression.elements[1].type !== 'Identifier')
15
15
  continue;
16
16
  if (constsToRemove.includes(arrayExpression.elements[1].name)) {
17
- console.log(arrayExpression);
18
17
  // @ts-expect-error - @types/estree seem to be wrong
19
18
  if (arrayExpression.start && arrayExpression.end) {
20
19
  // @ts-expect-error - @types/estree seem to be wrong
21
20
  s.remove(arrayExpression.start, arrayExpression.end);
21
+ // We need to check if there are any leftover commas, which are not part of the `ArrayExpression` node
22
+ // @ts-expect-error - @types/estree seem to be wrong
23
+ const endChar = s.slice(arrayExpression.end, arrayExpression.end + 1);
24
+ if (endChar.includes(',')) {
25
+ // @ts-expect-error - @types/estree seem to be wrong
26
+ s.remove(arrayExpression.end, arrayExpression.end + 1);
27
+ }
22
28
  }
23
29
  }
24
30
  }
@@ -11,6 +11,9 @@ export class NonServerChunkDetector {
11
11
  return {
12
12
  name: 'non-server-chunk-detector',
13
13
  generateBundle: (_, bundle) => {
14
+ // Skip if we bundle for client
15
+ if (!bundle['index.js'])
16
+ return;
14
17
  this.processBundle(bundle);
15
18
  },
16
19
  };
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": "10.2.1",
4
+ "version": "10.2.3",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -49,8 +49,8 @@
49
49
  "rollup": "^4.14.0",
50
50
  "strip-ansi": "^7.1.0",
51
51
  "vite": "^5.2.6",
52
- "@astrojs/test-utils": "0.0.1",
53
- "astro-scripts": "0.0.14"
52
+ "astro-scripts": "0.0.14",
53
+ "@astrojs/test-utils": "0.0.1"
54
54
  },
55
55
  "publishConfig": {
56
56
  "provenance": true