Open tpluscode opened 7 years ago
Could be an UglifyJs problem to digest ESNext syntax?
I'm trying to figure this out, maybe we can consider to add https://github.com/babel/minify instead of the standard UglifyJs minifier called by the --optimize-minimize
. Do you think could be a solution?
Or maybe another solution could be transpiling to ES5, but I need to test, and of course after that we will need the custom-elements-es5-adapter.js
for the app.
I did try with ES5 but somehow anything I tried also produced some error. In the end I think it wasn't even transpiling. I'm not sure how to do that properly. I've mostly written TS myself 😞
Did you try to minify with the babel/minify
?
I found that it works as expected with this webpack.conf.js
:
const path = require('path');
const webpack = require('webpack');
const MinifyPlugin = require('babel-minify-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'src'),
filename: 'bundle.js'
},
plugins: [
new MinifyPlugin()
]
};
NOTE: I think we can't use the --optimize-minimize
option because it works with UglifyJs
and other default options that seem don't support ES6.
Maybe defining the babel-loader
and UglifyJs
within the webpack configuration we can achieve the same result of --optimize-minimize
option.
With MinifyPlugin
it bundled without errors but in console I'm seeing
SyntaxError: Cannot declare a let variable twice: 'd'.
I tried with babel-loader
and various combinations of presets but every time the output was ES6 and not ES5. Don't know why...
Yeah, I'm seeing the same problem. Thank you for your upgrades and info. I will try some other solution, then maybe I will ask on the Polymer Slack.
Let's leave this issue open until we found a solution. Thank you again!
When I run
webpack --optimize-minimize
I get error:That's this line:
Any ideas?