You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** @returns {terser.MinifyOptions} */constgetTerserOpts=({ debug })=>({ecma: 2020,toplevel: false,parse: {},mangle: true,compress: {keep_fargs: false,pure_getters: true,drop_console: false,pure_funcs: [],unsafe: true,unsafe_arrows: true,unsafe_comps: true,unsafe_Function: true,unsafe_math: true,unsafe_symbols: true,unsafe_methods: true,unsafe_proto: true,passes: 10,global_defs: {DEBUG: debug,},},format: {comments: false,wrap_func_args: false,wrap_iife: false,},});constcode=`const DEBUG_assert = (expr, msg) => { if (!DEBUG) return; if (expr) return; throw new Error(msg);};const foo_test = (term) => { DEBUG_assert(Array.isArray(term), 'should be an array') DEBUG_assert([].includes(term), 'should be one of []')}`constterser=require('terser');terser.minify({'some-file.js': code},getTerserOpts({debug: true})).then(res=>console.dir({debug: true, ...res}))terser.minify({'some-file.js': code},getTerserOpts({debug: false})).then(res=>console.dir({debug: false, ...res}))
terser input
see above
terser output or error
Expected result
when debug === true, I expect something to the effect of
{
debug: true,
code: 'const DEBUG_assert=(r,s)=>{if(!r)throw Error(s)},foo_test=r=>{DEBUG_assert(Array.isArray(r),"should be an array"),DEBUG_assert([].includes(r),"should be one of []")};'
}
when debug === false, I expect something to the effect of
I just upgraded to latest (5.19.4, at time of writing), and my issue has disappeared. I now am able to enjoy the expected behavior.
did quick bisect, looks like #1330 fixed my issue; the resolution on this is to upgrade.
Feature request
Version 5.13.0
Complete CLI command or
minify()
options usedterser
inputsee above
terser
output or errorExpected result
when
debug === true
, I expect something to the effect ofwhen
debug === false
, I expect something to the effect ofActual
the
debug === false
case does not match my expectation. the actual output isthere is an additional
[].includes()
call which was kept.The text was updated successfully, but these errors were encountered: