babel / minify

:scissors: An ES6+ aware minifier based on the Babel toolchain (beta)
https://babeljs.io/repl
MIT License
4.39k stars 225 forks source link

Minify + preset-env + webpack produce `void returnfalse` #920

Closed Hypnosphi closed 6 years ago

Hypnosphi commented 6 years ago

Describe the bug

void returnfalse code is produced, referring to a non-existent returnfalse variable.

To Reproduce

Minimal code to reproduce the bug

const getFoo = () => {
  if (process.env.NODE_ENV === 'development') {
    console.log('dev')
  }

  return 'foo'
}

console.log(getFoo())

Actual Output

(window.webpackJsonp=window.webpackJsonp||[]).push([[0],[function(o,n,w){console.log(void returnfalse)}],[[0,1]]]);

Expected Output

(window.webpackJsonp=window.webpackJsonp||[]).push([[0],[function(o,n,w){console.log('foo')}],[[0,1]]]);

Configuration

https://github.com/Hypnosphi/minify-returnfalse-repro/blob/master/webpack.config.js

Hypnosphi commented 6 years ago

Downgrading webpack to ~4.21.0 helps

Hypnosphi commented 6 years ago

OK looks like it's actually a webpack issue https://github.com/webpack/webpack/issues/8269