webpack-contrib / babel-minify-webpack-plugin

[DEPRECATED] Babel Minify Webpack Plugin
MIT License
491 stars 44 forks source link

A joined array of ES6 template literals is minfied uncorrectly #76

Closed alshakero closed 6 years ago

alshakero commented 6 years ago

Hi! Thank you for the awesome package. I've been using it for a long time and it's been great. Today I stumbled upon this issue.

Node version

node -v
v8.5.0

OS: Windows 10

This:

const message = [`Hey`, `Jude`].join('\n');
console.log(message);

Is minified to this:

function(){console.log('\n')}

Whole bundle

var Palindrom=function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={i:d,l:!1,exports:{}};return a[d].call(e.exports,e,e.exports,b),e.l=!0,e.exports}var c={};return b.m=a,b.c=c,b.d=function(a,c,d){b.o(a,c)||Object.defineProperty(a,c,{configurable:!1,enumerable:!0,get:d})},b.n=function(a){var c=a&&a.__esModule?function(){return a['default']}:function(){return a};return b.d(c,'a',c),c},b.o=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)},b.p='',b(b.s=0)}([function(){console.log('\n')}]);

Reproduction repo

https://github.com/alshakero/webpack_bug

Reproduction steps

  1. Clone the repo above.
  2. Run npm install.
  3. Run npm run build

You should see the results in dist with obvious names.

Potentially usefull information:

  1. I couldn't reproduce this in Babel online REPL.
  2. Using normal ES5 string literals works.
alexander-akait commented 6 years ago

@alshakero Thanks for detailed issue! But we don't do minification directly, we just use https://github.com/babel/minify/tree/master/packages/babel-preset-minify, seems something have bug. Please create issue there.