Unverified Commit 72fae8be authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

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.
parent cfca41cb
---
description: Save pages under the `src` directory as an alternative to the root `pages` directory.
---
# Source Maps
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.
Next.js provides a configuration flag you can use to enable browser source map generation during the production build:
```js
// next.config.js
module.exports = {
productionBrowserSourceMaps: true,
}
```
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.
## Caveats
- Can increase `next build` time
- Increases memory usage during `next build`
...@@ -181,6 +181,10 @@ ...@@ -181,6 +181,10 @@
"title": "Debugging", "title": "Debugging",
"path": "/docs/advanced-features/debugging.md" "path": "/docs/advanced-features/debugging.md"
}, },
{
"title": "Source Maps",
"path": "/docs/advanced-features/source-maps.md"
},
{ {
"title": "Codemods", "title": "Codemods",
"path": "/docs/advanced-features/codemods.md" "path": "/docs/advanced-features/codemods.md"
......
...@@ -205,7 +205,7 @@ export default async function getBaseWebpackConfig( ...@@ -205,7 +205,7 @@ export default async function getBaseWebpackConfig(
} }
): Promise<webpack.Configuration> { ): Promise<webpack.Configuration> {
const productionBrowserSourceMaps = const productionBrowserSourceMaps =
config.experimental.productionBrowserSourceMaps && !isServer config.productionBrowserSourceMaps && !isServer
let plugins: PluginMetaData[] = [] let plugins: PluginMetaData[] = []
let babelPresetPlugins: { dir: string; config: any }[] = [] let babelPresetPlugins: { dir: string; config: any }[] = []
......
...@@ -59,6 +59,7 @@ const defaultConfig: NextConfig = { ...@@ -59,6 +59,7 @@ const defaultConfig: NextConfig = {
sassOptions: {}, sassOptions: {},
trailingSlash: false, trailingSlash: false,
i18n: null, i18n: null,
productionBrowserSourceMaps: false,
experimental: { experimental: {
cpus: Math.max( cpus: Math.max(
1, 1,
...@@ -71,7 +72,6 @@ const defaultConfig: NextConfig = { ...@@ -71,7 +72,6 @@ const defaultConfig: NextConfig = {
reactMode: 'legacy', reactMode: 'legacy',
workerThreads: false, workerThreads: false,
pageEnv: false, pageEnv: false,
productionBrowserSourceMaps: false,
optimizeImages: false, optimizeImages: false,
optimizeCss: false, optimizeCss: false,
scrollRestoration: false, scrollRestoration: false,
......
module.exports = { module.exports = {
experimental: { productionBrowserSourceMaps: true,
productionBrowserSourceMaps: true,
},
} }
...@@ -43,9 +43,7 @@ describe('Production browser sourcemaps', () => { ...@@ -43,9 +43,7 @@ describe('Production browser sourcemaps', () => {
` `
module.exports = { module.exports = {
target: 'serverless', target: 'serverless',
experimental: { productionBrowserSourceMaps: true
productionBrowserSourceMaps: true
}
} }
` `
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment