Unverified Commit 748ce123 authored by Donny/강동윤's avatar Donny/강동윤 Committed by GitHub

Add `swcMinifyDebugOptions` (#37172)

This also updates swc crates to https://github.com/swc-project/swc/commit/7eac56163943925a19017dcb8c8a47c8af2dc702Co-authored-by: 's avatarJJ Kasper <22380829+ijjk@users.noreply.github.com>
parent c7ab218d
......@@ -233,6 +233,29 @@ module.exports = {
If you have feedback about `swcMinify`, please share it on the [feedback discussion](https://github.com/vercel/next.js/discussions/30237).
### Minifier debug options
While the minifier is experimental, we are making the following options available for debugging purposes. They will not be available once the minifier is made stable.
```js
// next.config.js
module.exports = {
experimental: {
swcMinifyDebugOptions: {
compress: {
defaults: true,
side_effects: false,
},
},
},
swcMinify: true,
}
```
If your app works with the options above, it means `side_effects` is the problematic option.
See [the SWC documentation](https://swc.rs/docs/configuration/minification#jscminifycompress) for detailed options.
### Modularize Imports
Allows to modularize imports, similar to [babel-plugin-transform-imports](https://www.npmjs.com/package/babel-plugin-transform-imports).
......
......@@ -1244,7 +1244,7 @@ dependencies = [
[[package]]
name = "modularize_imports"
version = "0.4.0"
version = "0.6.0"
dependencies = [
"handlebars",
"once_cell",
......@@ -2329,7 +2329,7 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
[[package]]
name = "styled_components"
version = "0.29.0"
version = "0.31.0"
dependencies = [
"Inflector",
"once_cell",
......@@ -2346,7 +2346,7 @@ dependencies = [
[[package]]
name = "styled_jsx"
version = "0.4.0"
version = "0.6.0"
dependencies = [
"easy-error",
"swc_common",
......@@ -2870,9 +2870,9 @@ dependencies = [
[[package]]
name = "swc_ecma_transforms_base"
version = "0.85.1"
version = "0.85.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1029b98240a2e87af924e5abe56b274110436670f12752c3978aae1fb6cb2ea"
checksum = "528c99be91500ed393e04e5cfc37763b4b68b71bc4f9b54ff0cd21d714920130"
dependencies = [
"better_scoped_tls",
"once_cell",
......@@ -2905,9 +2905,9 @@ dependencies = [
[[package]]
name = "swc_ecma_transforms_compat"
version = "0.99.2"
version = "0.99.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "299b629eb4c48fcb27760f760a7edde1f533e5f38f20f6a9eddc07b8a94b4ae7"
checksum = "dc2f3792e7d5da4acc577fb8c0d40876c20811892e2143d2bd161b53f85b491f"
dependencies = [
"ahash",
"arrayvec",
......@@ -2945,14 +2945,15 @@ dependencies = [
[[package]]
name = "swc_ecma_transforms_module"
version = "0.112.6"
version = "0.112.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "727fc776ddc1a564486f13602f50f3e68c242555f644fdaffbbeeef0a788b2b3"
checksum = "5bc3eede69627f3de90ca5a90efb78307f50762ab9cf94955e076493b9f33207"
dependencies = [
"Inflector",
"ahash",
"anyhow",
"indexmap",
"path-clean",
"pathdiff",
"serde",
"swc_atoms",
......@@ -3120,7 +3121,7 @@ dependencies = [
[[package]]
name = "swc_emotion"
version = "0.5.0"
version = "0.7.0"
dependencies = [
"base64 0.13.0",
"byteorder",
......@@ -3203,9 +3204,9 @@ dependencies = [
[[package]]
name = "swc_node_base"
version = "0.5.3"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "453fe6f9b8b74ab126bc034cf8a67cd454f448371123fd555e7549ca66e7bbc9"
checksum = "2771d2e2fe236364f95a4c4e29e41dd82592d047377337401593cade75ef878a"
dependencies = [
"mimalloc-rust",
"tikv-jemallocator",
......
......@@ -5,7 +5,7 @@ description = "AST Transforms for emotion"
license = "Apache-2.0"
name = "swc_emotion"
repository = "https://github.com/vercel/next.js.git"
version = "0.5.0"
version = "0.7.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
......
......@@ -5,7 +5,7 @@ edition = "2018"
license = "Apache-2.0"
name = "modularize_imports"
repository = "https://github.com/vercel/next.js.git"
version = "0.4.0"
version = "0.6.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
......
......@@ -36,8 +36,8 @@ swc_bundler = { version = "0.147.0", features = ["concurrent"] }
swc_common = { version = "0.18.7", features = ["concurrent", "sourcemap"] }
swc_ecma_loader = { version = "0.30.2", features = ["node", "lru"] }
swc_ecmascript = { version = "0.157.0", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] }
swc_plugin_runner = { version = "0.55.0", optional = true, default-features = false }
swc_node_base = "0.5.3"
swc_plugin_runner = { version = "0.55.0",optional=true }
swc_node_base = "0.5.5"
tracing = { version = "0.1.32", features = ["release_max_level_info"] }
tracing-futures = "0.2.5"
tracing-subscriber = "0.3.9"
......
......@@ -6,7 +6,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "styled_components"
repository = "https://github.com/vercel/next.js.git"
version = "0.29.0"
version = "0.31.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
......
......@@ -5,7 +5,7 @@ edition = "2018"
license = "Apache-2.0"
name = "styled_jsx"
repository = "https://github.com/vercel/next.js.git"
version = "0.4.0"
version = "0.6.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
......
......@@ -1138,7 +1138,17 @@ export default async function getBaseWebpackConfig(
cacheDir: path.join(distDir, 'cache', 'next-minifier'),
parallel: config.experimental.cpus,
swcMinify: config.swcMinify,
terserOptions,
terserOptions: {
...terserOptions,
compress: {
...terserOptions.compress,
...(config.experimental.swcMinifyDebugOptions?.compress ?? {}),
},
mangle: {
...terserOptions.mangle,
...(config.experimental.swcMinifyDebugOptions?.mangle ?? {}),
},
},
}).apply(compiler)
},
// Minify CSS
......
......@@ -134,6 +134,17 @@ export interface ExperimentalConfig {
>
swcTraceProfiling?: boolean
forceSwcTransforms?: boolean
/**
* The option for the minifier of [SWC compiler](https://swc.rs).
* This option is only for debugging the SWC minifier, and will be removed once the SWC minifier is stable.
*
* @see [SWC Minification](https://nextjs.org/docs/advanced-features/compiler#minification)
*/
swcMinifyDebugOptions?: {
compress?: object
mangle?: object
}
swcPlugins?: Array<[string, Record<string, unknown>]>
largePageDataBytes?: number
}
......
......@@ -492,6 +492,12 @@ function assignDefaults(userConfig: { [key: string]: any }) {
)
}
if (result.experimental?.swcMinifyDebugOptions) {
Log.warn(
'SWC minify debug option specified. This option is for debugging minifier issues and will be removed once SWC minifier is stable.'
)
}
if (
result.experimental?.outputFileTracingRoot &&
!isAbsolute(result.experimental.outputFileTracingRoot)
......
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