The wikimedia/minify PHP library for minification of JavaScript code and CSS stylesheets.
- Browse repository
- Mainly used by MediaWiki-ResourceLoader.
The wikimedia/minify PHP library for minification of JavaScript code and CSS stylesheets.
JavaScript is a highly dynamic language. To safely mangle executable code without breaking runtime execution for arbitrary code, one generally has to have awareness of all code that will be served and awareness of the complete application. This is common for "finished" products, single-page apps, and small projects. This is however not the case for a platform like MediaWiki, where extensibility and collaboration between multiple tennants are key design requirements. For example, extensions and gadgets can define and load additional code at any time, which has to work independently from what loaded before and what will load next.
Hmm. The list of features by JS version I was consulting had class properties as part of ES7. I guess it was inaccurate though. I'll try switching to this reference. Thanks for catching.
Class properties are from ES2022.
Unit test I started writing that ended up catching this. A slimmed down version can be included in the patch if it's helpful.
After T368204: Consider removing new-line insertion from JavaScriptMinifier Minifier adds no new lines. So this one T277675#10046960 should no longer causes problems. We should focus on when new lines are required but ignored by Minifier.
Change #1084719 merged by jenkins-bot:
[mediawiki/libs/Minify@master] JavaScriptMinifier: Remove new line insertion
https://gerrit.wikimedia.org/r/1084719
Change #1084719 had a related patch set uploaded (by Hokwelum; author: Hokwelum):
[mediawiki/libs/Minify@master] remove new line insertion
https://gerrit.wikimedia.org/r/1084719
Change #1080851 merged by jenkins-bot:
[mediawiki/core@master] ResourceLoader: Restore `@nomin` for JavaScript files
https://gerrit.wikimedia.org/r/1080851
T371938 (gerrit 1060177), that you created at the same time, adds (in addition to the previously existing PAREN_EXPRESSION_OP_NO_NL state) EXPRESSION_TERNARY_NO_NL, PAREN_EXPRESSION_NO_NL and PROPERTY_EXPRESSION_NO_NL states. These might help to add support for the remaining async functions.
Change #1080851 had a related patch set uploaded (by Krinkle; author: Krinkle):
[mediawiki/core@master] ResourceLoader: Restore `@nomin` for JavaScript files
https://gerrit.wikimedia.org/r/1080851
Thanks @Trancesilken, that helps.
@Krinkle How about the "test case"? Does it fit your needs?
I have created a test case in form of a composer.json and package.json.
This is a regression that appearss to have slipped in during development for T47514: ResourceLoader: Implement support for Source Maps.
@Krinkle do you have any thoughts on this one ?
How about moving the handling of the @nomin pragma into the minifier itself, i.e. into the minify method?
Change #1065269 merged by jenkins-bot:
[mediawiki/core@master] ResourceLoader: Update wikimedia/minify to 2.8.0
https://gerrit.wikimedia.org/r/1065269
Change #1065268 merged by jenkins-bot:
[mediawiki/vendor@master] Update wikimedia/minify to 2.8.0
https://gerrit.wikimedia.org/r/1065268