Skip to content
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

[5.0] Drop es5 js files #39618

Merged
merged 32 commits into from
Jun 24, 2023
Merged

[5.0] Drop es5 js files #39618

merged 32 commits into from
Jun 24, 2023

Conversation

dgrammatiko
Copy link
Contributor

Pull Request for Issue # .

Summary of Changes

  • ES5 js files are targeting browser before 2015!
  • Joomla 5 (the js parts) would work on anything ES2018 or newer (that's 5 year old browsers!)
  • The 2018 was chosen as the year that all browsers supported ES Modules https://caniuse.com/es6-module
  • The PR adjusts all the joomla.asset.json files
  • It removes 2 dead npm packages chosen and focus-visible (never used in v4, the first was rolled with v4 for b/c the second was removed in some beta but the dependency was left behind)
  • the build tools were adjusted

Testing Instructions

Joomla still works

Actual result BEFORE applying this Pull Request

Expected result AFTER applying this Pull Request

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@nibra @HLeithner this is my take on what the deliverables should be but there was also a discussion prior to v4 release on the same subject:

These conversations actually led to shipping type=module/nomodule on the first place but I guess now it's time to skip the es5 altogether.

@joomla-cms-bot joomla-cms-bot added NPM Resource Changed This Pull Request can't be tested by Patchtester PR-5.0-dev labels Jan 12, 2023
@HLeithner
Copy link
Member

@dgrammatiko could you please rebase this?

@dgrammatiko
Copy link
Contributor Author

@HLeithner done

Copy link
Contributor

@wilsonge wilsonge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously agree with the concept. Largely lgtm only final comment do we still not want to use rollup in most cases against the code so that we can use modern js syntax like async/await or similar if we want

build/build-modules-js/settings.json Outdated Show resolved Hide resolved
@HLeithner
Copy link
Member

can we split this pr please, one "simple" pr that only removes es5 no other changes? is this possible?

@dgrammatiko
Copy link
Contributor Author

can we split this pr please, one "simple" pr that only removes es5 no other changes?

The extra parts are the removal of the focus-visible or there are more? Can do

@HLeithner
Copy link
Member

you removed chosen too, also I don't know the impact of changing template.js from defer:true to type:module

@dgrammatiko
Copy link
Contributor Author

dgrammatiko commented Mar 8, 2023

I don't know the impact of changing template.js from defer:true to type:module

type="module" is also embedding defer but also it has narrower scope (a good thing). The template.js is only depends on core.js so it's completely safe. type=module

Screenshot 2023-03-08 at 12 26 45

you removed chosen too

chosen is dead. It was dead back in 2015 when Joomla v4 was started so at some point this needs to be removed. That said I can revert this change (although I don't quite agree with the notion of distributing dead code)

Screenshot 2023-03-08 at 12 23 11

@HLeithner
Copy link
Member

about chosen, we use it on our own site https://developer.joomla.org/joomlacode-archive/tracker-32.html with joomla 4 and the promise is that this should continue without issues. That brings me to 2 questions.

  1. are templates using the es5 at the moment, you mentioned they are broken
  2. is it possible to move chosen and focus-visible (if this is not replaced by something else automatically) to the b/c plugin?

@dgrammatiko
Copy link
Contributor Author

is it possible to move chosen and focus-visible (if this is not replaced by something else automatically) to the b/c plugin?

Both were reverted but I have no clue how can PHP influence some static assets

are templates using the es5 at the moment, you mentioned they are broken

NO. All the methods (HTMLHelper, WAM) will only include assets (js,css) only if the files exist

@brianteeman
Copy link
Contributor

Not sure if its relevant but dont forget the debug plugin uses jquery

@dgrammatiko
Copy link
Contributor Author

Not sure if its relevant but dont forget the debug plugin uses jquery

Back in 2018 I was about to offer converting it to vanilla js but the author wasn't really interested: maximebf/php-debugbar#368

I would like to move this to a Webassetitem, but not sure if this this makes it better and how it have to be changed base on the Joomla own fetch function using the csrf token only for the current domain...

The CSRF on that jQuery script has the same exact issue (leaking) as the Joomla.response. But there are other issues with the Joomla.request that are also valid for $.ajax() (this is not a good place for this discussion).

BTW moving the jQuery to WAM is a B/C break (unless you have a dummy HTMLHelper::jquery that calls the WAM.

For anyone following the jQuery discussion I would like to mention that the maintainers have a plan for jQuery v4 with a bunch of B/C breaks all due to security:

@HLeithner
Copy link
Member

Not sure if its relevant but dont forget the debug plugin uses jquery

not planning to remove jquery from joomla, only want to reduce HTMLHelpers because they are not the way to go (if possible).

but completely irrelevant to this pr at the moment. I plan to do multiple Pr for the b/c plugin, if you are interested you can look at my repo.

BTW moving the jQuery to WAM is a B/C break (unless you have a dummy HTMLHelper::jquery that calls the WAM.

HTMLHelper::jquery already already calls the WAM, so no b/c on this, and as sad I would move the jquery htmlhelper to the plugin (not removing it in 5.0). will be an one pr.

regarding jquery 4

if it comes in time I would add it to joomla 5.0 not sure in which form yet.

# Conflicts:
#	package-lock.json
#	package.json
@HLeithner HLeithner added Feature b/c break This item changes the behavior in an incompatible why. HEADS UP labels Apr 7, 2023
@Fedik Fedik mentioned this pull request Apr 17, 2023
4 tasks
@Fedik
Copy link
Member

Fedik commented Jun 23, 2023

In case when people worries about b.c. break due to removed assets. We can keep the asset definations, but empty, with flag "deprecated". And remove all es5 js files.

Example for bootstrap,
Before:

{
  "name": "bootstrap.es5",
  "type": "script",
  "uri": "bootstrap-es5.min.js",
  "dependencies": [
    "core"
  ],
  "attributes": {
    "nomodule": true,
    "defer": true
  }
},

After:

{
  "name": "bootstrap.es5",
  "type": "script",
  "deprecated": true,
  "uri": "",
  "dependencies": [
    "core"
  ],
},

This dummies will save the site when some template use it in unknown reasons.

@dgrammatiko
Copy link
Contributor Author

dgrammatiko commented Jun 23, 2023

We can keep the asset definations, but empty

I was thinking about that as well, so maybe I should update the PR to eliminate any B/C considerations

@Fedik could you review this? I added the deprecated attribute and nullified the src on the es5 scripts

@Fedik
Copy link
Member

Fedik commented Jun 23, 2023

Looks good.

You reverted your original changes or? Because I see that es5 assets used as dependencies

"dependencies": [
"bootstrap.es5"
],

This can be trashed.

@HLeithner
Copy link
Member

I tested this with one of my customer sites with my own template using joomla bootstrap and works as expected, I merge this for now and hope for more real world testing for alpha2

@HLeithner HLeithner merged commit e6518fb into joomla:5.0-dev Jun 24, 2023
@dgrammatiko dgrammatiko deleted the 5.0-dev-drop-es5 branch June 24, 2023 08:55
richard67 added a commit to richard67/joomla-cms that referenced this pull request Jun 24, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Jun 24, 2023
HLeithner pushed a commit that referenced this pull request Jun 26, 2023
* Add deleted files and folders from PRs #39618 and #40147

* Update to changes from PRs #40743 and #40783
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
b/c break This item changes the behavior in an incompatible why. HEADS UP Feature NPM Resource Changed This Pull Request can't be tested by Patchtester PR-5.0-dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants