webpack-contrib / babel-minify-webpack-plugin

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

Uncaught TypeError: Class constructor cannot be invoked without 'new' [bug] #64

Closed damianobarbati closed 7 years ago

damianobarbati commented 7 years ago

I'm not sure whether this is a babel-minify-webpack-plugin or a babel-minify plugin. I supposed the latter so I reported this bug there (https://github.com/babel/minify/issues/711) but for sake of completeness I'm reporting it here as well in case anybody else is facing the same.

What happens? It looks like classes are converted to functions instead of ES6 classes. It's not up to modules: it's triggered by tons of them, I manually tried to remove dependencies but this pop up anyway for most of them.

Uncaught TypeError: Class constructor _class2 cannot be invoked without 'new'
    at exports.default (jszip.js:13)
    at jszip.js:13

REPRO https://github.com/damianobarbati/babel-minify-bug Instructions in README.

npm install -g yarn pm2
yarn install
yarn serve:dev //run pm2 to serve the website
yarn build:dev //run webpack without minifying and everything is fine at http://localhost:8080
yarn build:prod //run this to run webpack with minifying and http://localhost:8080 is broken

Babel versions and plugins I'm using babel-preset-env and babel-minify-webpack-plugin and I tried both the following minify options:

new BabelMinifyPlugin(), //everything on
new BabelMinifyPlugin({ mangle: false, evaluate: false, propertyLiterals: false }), //no mangle at all

Config and versions:

"babel": {
    "presets": [
        [
            "env",
            {
                "modules": false,
                "useBuiltIns": "usage",
                "debug": false
            }
        ],
        "stage-0",
        "react"
    ],
    "plugins": [
        "lodash",
        "transform-decorators-legacy",
        "transform-class-properties"
    ]
},
....
"babel-minify-webpack-plugin": "0.2.0",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-decorators-legacy": "1.3.4",
"babel-polyfill": "7.0.0-beta.2",
"babel-preset-env": "2.0.0-beta.2",
"webpack": "3.7.1",
boopathi commented 7 years ago

This is not a bug with the webpack plugin. I'm closing this here.