@opennextjs/cloudflare 1.8.4 → 1.8.5

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.
@@ -13,7 +13,7 @@ import { inlineFindDir } from "./patches/plugins/find-dir.js";
13
13
  import { patchInstrumentation } from "./patches/plugins/instrumentation.js";
14
14
  import { inlineLoadManifest } from "./patches/plugins/load-manifest.js";
15
15
  import { patchNextServer } from "./patches/plugins/next-server.js";
16
- import { patchResolveCache } from "./patches/plugins/open-next.js";
16
+ import { patchResolveCache, patchSetWorkingDirectory } from "./patches/plugins/open-next.js";
17
17
  import { handleOptionalDependencies } from "./patches/plugins/optional-deps.js";
18
18
  import { patchPagesRouterContext } from "./patches/plugins/pages-router-context.js";
19
19
  import { patchDepdDeprecations } from "./patches/plugins/patch-depd-deprecations.js";
@@ -90,6 +90,7 @@ export async function bundleServer(buildOpts, projectOpts) {
90
90
  patchRouteModules(updater, buildOpts),
91
91
  patchDepdDeprecations(updater),
92
92
  patchResolveCache(updater, buildOpts),
93
+ patchSetWorkingDirectory(updater, buildOpts),
93
94
  // Apply updater updates, must be the last plugin
94
95
  updater.plugin,
95
96
  ],
@@ -6,3 +6,5 @@ import type { ContentUpdater, Plugin } from "@opennextjs/aws/plugins/content-upd
6
6
  export declare function patchResolveCache(updater: ContentUpdater, buildOpts: BuildOptions): Plugin;
7
7
  export declare const cacheHandlerRule = "\nrule:\n pattern: var cacheHandlerPath = __require.resolve(\"./cache.cjs\");\nfix: |-\n var cacheHandlerPath = \"\";\n";
8
8
  export declare const compositeCacheHandlerRule = "\nrule:\n pattern: var composableCacheHandlerPath = __require.resolve(\"./composable-cache.cjs\");\nfix: |-\n var composableCacheHandlerPath = \"\";\n";
9
+ export declare function patchSetWorkingDirectory(updater: ContentUpdater, buildOpts: BuildOptions): Plugin;
10
+ export declare const workingDirectoryRule = "\nrule:\n pattern: function setNextjsServerWorkingDirectory() { $$$BODY }\nfix: |-\n function setNextjsServerWorkingDirectory() {\n }\n";
@@ -34,3 +34,25 @@ rule:
34
34
  fix: |-
35
35
  var composableCacheHandlerPath = "";
36
36
  `;
37
+ export function patchSetWorkingDirectory(updater, buildOpts) {
38
+ const { outputDir } = buildOpts;
39
+ const packagePath = getPackagePath(buildOpts);
40
+ const outputPath = path.join(outputDir, "server-functions/default");
41
+ const indexPath = path.relative(buildOpts.appBuildOutputPath, path.join(outputPath, packagePath, `index.mjs`));
42
+ return updater.updateContent("do-not-set-working-directory", [
43
+ {
44
+ filter: getCrossPlatformPathRegex(indexPath),
45
+ contentFilter: /function setNextjsServerWorkingDirectory\(/,
46
+ callback: async ({ contents }) => patchCode(contents, workingDirectoryRule),
47
+ },
48
+ ]);
49
+ }
50
+ // `setNextjsServerWorkingDirectory` calls `process.chdir("")` which errors because the directory does not exists
51
+ // See https://github.com/opennextjs/opennextjs-cloudflare/issues/899
52
+ export const workingDirectoryRule = `
53
+ rule:
54
+ pattern: function setNextjsServerWorkingDirectory() { $$$BODY }
55
+ fix: |-
56
+ function setNextjsServerWorkingDirectory() {
57
+ }
58
+ `;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@opennextjs/cloudflare",
3
3
  "description": "Cloudflare builder for next apps",
4
- "version": "1.8.4",
4
+ "version": "1.8.5",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "opennextjs-cloudflare": "dist/cli/index.js"
@@ -74,7 +74,7 @@
74
74
  "vitest": "^2.1.1"
75
75
  },
76
76
  "peerDependencies": {
77
- "wrangler": "^4.24.4"
77
+ "wrangler": "^4.38.0"
78
78
  },
79
79
  "scripts": {
80
80
  "clean": "rimraf dist",