? Pending

User tests: Successful: Unsuccessful:

avatar dneukirchen
dneukirchen
12 Feb 2018

Summary of Changes

Adds a script that compiles es6 down to es5 using babel-core.

This PR is part of a javascript modernization plan. See #19643 for more details.

The next step is to wire this up with the other build scripts (and refactor them).

When this PR gets merged, we write the es6 code in the file /path/to/lib.es6.js which then gets compiled into es5 /path/to/lib/lib.js (and depending on the result of #19637 also into /path/to/lib.min.js).

Testing Instructions

Create a javascript file anywhere in the project and name it whatever.es6.js
Write es6 javascript i.e: [1, 2, 3, 4, 5].map(num => num * 2);
Run npm install
Run node build/build-modules-js/compile-es6.js

Expected result

See whatever.js file created. This is the compiled es5 version of your es6 file and can be used in all supported browsers.

Documentation Changes Required

No changes, but this definitely needs documentation.

@dgt41 @C-Lodder @Fedik @laoneo

avatar dneukirchen dneukirchen - open - 12 Feb 2018
avatar dneukirchen dneukirchen - change - 12 Feb 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 12 Feb 2018
Category JavaScript Repository
avatar dneukirchen dneukirchen - change - 12 Feb 2018
The description was changed
avatar dneukirchen dneukirchen - edited - 12 Feb 2018
avatar dneukirchen dneukirchen - change - 12 Feb 2018
The description was changed
avatar dneukirchen dneukirchen - edited - 12 Feb 2018
avatar dneukirchen dneukirchen - change - 12 Feb 2018
The description was changed
avatar dneukirchen dneukirchen - edited - 12 Feb 2018
avatar dneukirchen dneukirchen - change - 12 Feb 2018
The description was changed
avatar dneukirchen dneukirchen - edited - 12 Feb 2018
avatar dneukirchen dneukirchen - change - 12 Feb 2018
The description was changed
avatar dneukirchen dneukirchen - edited - 12 Feb 2018
avatar dneukirchen dneukirchen - change - 12 Feb 2018
Title
Feature/compile es6
[4.0] Feature/compile es6
avatar dneukirchen dneukirchen - edited - 12 Feb 2018
avatar laoneo
laoneo - comment - 12 Feb 2018

Does it create also a ES5 none minified version? If not, this would mean then that debug mode would only work with ES6 compatible browsers?

avatar dgt41
dgt41 - comment - 12 Feb 2018

@laoneo debugging transpilled code won’t be fun! I guess if the removal of minified assets ever gets approved all we need is the non minified ES5 code

avatar laoneo
laoneo - comment - 12 Feb 2018

So when all of this gets approved we write the code in the file /media/plg_media-action_crop/js/crop.es6.js which then gets compiled into /media/plg_media-action_crop/js/crop.js and /media/plg_media-action_crop/js/crop.min.js? I guess this would be good to know for other devs what the consequences are of this pr while we develop then the core in the future.

avatar dneukirchen
dneukirchen - comment - 12 Feb 2018

So when all of this gets approved we write the code in the file /media/plg_media-action_crop/js/crop.es6.js which then gets compiled into /media/plg_media-action_crop/js/crop.js and /media/plg_media-action_crop/js/crop.min.js?

In short: Yes.

avatar dneukirchen dneukirchen - change - 12 Feb 2018
The description was changed
avatar dneukirchen dneukirchen - edited - 12 Feb 2018
avatar dneukirchen dneukirchen - change - 12 Feb 2018
The description was changed
avatar dneukirchen dneukirchen - edited - 12 Feb 2018
e951b25 12 Feb 2018 avatar dneukirchen CS
avatar dneukirchen dneukirchen - change - 12 Feb 2018
Labels Added: ?
avatar dneukirchen dneukirchen - change - 12 Feb 2018
The description was changed
avatar dneukirchen dneukirchen - edited - 12 Feb 2018
avatar dneukirchen
dneukirchen - comment - 12 Feb 2018

Added an example to further explain the process.
Please follow the last 3 commits.

  1. First i just copied admin.login.js to admin.login.es6.js.
  2. Then i used my IDE to auto-fix the .es6.js file, so that it follows our new javascript code styles. Notice that i did not manually change anything here (eslint --fix or IDE with eslint support will do most of the work).
  3. Lastly i executed the new compiler (node build/build-modules-js/compile-es6.js), which updated the contents of the original admin.login.js.

As you can see:

  • its not required (but strongly recommended) to use es6 features in the *.es6.js files.
  • the compiled file for the user is valid es5 and we can continue to use it
8218fa4 12 Feb 2018 avatar dneukirchen CS
avatar wilsonge
wilsonge - comment - 12 Feb 2018

I'm good with this in principle

avatar dneukirchen dneukirchen - change - 12 Feb 2018
The description was changed
avatar dneukirchen dneukirchen - edited - 12 Feb 2018
avatar dneukirchen
dneukirchen - comment - 14 Feb 2018

RTC?

avatar wilsonge
wilsonge - comment - 14 Feb 2018

@dgt41 has asked for a chat with me tonight about this. Want to see what the outcome of that is first before i hit RTC & merge :)

avatar dneukirchen
dneukirchen - comment - 15 Feb 2018

As discussed with @dgt41 i reverted the example code so that we can merge this one while working on https://github.com/joomla-projects/joomla-es6

avatar astridx
astridx - comment - 17 Feb 2018

I tested this PR successful. My *.es6.js files have been compiled to *.js and the text "PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
+OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD" was standing in the first line of the file.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 17 Feb 2018

@astridx please mark your Test as successfully:

  • open Issue Tracker
  • Login with your github-Account
  • Click on blue "Test this"-Button above Authors-Picture
  • mark your Test as successfully
  • hit "submit test result"
avatar astridx
astridx - comment - 17 Feb 2018

I have tested this item successfully on b8be210


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19650.

avatar astridx astridx - test_item - 17 Feb 2018 - Tested successfully
avatar wilsonge
wilsonge - comment - 18 Feb 2018

@dneukirchen if you fix conflicts here i'll get it merged :)

avatar dneukirchen
dneukirchen - comment - 19 Feb 2018

Resolved. Thank you.

avatar dneukirchen
dneukirchen - comment - 20 Feb 2018

push
@wilsonge

avatar dneukirchen
dneukirchen - comment - 20 Feb 2018

@wilsonge resolved the merge conflicts... again... ?
https://www.youtube.com/watch?v=oJDGcxAf9D8

(waiting for merge here, so that we can safely start the work in projects/es6 repo)

avatar mbabker mbabker - change - 20 Feb 2018
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-02-20 20:07:49
Closed_By mbabker
avatar mbabker mbabker - close - 20 Feb 2018
avatar mbabker mbabker - merge - 20 Feb 2018

Add a Comment

Login with GitHub to post a comment