From 6b50b5fe4be703bad9d2eba60a494ea9f45bb67d Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 17 Oct 2022 22:51:58 -0700 Subject: [PATCH] Enable swcMinify by default --- docs/advanced-features/compiler.md | 10 +++++----- packages/next/server/config-shared.ts | 2 +- packages/next/server/config.ts | 7 ------- test/.stats-app/stats-config.js | 28 --------------------------- 4 files changed, 6 insertions(+), 41 deletions(-) diff --git a/docs/advanced-features/compiler.md b/docs/advanced-features/compiler.md index 6708b07d693d2..02757c8e38e3d 100644 --- a/docs/advanced-features/compiler.md +++ b/docs/advanced-features/compiler.md @@ -9,6 +9,7 @@ description: Learn about the Next.js Compiler, written in Rust, which transforms | Version | Changes | | --------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| `v13.0.0` | SWC Minifier enabled by default. | | `v12.3.0` | SWC Minifier [stable](https://nextjs.org/blog/next-12-3#swc-minifier-stable). | | `v12.2.0` | [SWC Plugins](#swc-plugins-Experimental) experimental support added. | | `v12.1.0` | Added support for Styled Components, Jest, Relay, Remove React Properties, Legacy Decorators, Remove Console, and jsxImportSource. | @@ -241,18 +242,18 @@ Only `importMap` in `@emotion/babel-plugin` is not supported for now. ### Minification -You can opt-in to using the Next.js compiler for minification. This is 7x faster than Terser. +Next.js' swc compiler is used for minification by default since v13. This is 7x faster than Terser. + +If Terser is still needed for any reason this can be configured. ```js // next.config.js module.exports = { - swcMinify: true, + swcMinify: false, } ``` -If you have feedback about `swcMinify`, please share it on the [feedback discussion](https://github.com/vercel/next.js/discussions/30237). - ## Experimental Features ### Minifier debug options @@ -271,7 +272,6 @@ module.exports = { }, }, }, - swcMinify: true, } ``` diff --git a/packages/next/server/config-shared.ts b/packages/next/server/config-shared.ts index 6286da3da5285..2ec31c1a539da 100644 --- a/packages/next/server/config-shared.ts +++ b/packages/next/server/config-shared.ts @@ -547,7 +547,7 @@ export const defaultConfig: NextConfig = { }, outputFileTracing: true, staticPageGenerationTimeout: 60, - swcMinify: false, + swcMinify: true, output: !!process.env.NEXT_PRIVATE_STANDALONE ? 'standalone' : undefined, experimental: { optimisticClientCache: true, diff --git a/packages/next/server/config.ts b/packages/next/server/config.ts index f564f7cd7a144..a52d53b71cfad 100644 --- a/packages/next/server/config.ts +++ b/packages/next/server/config.ts @@ -471,13 +471,6 @@ function assignDefaults(userConfig: { [key: string]: any }) { ) } - if (result.experimental && 'swcMinify' in (result.experimental as any)) { - Log.warn( - `\`swcMinify\` has been moved out of \`experimental\`. Please update your ${configFileName} file accordingly.` - ) - result.swcMinify = (result.experimental as any).swcMinify - } - if (result.experimental && 'relay' in (result.experimental as any)) { Log.warn( `\`relay\` has been moved out of \`experimental\` and into \`compiler\`. Please update your ${configFileName} file accordingly.` diff --git a/test/.stats-app/stats-config.js b/test/.stats-app/stats-config.js index 0081dda215e3d..924441c7ad131 100644 --- a/test/.stats-app/stats-config.js +++ b/test/.stats-app/stats-config.js @@ -129,33 +129,5 @@ module.exports = { // numRequests: 2500, // }, }, - { - title: 'Default Build with SWC minify', - // renames to apply to make file names deterministic - renames, - configFiles: [ - { - path: 'next.config.js', - content: ` - module.exports = { - experimental: { - appDir: true, - // remove after next stable relase (current v12.3.1) - serverComponents: true - }, - swcMinify: true, - generateBuildId: () => 'BUILD_ID' - } - `, - }, - ], - filesToTrack: clientGlobs, - // will be output to fetched-pages/${pathname}.html - pagesToFetch: [ - 'http://localhost:$PORT/', - 'http://localhost:$PORT/link', - 'http://localhost:$PORT/withRouter', - ], - }, ], }