Minify: Minified code has other behaviour than normal code

Created on 14 Oct 2016  路  2Comments  路  Source: babel/minify

Hi, I've got this code:

class Adapter extends Array {
    constructor() {
        super();
        console.log('Hello');
        console.log('World');
    }
}
new Adapter()

which is transpiled using this config:

{
  "presets": [
    "es2015",
    "babili",
  ]
}

Without babili it runs just fine, but with it activated, I get following output:

World
Hello
World

The minified code look as follows:

'use strict';function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return call&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)throw new TypeError('Super expression must either be null or a function, not '+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var Adapter=function(_Array){function Adapter(){_classCallCheck(this,Adapter);var _this=_possibleConstructorReturn(this,(Adapter.__proto__||Object.getPrototypeOf(Adapter)).call(this));return console.log('World'),console.log('Hello'),console.log('World'),_this}return _inherits(Adapter,_Array),Adapter}(Array);new Adapter;
bug

Most helpful comment

The bug is in the simplify plugin.

I noticed that this doesn't happen when you don't use es2015 preset (or) when used with passPerPreset: true ...

{
  "presets": [ "es2015", "babili" ],
  "passPerPreset": true
}

All 2 comments

The bug is in the simplify plugin.

I noticed that this doesn't happen when you don't use es2015 preset (or) when used with passPerPreset: true ...

{
  "presets": [ "es2015", "babili" ],
  "passPerPreset": true
}

passperpreset is enabled by default .And also, even if I disable that option from babili, it still isn't a problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jamesloewen picture jamesloewen  路  3Comments

babel-bot picture babel-bot  路  3Comments

GabbeV picture GabbeV  路  3Comments

marvinhagemeister picture marvinhagemeister  路  5Comments

phoxer picture phoxer  路  3Comments