Skip to content

Commit 72fae8b

Browse files
authored
Move productionBrowserSourceMaps out of experimental (#20267)
Makes https://www.npmjs.com/package/@zeit/next-source-maps a built-in feature so that it can be deprecated.
1 parent cfca41c commit 72fae8b

File tree

6 files changed

+31
-8
lines changed

6 files changed

+31
-8
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
description: Save pages under the `src` directory as an alternative to the root `pages` directory.
3+
---
4+
5+
# Source Maps
6+
7+
Source Maps are enabled by default during development. During production builds they are disabled as generation source maps can significantly increase build times and memory usage while being generated.
8+
9+
Next.js provides a configuration flag you can use to enable browser source map generation during the production build:
10+
11+
```js
12+
// next.config.js
13+
module.exports = {
14+
productionBrowserSourceMaps: true,
15+
}
16+
```
17+
18+
When the `productionBrowserSourceMaps` option is enabled the source maps will be output in the same directory as the JavaScript files, Next.js will automatically serve these files when requested.
19+
20+
## Caveats
21+
22+
- Can increase `next build` time
23+
- Increases memory usage during `next build`

docs/manifest.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@
181181
"title": "Debugging",
182182
"path": "/docs/advanced-features/debugging.md"
183183
},
184+
{
185+
"title": "Source Maps",
186+
"path": "/docs/advanced-features/source-maps.md"
187+
},
184188
{
185189
"title": "Codemods",
186190
"path": "/docs/advanced-features/codemods.md"

packages/next/build/webpack-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export default async function getBaseWebpackConfig(
205205
}
206206
): Promise<webpack.Configuration> {
207207
const productionBrowserSourceMaps =
208-
config.experimental.productionBrowserSourceMaps && !isServer
208+
config.productionBrowserSourceMaps && !isServer
209209
let plugins: PluginMetaData[] = []
210210
let babelPresetPlugins: { dir: string; config: any }[] = []
211211

packages/next/next-server/server/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const defaultConfig: NextConfig = {
5959
sassOptions: {},
6060
trailingSlash: false,
6161
i18n: null,
62+
productionBrowserSourceMaps: false,
6263
experimental: {
6364
cpus: Math.max(
6465
1,
@@ -71,7 +72,6 @@ const defaultConfig: NextConfig = {
7172
reactMode: 'legacy',
7273
workerThreads: false,
7374
pageEnv: false,
74-
productionBrowserSourceMaps: false,
7575
optimizeImages: false,
7676
optimizeCss: false,
7777
scrollRestoration: false,
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
module.exports = {
2-
experimental: {
3-
productionBrowserSourceMaps: true,
4-
},
2+
productionBrowserSourceMaps: true,
53
}

test/integration/production-browser-sourcemaps/test/index.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ describe('Production browser sourcemaps', () => {
4343
`
4444
module.exports = {
4545
target: 'serverless',
46-
experimental: {
47-
productionBrowserSourceMaps: true
48-
}
46+
productionBrowserSourceMaps: true
4947
}
5048
`
5149
)

0 commit comments

Comments
 (0)