Skip to content

Commit

Permalink
Add minify debug env var to investigate minifier bugs (#31417)
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Nov 15, 2021
1 parent 0afc1d2 commit 9da8d65
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ function buildError(error, file) {
return new Error(`${file} from Terser\n${error.message}`)
}

const debugMinify = process.env.NEXT_DEBUG_MINIFY

export class TerserPlugin {
constructor(options = {}) {
const { cacheDir, terserOptions = {}, parallel, swcMinify } = options
const { terserOptions = {}, parallel, swcMinify } = options

this.options = {
swcMinify,
cacheDir,
parallel,
terserOptions,
}
Expand Down Expand Up @@ -128,6 +129,18 @@ export class TerserPlugin {
numberOfAssetsForMinify += 1
}

if (debugMinify && debugMinify === '1') {
console.dir(
{
name,
source: source.source().toString(),
},
{
breakLength: Infinity,
maxStringLength: Infinity,
}
)
}
return { name, info, inputSource: source, output, eTag }
})
)
Expand Down

0 comments on commit 9da8d65

Please sign in to comment.