Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/esbuild-dependency-82f9a43d.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@opennextjs/cloudflare": patch
---

fix: declare esbuild as runtime dependency

esbuild is imported at build time by the Cloudflare adapter but was only in devDependencies, so consumers relied on hoisting from @opennextjs/aws. Add it to dependencies so builds work under npm ci and with hoist conflicts.
2 changes: 1 addition & 1 deletion packages/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"cloudflare": "^4.4.1",
"comment-json": "^4.5.1",
"enquirer": "^2.4.1",
"esbuild": "catalog:",
"glob": "catalog:",
"ts-tqdm": "^0.8.6",
"yargs": "catalog:"
Expand All @@ -73,7 +74,6 @@
"@types/rclone.js": "^0.6.1",
"@types/yargs": "catalog:",
"diff": "^8.0.2",
"esbuild": "catalog:",
"eslint": "catalog:",
"eslint-plugin-import": "catalog:",
"eslint-plugin-simple-import-sort": "catalog:",
Expand Down
26 changes: 26 additions & 0 deletions packages/cloudflare/src/cli/build/build-deps.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";

import { describe, expect, it } from "vitest";

/**
* Regression test for https://github.com/opennextjs/opennextjs-cloudflare/issues/1339
*
* `esbuild` is imported at build time (see src/cli/build/bundle-server.ts and
* src/cli/build/open-next/*.ts) but used to be declared only in devDependencies,
* so consumers only got it by npm hoisting accident. It must be a real runtime
* `dependency` of the published package.
*/
const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), "../../../package.json");

describe("build-time dependencies", () => {
it("declares esbuild as a runtime dependency", () => {
const { dependencies } = JSON.parse(readFileSync(packageJsonPath, "utf8")) as {
dependencies?: Record<string, string>;
};

expect(dependencies).toBeDefined();
expect(dependencies?.["esbuild"]).toBeDefined();
});
});