@opennextjs/cloudflare 0.3.7 → 0.3.8

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.
@@ -4,6 +4,7 @@ import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { build } from "esbuild";
6
6
  import * as patches from "./patches/index.js";
7
+ import { normalizePath } from "./utils/index.js";
7
8
  /** The dist directory of the Cloudflare adapter package */
8
9
  const packageDistDir = path.join(path.dirname(fileURLToPath(import.meta.url)), "../..");
9
10
  /**
@@ -103,8 +104,7 @@ globalThis.__BUILD_TIMESTAMP_MS__ = ${Date.now()};
103
104
  await updateWorkerBundledCode(openNextServerBundle, config, openNextOptions);
104
105
  const isMonorepo = monorepoRoot !== appPath;
105
106
  if (isMonorepo) {
106
- const packagePosixPath = packagePath.split(path.sep).join(path.posix.sep);
107
- fs.writeFileSync(path.join(outputPath, "handler.mjs"), `export * from "./${packagePosixPath}/handler.mjs";`);
107
+ fs.writeFileSync(path.join(outputPath, "handler.mjs"), `export * from "./${normalizePath(packagePath)}/handler.mjs";`);
108
108
  }
109
109
  console.log(`\x1b[35mWorker saved in \`${getOutputWorkerPath(openNextOptions)}\` 🚀\n\x1b[0m`);
110
110
  }
@@ -156,7 +156,7 @@ function createFixRequiresESBuildPlugin(config) {
156
156
  name: "replaceRelative",
157
157
  setup(build) {
158
158
  // Note: we (empty) shim require-hook modules as they generate problematic code that uses requires
159
- build.onResolve({ filter: /^\.\/require-hook$/ }, () => ({
159
+ build.onResolve({ filter: /^\.(\/|\\)require-hook$/ }, () => ({
160
160
  path: path.join(config.paths.internal.templates, "shims", "empty.js"),
161
161
  }));
162
162
  },
@@ -13,6 +13,7 @@ import { minifyAll } from "@opennextjs/aws/minimize-js.js";
13
13
  import { openNextEdgePlugins } from "@opennextjs/aws/plugins/edge.js";
14
14
  import { openNextReplacementPlugin } from "@opennextjs/aws/plugins/replacement.js";
15
15
  import { openNextResolvePlugin } from "@opennextjs/aws/plugins/resolve.js";
16
+ import { normalizePath } from "../utils/index.js";
16
17
  export async function createServerBundle(options) {
17
18
  const { config } = options;
18
19
  const foundRoutes = new Set();
@@ -147,7 +148,7 @@ async function generateBundle(name, options, fnOptions) {
147
148
  outfile: path.join(outputPath, packagePath, `index.${outfileExt}`),
148
149
  banner: {
149
150
  js: [
150
- `globalThis.monorepoPackagePath = "${packagePath}";`,
151
+ `globalThis.monorepoPackagePath = "${normalizePath(packagePath)}";`,
151
152
  name === "default" ? "" : `globalThis.fnName = "${name}";`,
152
153
  ].join(""),
153
154
  },
@@ -201,10 +202,7 @@ function addMonorepoEntrypoint(outputPath, packagePath) {
201
202
  // the Lambda function to be able to find the handler at
202
203
  // the root of the bundle. We will create a dummy `index.mjs`
203
204
  // that re-exports the real handler.
204
- // TOOD: use helper
205
- // Always use posix path for import path
206
- const packagePosixPath = packagePath.split(path.sep).join(path.posix.sep);
207
- fs.writeFileSync(path.join(outputPath, "index.mjs"), `export * from "./${packagePosixPath}/index.mjs";`);
205
+ fs.writeFileSync(path.join(outputPath, "index.mjs"), `export * from "./${normalizePath(packagePath)}/index.mjs";`);
208
206
  }
209
207
  async function minifyServerBundle(outputDir) {
210
208
  logger.info("Minimizing server function...");
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+ import { normalizePath } from "../../utils/index.js";
2
3
  /**
3
4
  * Sets up the OpenNext cache handler in a Next.js build.
4
5
  *
@@ -17,6 +18,6 @@ export async function patchCache(code, openNextOptions) {
17
18
  const packagePath = path.relative(monorepoRoot, appBuildOutputPath);
18
19
  const cacheFile = path.join(outputPath, packagePath, "cache.cjs");
19
20
  return code.replace("const { cacheHandler } = this.nextConfig;", `const cacheHandler = null;
20
- CacheHandler = require('${cacheFile}').default;
21
+ CacheHandler = require('${normalizePath(cacheFile)}').default;
21
22
  `);
22
23
  }
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": "0.3.7",
4
+ "version": "0.3.8",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "opennextjs-cloudflare": "dist/cli/index.js"
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "dependencies": {
64
64
  "@dotenvx/dotenvx": "1.31.0",
65
- "@opennextjs/aws": "https://pkg.pr.new/@opennextjs/aws@688",
65
+ "@opennextjs/aws": "https://pkg.pr.new/@opennextjs/aws@695",
66
66
  "glob": "^11.0.0",
67
67
  "ts-morph": "^23.0.0",
68
68
  "enquirer": "^2.4.1"