Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable swcMinify by default #41506

Merged
merged 2 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/advanced-features/compiler.md
Original file line number Diff line number Diff line change
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "swc compiler" is redundant since swc stands for "speedy web compiler"

Also, this should be added to upgrading.md too, right?


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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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',
],
},
],
}