Feature NPM Resource Changed PR-5.3-dev Pending

User tests: Successful: Unsuccessful:

avatar dgrammatiko
dgrammatiko
8 Jul 2024

Pull Request for Issue #43714 .

Summary of Changes

Use iife instead of esm for the script core.js and load the script validate.js with a type=module

Testing Instructions

  • Apply the PR
  • run npm install
  • Check that authenticating in the administrator works
  • Create a new article, don't add anything and press save, the validation error should appear

Actual result BEFORE applying this Pull Request

Leaking variables in the global scope

Expected result AFTER applying this Pull Request

NO leaking variables in the global scope

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

@Fedik

avatar dgrammatiko dgrammatiko - open - 8 Jul 2024
avatar dgrammatiko dgrammatiko - change - 8 Jul 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 8 Jul 2024
Category JavaScript Repository NPM Change
avatar dgrammatiko dgrammatiko - change - 8 Jul 2024
Labels Added: NPM Resource Changed PR-5.1-dev
avatar Fedik
Fedik - comment - 8 Jul 2024

This is no go, sorry.

I would suggest to keep for 5.1 the same what you did for 4.4 (will be upmerged).
And set core and validator to type=module for 5.2 as a new feature.

Please, without this huge code move, that you made in core.js.
Just window.Joomla = Joomla; is enough. Having 100 window.Joomla.foobar = .. is very bad idea.
Thanks.

avatar Fedik
Fedik - comment - 8 Jul 2024

If you have a problems with eslint, just add:

/* global Joomla */

At top of the file. Like we have for TinyMCE

avatar dgrammatiko
dgrammatiko - comment - 8 Jul 2024

I would suggest to keep for 5.1 the same what you did for 4.4 (will be upmerged).
And set core and validator to type=module for 5.2 as a new feature.

I don't see any problems with the change from defer to type=module. Let me explain:

  • the defer script in 4.4 has a use strict but with the type=module this is inferred
  • Both defer and type=module load the script as deferred
  • The only difference is that in the 4.4 the class JFormValidator is globally registered but I could attach it to the window and have the same effect.

In sort this change shouldn't be assumed as a breaking change as it isn't

I'll change the window.Joomla refs

avatar Fedik
Fedik - comment - 8 Jul 2024

There no problem to set type=module as it is, however they may be extensions that doing "script optimisation" merging non module scripts etc. It will change behavior slightly, to them.

It is not a big deal, but I would keep it safe, and would not to do such changes in patch release.

avatar dgrammatiko
dgrammatiko - comment - 8 Jul 2024

It is not a big deal, but I would keep it safe, and would not to do such changes in patch release.

I'm willing to take full responsibility for this if the maintainers trust me ?‍♂️

avatar Fedik
Fedik - comment - 8 Jul 2024

Then I leave you to maintainers ?

avatar Fedik
Fedik - comment - 8 Jul 2024

Please add one more globals for window.punycode = punycode; (as it may used by some script).

And then release manages can decide, what to do with the PR.

avatar dgrammatiko dgrammatiko - change - 8 Jul 2024
Labels Added: RMDQ
avatar dgrammatiko
dgrammatiko - comment - 8 Jul 2024

Please add one more globals for window.punycode = punycode; (as it may used by some script).

Done, I guess you could raise this to the maintainers

avatar Fedik Fedik - test_item - 8 Jul 2024 - Tested successfully
avatar Fedik
Fedik - comment - 8 Jul 2024

I have tested this item ✅ successfully on 2c1f421


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

avatar viocassel viocassel - test_item - 10 Jul 2024 - Tested successfully
avatar viocassel
viocassel - comment - 10 Jul 2024

I have tested this item ✅ successfully on 2c1f421


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

avatar alikon alikon - change - 10 Jul 2024
Status Pending Ready to Commit
avatar alikon
alikon - comment - 10 Jul 2024

RTC


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

avatar bembelimen
bembelimen - comment - 10 Aug 2024

Hey @dgrammatiko thanks for this PR. Just to understand, isn't this a B/C break, if someone e.g. made an override of the "old" core/validation script and now it's loaded as a module?

avatar dgrammatiko
dgrammatiko - comment - 10 Aug 2024

No, type=module means:

  • use strict by default
  • Deferred
  • Reduced scope

the reduced scope in this case is irrelevant as the classes are exposed as global vars. In sort there won’t be any issue!

FWIW: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#other_differences_between_modules_and_standard_scripts

avatar bembelimen
bembelimen - comment - 11 Aug 2024

Ok, I just saw, that after the upmerge something similar was done in 4.4, could you (@dgrammatiko ) please check, if the changes were correct and if this PR is still needed? Thank you!

