joomla-cms
joomla-cms copied to clipboard
[5.2] Move to ESM
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
.jsextension instead of.es5.js - Web Components also have
.mjsextension (used to be.w-c.es6.js) - The
build/media_source/system/js/joomla-core-loader.mjsfile now includes the required css and the relatedbuild/media_source/system/scss/joomla-core-loader.scssis deleted
Testing Instructions
You need Git and NPM to test this
Pull the 4.4-dev branch and run:
npm installnpm run cssversioningnpm run gzipnpm run versioning- Store the media folder somewhere outside of the
joomla-cmsfolder
Pull this PR gh pr checkout 43779 and run:
npm installnpm run cssversioningnpm run gzipnpm run versioning- Store the media folder somewhere outside of the
joomla-cmsfolder
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)?
Hey, at least there are clear test instructions 😅
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.
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
Yes please.
It is better to keep them apart, there mostly joomla stuff, nothing standart for package.json
And it really huge.
Ok, done
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.
Why not just use "type": "module" in the package.json instead of using .mjs files?
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:
.mjsmodern js,.jslegacy, iife staff
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.
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)...
Is there any interest on this one or should I close it?
or should I close it?
hold on, not so fast :smile:
This should be something in Joomla! but sorry, not in a Bugfix release. Moved it to 5.2.
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 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!