NPM Resource Changed RMDQ PR-5.1-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
42b9ba9 11 Aug 2024 avatar dgrammatiko iife
88b64b0 11 Aug 2024 avatar dgrammatiko fixes
d67cdda 11 Aug 2024 avatar dgrammatiko nope
23d5582 11 Aug 2024 avatar dgrammatiko nope
9a782f6 11 Aug 2024 avatar dgrammatiko cs
avatar dgrammatiko dgrammatiko - change - 11 Aug 2024
Labels Removed: Unit/System Tests Language Change
a9fa83a 11 Aug 2024 avatar dgrammatiko CS
509eafd 11 Aug 2024 avatar dgrammatiko CS
1ff2313 11 Aug 2024 avatar dgrammatiko oops
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...

4ffc43c 11 Aug 2024 avatar dgrammatiko what
db81fb9 11 Aug 2024 avatar dgrammatiko cs
d3b6e86 11 Aug 2024 avatar dgrammatiko cs
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

Add a Comment

Login with GitHub to post a comment