avatar dgrammatiko dgrammatiko - change - 11 Aug 2024
Labels Added: RTC
avatar joomla-cms-bot joomla-cms-bot - change - 11 Aug 2024
Category JavaScript Repository NPM Change Unit Tests Administration com_content com_fields com_finder com_menus com_messages com_redirect com_users Language & Strings JavaScript Repository NPM Change
avatar joomla-cms-bot joomla-cms-bot - change - 11 Aug 2024
Category JavaScript Repository NPM Change Unit Tests Administration com_content com_fields com_finder com_menus com_messages com_redirect com_users Language & Strings JavaScript Repository NPM Change
avatar dgrammatiko dgrammatiko - change - 11 Aug 2024
Labels Added: Unit/System Tests Language Change
avatar dgrammatiko dgrammatiko - change - 11 Aug 2024
Labels Removed: Unit/System Tests Language Change
avatar joomla-cms-bot joomla-cms-bot - change - 11 Aug 2024
Category JavaScript Repository NPM Change Unit Tests Administration com_content com_fields com_finder com_menus com_messages com_redirect com_users Language & Strings JavaScript Repository NPM Change
avatar dgrammatiko dgrammatiko - change - 11 Aug 2024
Labels Added: Unit/System Tests Language Change
avatar joomla-cms-bot joomla-cms-bot - change - 11 Aug 2024
Category JavaScript Repository NPM Change Unit Tests Administration com_content com_fields com_finder com_menus com_messages com_redirect com_users Language & Strings JavaScript Repository NPM Change
avatar dgrammatiko dgrammatiko - change - 11 Aug 2024
Labels Removed: Unit/System Tests Language Change
avatar dgrammatiko
dgrammatiko - comment - 11 Aug 2024

@bembelimen these changes are still better than the code in 4.4. ES modules should be the default way of serving js in 2024...

avatar dgrammatiko dgrammatiko - change - 12 Aug 2024
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2024-08-12 12:29:09
Closed_By dgrammatiko
avatar dgrammatiko dgrammatiko - close - 12 Aug 2024
avatar dgrammatiko dgrammatiko - change - 12 Aug 2024
Status Closed New
Closed_Date 2024-08-12 12:29:09
Closed_By dgrammatiko
Labels Removed: RTC
avatar dgrammatiko dgrammatiko - change - 12 Aug 2024
Status New Pending
avatar dgrammatiko dgrammatiko - reopen - 12 Aug 2024
avatar HLeithner
HLeithner - comment - 2 Sep 2024

I rebased this for 5.2, not sure if this comes to 5.2 or not @bembelimen @Hackwar

avatar HLeithner HLeithner - change - 2 Sep 2024
Title
[5.1][bugfix] Use iife for the scripts core and load validate as module
[5.2] [bugfix] Use iife for the scripts core and load validate as module
avatar HLeithner HLeithner - edited - 2 Sep 2024
avatar Hackwar
Hackwar - comment - 22 Nov 2024

I understand that something similar was added to 4.4 and that theoretically this could go into 5.2, however I feel uncomfortable adding this to a patch release. That's why I'm moving this to 5.3, but I'm also asking @viocassel and @Fedik to re-test and then will merge it into 5.3. Thank you for your work so far.

avatar Hackwar Hackwar - change - 22 Nov 2024
Title
[5.2] [bugfix] Use iife for the scripts core and load validate as module
[5.3] [bugfix] Use iife for the scripts core and load validate as module
avatar Hackwar Hackwar - edited - 22 Nov 2024
avatar Hackwar
Hackwar - comment - 22 Nov 2024

Can you please solve the conflict in the file... ☹️

avatar dgrammatiko dgrammatiko - change - 26 Nov 2024
Labels Added: Feature PR-5.3-dev
Removed: RMDQ PR-5.1-dev
7eed713 26 Nov 2024 avatar dgrammatiko iife
f531bf8 26 Nov 2024 avatar dgrammatiko fixes
40dae7d 26 Nov 2024 avatar dgrammatiko nope
2b6a1f5 26 Nov 2024 avatar dgrammatiko nope
3f95c4b 26 Nov 2024 avatar dgrammatiko cs
8d69dd0 26 Nov 2024 avatar dgrammatiko CS
1389668 26 Nov 2024 avatar dgrammatiko CS
104e36a 26 Nov 2024 avatar dgrammatiko oops
fb26cc6 26 Nov 2024 avatar dgrammatiko what
66de0ab 26 Nov 2024 avatar dgrammatiko cs
6eb0866 26 Nov 2024 avatar dgrammatiko cs
8783aaa 26 Nov 2024 avatar dgrammatiko x
c8fdb85 26 Nov 2024 avatar dgrammatiko fix
avatar dgrammatiko
dgrammatiko - comment - 26 Nov 2024

@Hackwar done

avatar laoneo
laoneo - comment - 29 Nov 2024

Can we have here one more test, just to see if it still works as there were some commits after the rebase.

avatar laoneo laoneo - change - 7 Dec 2024
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2024-12-07 18:18:02
Closed_By laoneo
avatar laoneo laoneo - close - 7 Dec 2024
avatar laoneo laoneo - merge - 7 Dec 2024
avatar laoneo
laoneo - comment - 7 Dec 2024

Thanks!

Add a Comment

Login with GitHub to post a comment