forked from vercel-labs/workflow-builder-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathnext.config.ts
More file actions
352 lines (341 loc) · 12.2 KB
/
next.config.ts
File metadata and controls
352 lines (341 loc) · 12.2 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
import { withSentryConfig } from "@sentry/nextjs";
import type { NextConfig } from "next";
import { withWorkflow } from "workflow/next";
const nextConfig = {
output: "standalone",
// Admin test routes (app/api/admin/test/**/route.staging.ts) are excluded
// from the prod bundle by omitting "staging.ts" from pageExtensions. See
// KEEP-237. Staging/PR builds set INCLUDE_TEST_ENDPOINTS=true via the build
// workflow to compile them in.
// "js"/"jsx" must remain so that the workflow runtime routes generated by
// withWorkflow at app/.well-known/workflow/v1/{flow,step,webhook}/route.js
// are picked up by the Next.js router; without them the in-pod graphile
// worker POSTs return Next's HTML 404 and every workflow run fails.
pageExtensions:
process.env.INCLUDE_TEST_ENDPOINTS === "true"
? ["ts", "tsx", "js", "jsx", "staging.ts", "staging.tsx"]
: ["ts", "tsx", "js", "jsx"],
// Bake INCLUDE_TEST_ENDPOINTS so lib/admin-auth.ts and lib/auth.ts can
// gate runtime behavior (admin routes, rate-limit bypass) on the build-
// time flag. The bundler (Turbopack / webpack) replaces
// `process.env.INCLUDE_TEST_ENDPOINTS` with the literal captured here, so
// runtime env cannot override the baked value.
//
// NOTE: `env` config inlines into BOTH server and client bundles. The
// value ("true" or "") is a non-sensitive feature flag, so this is fine.
// Never put secrets in this block.
//
// See KEEP-237.
env: {
INCLUDE_TEST_ENDPOINTS: process.env.INCLUDE_TEST_ENDPOINTS ?? "",
},
// The SDK loads @workflow/world-postgres via dynamic
// require(process.env.WORKFLOW_TARGET_WORLD) which the standalone output
// tracer cannot follow. serverExternalPackages keeps it out of the bundle
// and outputFileTracingIncludes forces it into the standalone node_modules.
// .npmrc public-hoist-pattern hoists these from .pnpm/ to top-level
// node_modules/ so the simple globs below can find them.
// Full transitive dependency tree of @workflow/world-postgres.
// Generated by: tsx scripts/list-world-deps.ts
serverExternalPackages: [
"@babel/code-frame",
"@babel/helper-validator-identifier",
"@cbor-extract/cbor-extract-darwin-arm64",
"@cbor-extract/cbor-extract-darwin-x64",
"@cbor-extract/cbor-extract-linux-arm",
"@cbor-extract/cbor-extract-linux-arm64",
"@cbor-extract/cbor-extract-linux-x64",
"@cbor-extract/cbor-extract-win32-x64",
"@graphile/logger",
"@types/debug",
"@types/interpret",
"@types/ms",
"@types/node",
"@types/pg",
"@types/semver",
"@vercel/oidc",
"@vercel/queue",
"@workflow/errors",
"@workflow/utils",
"@workflow/world",
"@workflow/world-local",
"@workflow/world-postgres",
"ansi-regex",
"ansi-styles",
"argparse",
"async-sema",
"balanced-match",
"brace-expansion",
"callsites",
"cbor-extract",
"cbor-x",
"chalk",
"cliui",
"color-convert",
"color-name",
"cosmiconfig",
"cron-parser",
"debug",
"detect-libc",
"dotenv",
"drizzle-orm",
"emoji-regex",
"error-ex",
"escalade",
"get-caller-file",
"graphile-config",
"graphile-worker",
"has-flag",
"import-fresh",
"interpret",
"is-arrayish",
"is-fullwidth-code-point",
"js-tokens",
"js-yaml",
"json-parse-even-better-errors",
"json5",
"lines-and-columns",
"minimatch",
"mixpart",
"ms",
"node-gyp-build-optional-packages",
"parent-module",
"parse-json",
"path-type",
"pg",
"pg-cloudflare",
"pg-connection-string",
"pg-int8",
"pg-pool",
"pg-protocol",
"pg-types",
"pgpass",
"picocolors",
"postgres",
"postgres-array",
"postgres-bytea",
"postgres-date",
"postgres-interval",
"require-directory",
"resolve-from",
"semver",
"split2",
"string-width",
"strip-ansi",
"supports-color",
"tslib",
"ulid",
"undici",
"undici-types",
"wrap-ansi",
"xtend",
"y18n",
"yargs",
"yargs-parser",
"zod",
],
outputFileTracingIncludes: {
"/*": [
// Force-include the next package itself. The standalone server.js
// emitted by `output: "standalone"` does a bare `require('next')`,
// which needs next/package.json to resolve. Next's tracer only
// catches that bare specifier when some other file in the bundle
// also imports next directly. In prod builds INCLUDE_TEST_ENDPOINTS
// is empty, the staging-only `*.staging.ts` files that triggered
// the side-effect are excluded, and the standalone output ends up
// with next/dist/ but no next/package.json -- runtime crashes with
// "Cannot find module 'next'" on server.js line 16. Including next
// explicitly here makes the bundle robust regardless of which other
// pageExtensions are active. See KEEP-348 follow-up incident.
"./node_modules/next/**/*",
// Next 16's standalone tracer doesn't follow next's own runtime
// dependencies through pnpm's .pnpm/ store. Force-include the full
// set listed in next/package.json `dependencies` plus the
// architecture-specific @next/swc binary used on Alpine (musl).
"./node_modules/@next/env/**/*",
"./node_modules/@next/swc-linux-x64-musl/**/*",
"./node_modules/@swc/helpers/**/*",
"./node_modules/baseline-browser-mapping/**/*",
"./node_modules/caniuse-lite/**/*",
"./node_modules/postcss/**/*",
"./node_modules/styled-jsx/**/*",
"./node_modules/@babel/code-frame/**/*",
"./node_modules/@babel/helper-validator-identifier/**/*",
"./node_modules/@cbor-extract/cbor-extract-darwin-arm64/**/*",
"./node_modules/@cbor-extract/cbor-extract-darwin-x64/**/*",
"./node_modules/@cbor-extract/cbor-extract-linux-arm/**/*",
"./node_modules/@cbor-extract/cbor-extract-linux-arm64/**/*",
"./node_modules/@cbor-extract/cbor-extract-linux-x64/**/*",
"./node_modules/@cbor-extract/cbor-extract-win32-x64/**/*",
"./node_modules/@graphile/logger/**/*",
"./node_modules/@types/debug/**/*",
"./node_modules/@types/interpret/**/*",
"./node_modules/@types/ms/**/*",
"./node_modules/@types/node/**/*",
"./node_modules/@types/pg/**/*",
"./node_modules/@types/semver/**/*",
"./node_modules/@vercel/oidc/**/*",
"./node_modules/@vercel/queue/**/*",
"./node_modules/@workflow/errors/**/*",
"./node_modules/@workflow/utils/**/*",
"./node_modules/@workflow/world/**/*",
"./node_modules/@workflow/world-local/**/*",
"./node_modules/@workflow/world-postgres/**/*",
"./node_modules/ansi-regex/**/*",
"./node_modules/ansi-styles/**/*",
"./node_modules/argparse/**/*",
"./node_modules/async-sema/**/*",
"./node_modules/balanced-match/**/*",
"./node_modules/brace-expansion/**/*",
"./node_modules/callsites/**/*",
"./node_modules/cbor-extract/**/*",
"./node_modules/cbor-x/**/*",
"./node_modules/chalk/**/*",
"./node_modules/cliui/**/*",
"./node_modules/color-convert/**/*",
"./node_modules/color-name/**/*",
"./node_modules/cosmiconfig/**/*",
"./node_modules/cron-parser/**/*",
"./node_modules/debug/**/*",
"./node_modules/detect-libc/**/*",
"./node_modules/dotenv/**/*",
"./node_modules/drizzle-orm/**/*",
"./node_modules/emoji-regex/**/*",
"./node_modules/error-ex/**/*",
"./node_modules/escalade/**/*",
"./node_modules/get-caller-file/**/*",
"./node_modules/graphile-config/**/*",
"./node_modules/graphile-worker/**/*",
"./node_modules/has-flag/**/*",
"./node_modules/import-fresh/**/*",
"./node_modules/interpret/**/*",
"./node_modules/is-arrayish/**/*",
"./node_modules/is-fullwidth-code-point/**/*",
"./node_modules/js-tokens/**/*",
"./node_modules/js-yaml/**/*",
"./node_modules/json-parse-even-better-errors/**/*",
"./node_modules/json5/**/*",
"./node_modules/lines-and-columns/**/*",
"./node_modules/minimatch/**/*",
"./node_modules/mixpart/**/*",
"./node_modules/ms/**/*",
"./node_modules/node-gyp-build-optional-packages/**/*",
"./node_modules/parent-module/**/*",
"./node_modules/parse-json/**/*",
"./node_modules/path-type/**/*",
"./node_modules/pg/**/*",
"./node_modules/pg-cloudflare/**/*",
"./node_modules/pg-connection-string/**/*",
"./node_modules/pg-int8/**/*",
"./node_modules/pg-pool/**/*",
"./node_modules/pg-protocol/**/*",
"./node_modules/pg-types/**/*",
"./node_modules/pgpass/**/*",
"./node_modules/picocolors/**/*",
"./node_modules/postgres/**/*",
"./node_modules/postgres-array/**/*",
"./node_modules/postgres-bytea/**/*",
"./node_modules/postgres-date/**/*",
"./node_modules/postgres-interval/**/*",
"./node_modules/require-directory/**/*",
"./node_modules/resolve-from/**/*",
"./node_modules/semver/**/*",
"./node_modules/split2/**/*",
"./node_modules/string-width/**/*",
"./node_modules/strip-ansi/**/*",
"./node_modules/supports-color/**/*",
"./node_modules/tslib/**/*",
"./node_modules/ulid/**/*",
"./node_modules/undici/**/*",
"./node_modules/undici-types/**/*",
"./node_modules/wrap-ansi/**/*",
"./node_modules/xtend/**/*",
"./node_modules/y18n/**/*",
"./node_modules/yargs/**/*",
"./node_modules/yargs-parser/**/*",
"./node_modules/zod/**/*",
"./node_modules/next/dist/compiled/@vercel/og/**/*",
],
},
logging: {
fetches: {
fullUrl: true,
},
},
eslint: {
ignoreDuringBuilds: true,
},
images: {
remotePatterns: [
{
protocol: "https",
hostname: "raw.githubusercontent.com",
pathname: "/trustwallet/assets/**",
},
],
},
async rewrites() {
return [{ source: "/openapi.json", destination: "/api/openapi" }];
},
async headers() {
return [
{
source: "/:path*",
headers: [
{ key: "X-Frame-Options", value: "DENY" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{
key: "Strict-Transport-Security",
value: "max-age=63072000; includeSubDomains",
},
],
},
];
},
async redirects() {
return [
{
source: "/llms.txt",
destination: "https://docs.keeperhub.com/llms.txt",
permanent: true,
},
];
},
} satisfies NextConfig & { eslint?: { ignoreDuringBuilds?: boolean } };
const { SENTRY_ORG, SENTRY_PROJECT, SENTRY_RELEASE } = process.env;
export default withSentryConfig(withWorkflow(nextConfig), {
// For all available options, see:
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
org: SENTRY_ORG,
project: SENTRY_PROJECT,
release: SENTRY_RELEASE ? { name: SENTRY_RELEASE } : undefined,
// Only print logs for uploading source maps in CI
silent: !process.env.CI,
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
// No-op: source map upload moved to sentry-upload Docker stage (KEEP-280).
// Kept for safety in case SENTRY_AUTH_TOKEN is ever set during build.
sourcemaps: {
deleteSourcemapsAfterUpload: true,
},
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
tunnelRoute: "/monitoring",
webpack: {
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
// See the following for more information:
// https://docs.sentry.io/product/crons/
// https://vercel.com/docs/cron-jobs
automaticVercelMonitors: true,
// Tree-shaking options for reducing bundle size
treeshake: {
// Automatically tree-shake Sentry logger statements to reduce bundle size
removeDebugLogging: true,
},
},
});