Labels |
Added:
?
|
But with Fedik's PR, ES6 files will be shipped and thus need to be minified. Uglify doesnt support ES6
That approach is also wrong. In order to ship esXXXX code you need to use module/nomodule in the script tags. That's what everybody else is doing. The approach to keep thinking on es5 terms for ESXXX is plain wrong...
Uglify doesnt support ES6
For Esxxxx you can use babel without transpiling, just minifying. Check the code in the build tools this is already supported:
const settings = [
{
presets: [
['@babel/preset-env', {
targets: {
browsers: ["ie 11"]
},
modules: false
}],
],
plugins: [
['add-header-comment', { header: [headerText] }],
['@babel/plugin-transform-classes']
],
comments: true
},
{
presets: [
['@babel/preset-env', {
targets: {
browsers: ["ie 11"]
},
modules: false
}],
"minify"
],
plugins: [
['@babel/plugin-transform-classes']
],
comments: false
}
];
Those settings are used to transpile to es5, but you can have a copy of them with browsers: ["last 2 versions"]
and voila ES6 minified (and also transpiled any newer feature to the minimum browser that Joomla wants to support)...
Yes browser detection is wrong. Should be feature detection, but then all assets will need to be lazy loaded.
Actually Joomla can use feature detection without lazy loading the scripts:
https://philipwalton.com/articles/deploying-es2015-code-in-production-today/
As always there are some caveats: scripts need to be ALWAYS deferred (otherwise the order of execution might be messed up), but this is the recommended best practice so at some point ppl should accept it and move forward...
Status | New | ⇒ | Discussion |
Category | ⇒ | Code style |
Labels |
Added:
J4 Issue
|
Labels |
Added:
?
|
Category | Code style | ⇒ |
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-04-10 07:42:12 |
Closed_By | ⇒ | C-Lodder |
FWIW uglify-es is only used for ES5 since the last or for the build tools. The reason is that either uglify-we or any other minifying script is useless now that we use the Babel minifier, which btw is the only one that can be trusted, check the react repo for the bugs from uglify-es