You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These configs have been being validated for quite a while now and they
are pretty crucial to handle edge-cases without our output tracing setup
since we can't always trace 100% of cases. No functional changes are
made here expect removal of long deprecated
`experimental.outputFileTracingIgnores` and upgrading from experimental
for `outputFileTracingRoot`, `outputFileTracingIncludes`, and
`outputFileTracingExcludes`.
Closes: NDX-166
Copy file name to clipboardExpand all lines: docs/02-app/02-api-reference/05-next-config-js/output.mdx
+16-33Lines changed: 16 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,6 @@ Additionally, a minimal `server.js` file is also output which can be used instea
40
40
> **Good to know**:
41
41
>
42
42
> - If your project needs to listen to a specific port or hostname, you can define `PORT` or `HOSTNAME` environment variables before running `server.js`. For example, run `PORT=8080 HOSTNAME=0.0.0.0 node server.js` to start the server on `http://0.0.0.0:8080`.
43
-
> - If your project uses [Image Optimization](/docs/app/building-your-application/optimizing/images) with the default `loader`, you must install `sharp` as a dependency:
44
43
45
44
</AppOnly>
46
45
@@ -50,54 +49,38 @@ Additionally, a minimal `server.js` file is also output which can be used instea
50
49
>
51
50
> -`next.config.js` is read during `next build` and serialized into the `server.js` output file. If the legacy [`serverRuntimeConfig` or `publicRuntimeConfig` options](/docs/pages/api-reference/next-config-js/runtime-configuration) are being used, the values will be specific to values at build time.
52
51
> - If your project needs to listen to a specific port or hostname, you can define `PORT` or `HOSTNAME` environment variables before running `server.js`. For example, run `PORT=8080 HOSTNAME=0.0.0.0 node server.js` to start the server on `http://0.0.0.0:8080`.
53
-
> - If your project uses [Image Optimization](/docs/pages/building-your-application/optimizing/images) with the default `loader`, you must install `sharp` as a dependency:
54
52
55
53
</PagesOnly>
56
54
57
-
```bash filename="Terminal"
58
-
npm i sharp
59
-
```
60
-
61
-
```bash filename="Terminal"
62
-
yarn add sharp
63
-
```
64
-
65
-
```bash filename="Terminal"
66
-
pnpm add sharp
67
-
```
68
-
69
-
```bash filename="Terminal"
70
-
bun add sharp
71
-
```
72
-
73
55
## Caveats
74
56
75
-
- While tracing in monorepo setups, the project directory is used for tracing by default. For `next build packages/web-app`, `packages/web-app` would be the tracing root and any files outside of that folder will not be included. To include files outside of this folder you can set `experimental.outputFileTracingRoot` in your `next.config.js`.
57
+
- While tracing in monorepo setups, the project directory is used for tracing by default. For `next build packages/web-app`, `packages/web-app` would be the tracing root and any files outside of that folder will not be included. To include files outside of this folder you can set `outputFileTracingRoot` in your `next.config.js`.
76
58
77
59
```js filename="packages/web-app/next.config.js"
78
60
module.exports= {
79
-
experimental: {
80
-
// this includes files from the monorepo base two directories up
- There are some cases in which Next.js might fail to include required files, or might incorrectly include unused files. In those cases, you can leverage `experimental.outputFileTracingExcludes` and `experimental.outputFileTracingIncludes` respectively in `next.config.js`. Each config accepts an object with [minimatch globs](https://www.npmjs.com/package/minimatch) for the key to match specific pages and a value of an array with globs relative to the project's root to either include or exclude in the trace.
66
+
- There are some cases in which Next.js might fail to include required files, or might incorrectly include unused files. In those cases, you can leverage `outputFileTracingExcludes` and `outputFileTracingIncludes` respectively in `next.config.js`. Each config accepts an object with [minimatch globs](https://www.npmjs.com/package/minimatch) for the key to match specific pages and a value of an array with globs relative to the project's root to either include or exclude in the trace.
87
67
88
68
```js filename="next.config.js"
89
69
module.exports= {
90
-
experimental: {
91
-
outputFileTracingExcludes: {
92
-
'/api/hello': ['./un-necessary-folder/**/*'],
93
-
},
94
-
outputFileTracingIncludes: {
95
-
'/api/another': ['./necessary-folder/**/*'],
96
-
},
70
+
outputFileTracingExcludes: {
71
+
'/api/hello': ['./un-necessary-folder/**/*'],
72
+
},
73
+
outputFileTracingIncludes: {
74
+
'/api/another': ['./necessary-folder/**/*'],
75
+
'/api/login/\\[\\[\\.\\.\\.slug\\]\\]': [
76
+
'./node_modules/aws-crt/dist/bin/**/*',
77
+
],
97
78
},
98
79
}
99
80
```
100
81
82
+
**Note:** The key of `outputFileTracingIncludes`/`outputFileTracingExcludes` is a [glob](https://www.npmjs.com/package/picomatch#basic-globbing), so special characters need to be escaped.
83
+
101
84
- Currently, Next.js does not do anything with the emitted `.nft.json` files. The files must be read by your deployment platform, for example [Vercel](https://vercel.com), to create a minimal deployment. In a future release, a new command is planned to utilize these `.nft.json` files.
102
85
103
86
## Experimental `turbotrace`
@@ -127,8 +110,8 @@ module.exports = {
127
110
logAll?: boolean
128
111
// control the context directory of the turbotrace
129
112
// files outside of the context directory will not be traced
130
-
// set the `experimental.outputFileTracingRoot` has the same effect
131
-
// if the `experimental.outputFileTracingRoot` and this option are both set, the `experimental.turbotrace.contextDirectory` will be used
113
+
// set the `outputFileTracingRoot` has the same effect
114
+
// if the `outputFileTracingRoot` and this option are both set, the `experimental.turbotrace.contextDirectory` will be used
132
115
contextDirectory?: string
133
116
// if there is `process.cwd()` expression in your code, you can set this option to tell `turbotrace` the value of `process.cwd()` while tracing.
134
117
// for example the require(process.cwd() + '/package.json') will be traced as require('/path/to/cwd/package.json')
0 commit comments