-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[4.0] Deliver ES2015+ javascript #32315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
looks okau to me. |
Sure, but only if we ever come to an agreement on how we move forward with Js, transpiling, etc 🤣 |
|
you know what I thinking, |
The backend is unusable with the default template. If I fork Atum and use bs4 css (patching the changed classes with some extends or whatever) the backend should be still fine on IE11 @wilsonge any input here? |
It not only the styling, but much of JS errors (I tried on current 4.0-dev branch, without this PR) |
There are known errors right now as people removed some polyfills without our tools adding them back. Basically, the tools are not really transpiling properly the es6 files. Partially this is fixed with #32300 but I think there will be a bit more tweaking required @Fedik can you post some of those errors? |
yeah I suspect that also, |
|
Thanks, so there are quite some problems here:
EDIT: it seems there's a tag missing: |
f8b099c to
a2b010a
Compare
I know, I commented out the required lines for IE https://github.com/joomla/joomla-cms/pull/32315/files#diff-7973fa8a952791298a25a8354216ed84a7476bf991fce4be84f05cb1d91f2bce because we might want to abstract (if possible) the Babel runtime (it's 6kb that will be included in each script) but besides that, we need a list of DOM polyfills that Babel is not injecting (eg |
you wanted to say that we need jQuery? 😄 |
I some cases also Mootools 🤣 |
|
@wilsonge can we have a decision here? |
|
@dgrammatiko I think with this PR, it's a good opportunity to change ESlint with @babel/eslint-parser, this one allows static properties to be parsed, something I need for the color-picker called |
|
@thednp joomla is using the Airbnb rules for eslint and I don’t see why we need to change this. Airbnb is extremely well documented. Also you can’t use formInternals as it is poorly supported |
|
Also |
|
Safari doesn’t support it so: no ref https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onformdata |
|
Btw I already gave you the solution |
|
@dgrammatiko Now I have a problem when using node version 12: I.e. it breaks here: With node version 14 I don't have that problem. At least one other person could reproduce that, i.e. same problem on same OS (Linux) with node v12, and no problem anymore after removing node and installing v14. Any idea? @wilsonge What version of node do we require? |
|
@richard67 Can you change it to: Also according to https://nodejs.org/en/about/releases/ v10 goes EOL next month, so v12 should be set as the minimum at the end of April. |
Not sure if I can. Can you advise me? Does it need a text editor for that?
It solves the problem on node v12 on my Linux VM. Will see in a few minutes if it still works with node v14 on my Windows VM. |
Well, the |
It means no need for a fix? Or it means your suggested fix is ok? If the latter: Could you make the necessary PR? |
|
so the question arise what should be the node and npm versions ? for testing of course |
|
sure: #32686 |
Till the end of April v10 should be ok but I guess the project should raise the minimum to v12 before v10 goes EOL. Also whatever you do MARK the date (end of April) as you have to do this every year since Javascript the language gets a new version every year (so nodejs just follows the ecmascript releases) |
Lines 10 to 12 in 4bc8bb1
|
Co-authored-by: Brian Teeman Co-authored-by: Roland Dalmulder Co-authored-by: AndySDH Co-authored-by: Quy


Pull Request for Issue # .
Summary of Changes
Use
type=modulefor ES2017 andnomodulefor ES5 scriptsTesting Instructions
Test every url Front End and Back End to confirm that there's no console errors and all the interactive elements continue to work as before
Especially check the Admin login by insering a username but ignoring the password should raise a message (formbvalidation)
Set the editor to Codemirror and create an article and also check that editing a template file is working as before
Actual result BEFORE applying this Pull Request
Expected result AFTER applying this Pull Request
Documentation Changes Required
Just as a comment here: all
.es6.jsand.w-c.es6.jsare handled by Rollup, meaning that anyimportwill be correctly bundled. Also the compiled-es5.jsis again created by Rollup using Babel. This adds a delay on the build command BUT now all the ES6 files are ES2017 (meaning there is translation to a minimum version) against the previous state (ES6 filescould have eg 2021 code that would be problematic for many browsers as the coverage is way bellow the 95% threshold, which is assumed the industry standard for the compatibility lower boundary. Worth watching https://www.youtube.com/watch?v=cLxNdLK--yI by @developit and @housseindjirdeh as this PR basically implements exactly that)
Performance
The impact could be from 1s to 20s depending on the actual hardware
Before
The CI server

My mac

After
The CI server

My mac

Calling for testing @richard67 @Fedik @anibalsanchez @alikon @laoneo
Eg legacy script is, let's say some jQuery, so:
{ "name": "com_example.awesome-script", "type": "script", "uri": "com_example/awesome-script.min.js", "dependencies": [ "core" ], "attributes": { "defer": true }Modern way assumes that the script has a source (modern JS) that transpiles to 2 files, one ES2017 and one ES5 (the one with -es5):
{ "name": "com_example.awesome-script.es5", "type": "script", "uri": "com_example/awesome-script-es5.min.js", "dependencies": [ "core" ], "attributes": { "nomodule": true, "defer": true }, } { "name": "com_example.awesome-script", "type": "script", "uri": "com_example/awesome-script.min.js", "dependencies": [ "com_example.awesome-script.es5" ], "attributes": { "type": "module" } }Eg: Legacy:
Eg Modern:
Mind that the legacy script
com_example/awesome-script.min.jswas theoretically rewritten as modern JS and was transpiled to ES2017 with the same name and then a transpiled ES5 was produced by a bundler and had a theoretical namecom_example/awesome-script-es5.min.js. But this is the convention Joomla is using, devs can use their own naming convention here, Joomla will not impose anything in this part.Joomla has a set of tools for compiling a modern script to ES2017 and ES5 files. Devs can use Rollup, Webpack, Parcel, ESBuild, SnowPack, or any other bundler out there. The scripts for the bundling live at https://github.com/joomla/joomla-cms/tree/4.0-dev/build/build-modules-js/javascript and devs can even use them as-is if they develop on top of the Joomla repo (this is probably an antipattern, but...) or fork them for their own benefit.