Open kaihendry opened 7 years ago
Oh, another problem is that npm run build
webpack.optimize fails with
ERROR in build.js from UglifyJs
Unexpected token: operator (>) [./src/main.js:6,10][build.js:119,13]
Your change to .babelrc
essentially deactivated transpilation for this feature because it's avaailable in the last 2 chrome versions.
But since Uglify can't deal with anything beyond ES5, minification breaks.
Oh, so why did I need to change babel for it not to complain?
Any ideas how to keep the bundle size low but using features like await?
Oh, so why did I need to change babel for it not to complain?
Probably because transpiling async requires a polyfill, not just transpilation. And you didn't provide said polyfill.
After you told babel not to transpile, it had no problem.
What about minimising the bundle since async/await isn't liked by UglifyJS?
you can switch to babel-minify-webpack-plugin.
However, I don't think we will switch this template to support all of this, load polyfills etc. - it's meant to be a simple, basic template.
But, if you use uglifyJS as you do for creating the production bundle, and someone uses async/await, it won't simply work?
No. If they don't transpile and polyfill aync /await, then ES6/7 code will be passed to Uglify, which it can't handle.
If you properly setup babel to transpile to Es5 and also polyfill missing features for this transpilation (namely generators), then Uglify only receives ES5 code and is happy.
Still struggling to understand why there is a need to transpile by default with leading browsers such as Safari & Chrome support this stuff?
And surely you can't expect people using this project to know how to easily use polyfill?
Well, that choice is not that easy. This template aims to work on all browsers that Vue supports, which includes IE11 (or even 9).
This requires transpilation to ES5. So we would have to include a polyfill by default for generators to make transpilation to ES5 possible for async/await- and that polyfill is quite heavy.
So we either
asyc/await
struggling over errors in one browser specificallyIf we choose option 2, we should ...
So this can be done and considered, but is not as easy as the babel config you showed.
Option 2 and 2 gets my vote.
why bother
The following code doesn't work unless babel is massaged.
Easiest way to support it, appears to be updating .babelrc