Skip to content

Commit

Permalink
misc: add MANGLING_DEBUG option (#40958)
Browse files Browse the repository at this point in the history
Context:

I am doing some work re: bundle size so I'm spending a lot of time looking at the bundles we generate. This debug options basically deactives mangling and beautifies the output whilst keeping the dead code elimination from Terser which is helpful for me to check what I'm removing.

this is what the output is like with it.

<img width="566" alt="image" src="https://user-images.githubusercontent.com/11064311/192574974-4ff50fb8-43b2-44fe-9df3-c9e3a1b593f8.png">


## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature






- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
  • Loading branch information
feedthejim committed Sep 28, 2022
1 parent 43dfc50 commit e8f85e3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/next/build/webpack-config.ts
Expand Up @@ -897,13 +897,28 @@ export default async function getBaseWebpackConfig(
comparisons: false,
inline: 2, // https://github.com/vercel/next.js/issues/7178#issuecomment-493048965
},
mangle: { safari10: true },
mangle: {
safari10: true,
...(process.env.__NEXT_MANGLING_DEBUG
? {
toplevel: true,
module: true,
keep_classnames: true,
keep_fnames: true,
}
: {}),
},
output: {
ecma: 5,
safari10: true,
comments: false,
// Fixes usage of Emoji and certain Regex
ascii_only: true,
...(process.env.__NEXT_MANGLING_DEBUG
? {
beautify: true,
}
: {}),
},
}

Expand Down

0 comments on commit e8f85e3

Please sign in to comment.