joomla-cms icon indicating copy to clipboard operation
joomla-cms copied to clipboard

[5.2] Move to ESM

Open dgrammatiko opened this issue 1 year ago • 16 comments

Pull Request for Issue # .

Summary of Changes

  • Move tools and source JS to ESM
  • ES6 files have now the extension .mjs (used to be .es6.js)
  • Legacy js files now have a .js extension instead of .es5.js
  • Web Components also have .mjs extension (used to be .w-c.es6.js)
  • The build/media_source/system/js/joomla-core-loader.mjs file now includes the required css and the related build/media_source/system/scss/joomla-core-loader.scss is deleted

Testing Instructions

You need Git and NPM to test this

Pull the 4.4-dev branch and run:

  • npm install
  • npm run cssversioning
  • npm run gzip
  • npm run versioning
  • Store the media folder somewhere outside of the joomla-cms folder

Pull this PR gh pr checkout 43779 and run:

  • npm install
  • npm run cssversioning
  • npm run gzip
  • npm run versioning
  • Store the media folder somewhere outside of the joomla-cms folder

Compare the two folders. The only difference should be the missing files: media/system/css/joomla-core-loader.css, media/system/css/joomla-core-loader.min.css, media/system/css/joomla-core-loader.min.css.gz

Check the basic backend functionality

Actual result BEFORE applying this Pull Request

Expected result AFTER applying this Pull Request

Link to documentations

Please select:

  • [x] Documentation link for docs.joomla.org:

  • [x] No documentation changes for docs.joomla.org needed

  • [x] Pull Request link for manual.joomla.org:

  • [x] No documentation changes for manual.joomla.org needed

@Fedik @richard67 could you please test this one (pretty hard for the average tester)?

dgrammatiko avatar Jul 13 '24 06:07 dgrammatiko

image

Fedik avatar Jul 13 '24 17:07 Fedik

Hey, at least there are clear test instructions 😅

dgrammatiko avatar Jul 13 '24 17:07 dgrammatiko

I would keep settings.json as it is now. To avoid bloating of package.json.

Other than that, the PR seems working, node comands still working.

Fedik avatar Jul 16 '24 16:07 Fedik

I would keep settings.json as it is now. To avoid bloating of package.json.

It can be reverted, although personally I see that the settings in the package is easier than searching for some file that all the settings are stored. Anyways not too strong opinion here, I would revert it

dgrammatiko avatar Jul 16 '24 16:07 dgrammatiko

Yes please. It is better to keep them apart, there mostly joomla stuff, nothing standart for package.json

And it really huge.

Fedik avatar Jul 16 '24 16:07 Fedik

Ok, done

dgrammatiko avatar Jul 16 '24 16:07 dgrammatiko

I have tested this item :white_check_mark: successfully on 46da720128be4f744313c2d560ecfcba41a3afdc


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

Fedik avatar Jul 17 '24 11:07 Fedik

Why not just use "type": "module" in the package.json instead of using .mjs files?

C-Lodder avatar Jul 19 '24 13:07 C-Lodder

instead of using .mjs files

Couple reasons:

  • existing common js files will need to be renamed to .cjs
  • most important, this simplifies the whole thing: .mjs modern js, .js legacy, iife staff

dgrammatiko avatar Jul 19 '24 13:07 dgrammatiko

Oh you still have CJS. Fair enough. I don't understanding mixing .cjs, .mjs and .js in 2024, as Node.js has supported ES Modules for ages.

C-Lodder avatar Jul 19 '24 15:07 C-Lodder

I don't understanding mixing .cjs, .mjs and .js in 2024, as Node.js has supported ES Modules for ages.

Actually what I'm doing here is using the mjs/js extensions as a convention for the tools.

Could it be done with just the js extension? Sure by using some prefix like we did .es6.js but since these are the source files (not deliverables) it's up to the maintainers to choose their poison (the point is that I've eliminated one case here the .w-c.js, now covered by .mjs) a 3 letter extension (mjs) or a 6 one (es6.js). FWIW .mjs is totally supported by node (actually was invented for cases where there were more than ESM files, ie current Joomla's case)...

dgrammatiko avatar Jul 22 '24 20:07 dgrammatiko

Is there any interest on this one or should I close it?

dgrammatiko avatar Jul 27 '24 12:07 dgrammatiko

or should I close it?

hold on, not so fast :smile:

Fedik avatar Jul 27 '24 13:07 Fedik

This should be something in Joomla! but sorry, not in a Bugfix release. Moved it to 5.2.

bembelimen avatar Aug 11 '24 11:08 bembelimen

Ok, I reduced the changes only to the tools. The source folder needs coordination as any conflicts are painful to be fixed. I'm ok with doing the work if the maintainers accept the changes and coordinate the RL so I don't have to fight unmerges etc...

dgrammatiko avatar Aug 11 '24 14:08 dgrammatiko

@dgrammatiko please reset the changes in settings.json, as I see it is only formating, I do not realy want it to affect the history. Thanks!

Fedik avatar Aug 12 '24 12:08 Fedik