@opennextjs/cloudflare 0.5.0 → 0.5.1

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.
@@ -39,10 +39,9 @@ export async function createServerBundle(options) {
39
39
  // We build every other function than default before so we know which route there is left
40
40
  await Promise.all(promises);
41
41
  const remainingRoutes = new Set();
42
- const { appBuildOutputPath, monorepoRoot } = options;
43
- const packagePath = path.relative(monorepoRoot, appBuildOutputPath);
42
+ const { appBuildOutputPath } = options;
44
43
  // Find remaining routes
45
- const serverPath = path.join(appBuildOutputPath, ".next", "standalone", packagePath, ".next", "server");
44
+ const serverPath = path.join(appBuildOutputPath, ".next/standalone", buildHelper.getPackagePath(options), ".next/server");
46
45
  // Find app dir routes
47
46
  if (fs.existsSync(path.join(serverPath, "app"))) {
48
47
  const appPath = path.join(serverPath, "app");
@@ -81,7 +80,7 @@ async function generateBundle(name, options, fnOptions) {
81
80
  // `node_modules` inside `.next/standalone`, and others inside
82
81
  // `.next/standalone/package/path` (ie. `.next`, `server.js`).
83
82
  // We need to output the handler file inside the package path.
84
- const packagePath = path.relative(monorepoRoot, appBuildOutputPath);
83
+ const packagePath = buildHelper.getPackagePath(options);
85
84
  fs.mkdirSync(path.join(outputPath, packagePath), { recursive: true });
86
85
  const ext = fnOptions.runtime === "deno" ? "mjs" : "cjs";
87
86
  fs.copyFileSync(path.join(options.buildDir, `cache.${ext}`), path.join(outputPath, packagePath, "cache.cjs"));
@@ -113,7 +112,7 @@ async function generateBundle(name, options, fnOptions) {
113
112
  buildHelper.compareSemver(options.nextVersion, "13.4.1") <= 0;
114
113
  const overrides = fnOptions.override ?? {};
115
114
  const isBefore13413 = buildHelper.compareSemver(options.nextVersion, "13.4.13") <= 0;
116
- const isAfter141 = buildHelper.compareSemver(options.nextVersion, "14.0.4") >= 0;
115
+ const isAfter141 = buildHelper.compareSemver(options.nextVersion, "14.1") >= 0;
117
116
  const disableRouting = isBefore13413 || config.middleware?.external;
118
117
  const plugins = [
119
118
  openNextReplacementPlugin({
@@ -11,13 +11,14 @@ import { patchVercelOgFallbackFont, patchVercelOgImport } from "./vercel-og.js";
11
11
  */
12
12
  export function patchVercelOgLibrary(buildOpts) {
13
13
  const { appBuildOutputPath, outputDir } = buildOpts;
14
- const packagePath = path.join(outputDir, "server-functions/default", getPackagePath(buildOpts));
14
+ const functionsPath = path.join(outputDir, "server-functions/default");
15
+ const packagePath = path.join(functionsPath, getPackagePath(buildOpts));
15
16
  for (const traceInfoPath of globSync(path.join(appBuildOutputPath, ".next/server/**/*.nft.json"))) {
16
17
  const traceInfo = JSON.parse(readFileSync(traceInfoPath, { encoding: "utf8" }));
17
18
  const tracedNodePath = traceInfo.files.find((p) => p.endsWith("@vercel/og/index.node.js"));
18
19
  if (!tracedNodePath)
19
20
  continue;
20
- const outputDir = path.join(packagePath, "node_modules/next/dist/compiled/@vercel/og");
21
+ const outputDir = getOutputDir({ functionsPath, packagePath });
21
22
  const outputEdgePath = path.join(outputDir, "index.edge.js");
22
23
  // Ensure the edge version is available in the OpenNext node_modules.
23
24
  if (!existsSync(outputEdgePath)) {
@@ -37,3 +38,11 @@ export function patchVercelOgLibrary(buildOpts) {
37
38
  writeFileSync(routeFilePath, node.commitEdits(edits));
38
39
  }
39
40
  }
41
+ function getOutputDir(opts) {
42
+ const vercelOgNodeModulePath = "node_modules/next/dist/compiled/@vercel/og";
43
+ const packageOutputPath = path.join(opts.packagePath, vercelOgNodeModulePath);
44
+ if (existsSync(packageOutputPath)) {
45
+ return packageOutputPath;
46
+ }
47
+ return path.join(opts.functionsPath, vercelOgNodeModulePath);
48
+ }
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.5.0",
4
+ "version": "0.5.1",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "opennextjs-cloudflare": "dist/cli/index.js"