-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopen-next.config.ts
More file actions
executable file
·38 lines (33 loc) · 1.68 KB
/
Copy pathopen-next.config.ts
File metadata and controls
executable file
·38 lines (33 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// OpenNext for Cloudflare — wraps the Next.js build so it runs on Cloudflare's
// Workers runtime. Produces a .open-next/ directory with worker.js + assets.
//
// Docs: https://opennext.js.org/cloudflare
import { defineCloudflareConfig } from '@opennextjs/cloudflare';
const config = defineCloudflareConfig({});
// Explicitly set the build command to `next build` (not `npm run build`).
// This prevents infinite recursion when the `build` npm script is set to
// `opennextjs-cloudflare build` — without this, OpenNext would call
// `npm run build` → `opennextjs-cloudflare build` → `npm run build` → forever.
(config as Record<string, unknown>).buildCommand = 'next build';
// Externalize heavy packages so they're not bundled into the Worker.
// The Cloudflare Workers free plan has a 3 MiB size limit — without
// these externals, the Worker bundle is ~19 MiB (mostly @stellar/stellar-sdk
// and wallet SDKs). These packages are lazy-imported at runtime via
// dynamic import(), so they don't need to be in the initial bundle.
//
// Note: defineCloudflareConfig() already sets edgeExternals: ["node:crypto"].
// We merge our extras in rather than replacing the array — otherwise
// ensureCloudflareConfig() fails validation because node:crypto is missing.
const existingExternals = (config as Record<string, unknown>).edgeExternals as string[] ?? [];
(config as Record<string, unknown>).edgeExternals = [
...existingExternals,
'@stellar/stellar-sdk',
'@stellar/freighter-api',
'@albedo-link/intent',
'@creit.tech/xbull-wallet-connect',
'@ledgerhq/hw-app-str',
'@ledgerhq/hw-transport-webhid',
'@ledgerhq/hw-transport-webusb',
'@walletconnect/sign-client',
];
export default config;