Skip to content

Commit 58a36d8

Browse files
authored
[aws]: add outputFileTracingIncludes to common issues (#116)
1 parent e133dbb commit 58a36d8

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

pages/aws/common_issues.mdx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,59 @@ This error is usually resolved by removing all yarn files in your repo. You shou
112112
If you use `yarn` there is a workaround [here](https://stackoverflow.com/a/76902985).
113113

114114
If you are not using `yarn` and you see `yarn` related errors it might be solved by running `corepack disable` or updating `nvm` to `0.40.2`.
115+
116+
#### A file/dependency is missing from my bundle
117+
118+
Sometimes there might be a file missing from your server functions bundle. An example could be `sentry.server.config.ts`. It can be any file or directory and it also accept globs. In Next there is an option to include files that were not picked up by tracing.
119+
Its called `outputFileTracingIncludes`. Here is an example on how to use it in `next.config.ts`:
120+
121+
```ts
122+
import type { NextConfig } from "next";
123+
124+
const nextConfig: NextConfig = {
125+
/* config options here */
126+
outputFileTracingIncludes: {
127+
"*": ["sentry.server.config.ts"],
128+
// can also be a glob pattern
129+
"/api/*": ["node_modules/.prisma/client/**/*"],
130+
},
131+
};
132+
133+
export default nextConfig;
134+
```
135+
136+
This will copy the file to `.open-next/server-functions/default/sentry.server.config.ts`, or every splitted function in this case.
137+
To read more about `outputFileTracingIncludes` you can refer to the [Next.js documentation](https://nextjs.org/docs/pages/api-reference/config/next-config-js/output#caveats).
138+
139+
It works with function splitting in OpenNext aswell. If your key corresponds to a specific route (i.e: `api/test`), it will be included only in the function bundle for that route.
140+
Using `*` as a key, however, will include it in every function bundle. Here is an example with function splitting:
141+
142+
```ts
143+
// open-next.config.ts
144+
import type { OpenNextConfig } from "@opennextjs/aws/types/open-next";
145+
const config = {
146+
default: {},
147+
functions: {
148+
extraFunction: {
149+
patterns: ["api/test"],
150+
// this is the route that will be used in this function
151+
routes: ["app/api/test/route"],
152+
override: {
153+
wrapper: "aws-lambda-streaming",
154+
},
155+
},
156+
},
157+
} satisfies OpenNextConfig;
158+
159+
// next.config.ts
160+
import type { NextConfig } from "next";
161+
162+
const nextConfig: NextConfig = {
163+
outputFileTracingIncludes: {
164+
// these files will be copied only to the extraFunction bundle
165+
"/api/test": ["sentry.config.ts", "node_modules/.prisma/client/**/*"],
166+
},
167+
};
168+
```
169+
170+
It will also work in a monorepo. Lets say you have your Next app in `packages/web`, the files will be written to: `packages/web/.open-next/server-functions/default/packages/web/*`

0 commit comments

Comments
 (0)