Skip to content

Commit

Permalink
Enable swcMinify by default (vercel#41506)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk authored and Kikobeats committed Oct 24, 2022
1 parent 4dcc5d7 commit 910540a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 41 deletions.
10 changes: 5 additions & 5 deletions docs/advanced-features/compiler.md
Expand Up @@ -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. |
Expand Down Expand Up @@ -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
Expand All @@ -271,7 +272,6 @@ module.exports = {
},
},
},
swcMinify: true,
}
```

Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/config-shared.ts
Expand Up @@ -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,
Expand Down
7 changes: 0 additions & 7 deletions packages/next/server/config.ts
Expand Up @@ -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.`
Expand Down
28 changes: 0 additions & 28 deletions test/.stats-app/stats-config.js
Expand Up @@ -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',
],
},
],
}

0 comments on commit 910540a

Please sign in to comment.