The wikimedia/minify PHP library for minification of JavaScript code and CSS stylesheets.
- Browse repository
- Mainly used by MediaWiki-ResourceLoader.
- Maintained by MediaWiki-Platform-Team.
The wikimedia/minify PHP library for minification of JavaScript code and CSS stylesheets.
Change #1048590 merged by jenkins-bot:
[mediawiki/libs/Minify@master] JavaScriptMinifier: Add support for `**=` operator (ECMAScript 2016)
I'm proposing this as a maintenance task next quarter to take on between Hannah and Derick (writing and review, respectively).
These are examples of issues that this improvement would have avoided or reduced the priority of:
Change #1048590 had a related patch set uploaded (by Krinkle; author: Krinkle):
[mediawiki/libs/Minify@master] JavaScriptMinifier: Add support for `**=` operator (ECMAScript 2016)
A big thank you to everybody working on this! @Krinkle: I'll follow your recommendation to include the slint-config-wikimedia package, thanks.
Change #1035483 merged by jenkins-bot:
[mediawiki/libs/Minify@master] JavaScriptMinifier: Add support for ES2020 `??` nullish operator
@Phispi To avoid surprises in the future, I recommend running ESLint in your extension. If you already use this, make sure that you set ecmaVersion: 2016 ("ES7") in your ESLint config, which is what MediaWiki 1.39+ supports. There is also the eslint-config-wikimedia package from npm, which would automatically follow other (optional) MediaWiki's code conventions as well. I recommend using the same version as the oldest MW release branch your extension supports: https://github.com/wikimedia/mediawiki/blob/REL1_39/package.json#L24
Currently, JavaScriptMinifier only supports ES2017 tokens. When you try to minify unsupported tokens, it attempts to interpret them and often results in bugs, similar to the one reported.
Change #1035483 had a related patch set uploaded (by Hokwelum; author: Hokwelum):
[mediawiki/libs/Minify@master] Fix line break between `return` and returned value
Change #1027538 merged by jenkins-bot:
[mediawiki/libs/Minify@master] PHPUnit 10: Remove deprecated E_WARNING and E_USER_WARNING in CSSMinTest
Change #1027538 had a related patch set uploaded (by Lgaulia; author: Lgaulia):
[mediawiki/libs/Minify@master] PHPUnit 10: Remove deprecated E_WARNING and E_USER_WARNING in CSSMinTest
Let's continue the discussion on Gadgets in T357197, since it is indeed off-topic (or only tangentially related) to this task.
@Nux Standardisation is not in question. Unlike new Web APIs (such as fetch), which can be polyfilled, or used via a conditional "if" statement, new syntax, if allowed even once, immediately breaks all code in many browsers that we still support. You can complain to upstream TC39 for having introducing features in ES2017 in a way that is backwards-incompatible. When MediaWiki raises its minimum requirement to ES8/ES2017, we will on the same day, raise the ESLint and site script validator to also allow this syntax.
@Nux Standardisation is not in question. Unlike new Web APIs (such as fetch), which can be polyfilled, or used via a conditional "if" statement, new syntax, if allowed even once, immediately breaks all code in many browsers that we still support. You can complain to upstream TC39 for having introducing features in ES2017 in a way that is backwards-incompatible. When MediaWiki raises its minimum requirement to ES8/ES2017, we will on the same day, raise the ESLint and site script validator to also allow this syntax.
There are no plans currently to raise browser requirements to ES8/ES2017 or ES2020 etc. Not likely until browser engines, browser vendors/apps, audience usage thereof catch up.
Well... we did tell people not to do that.. its not called requiresES6 for nothing.
Please, please keep the requiresES6 flag at least until ES8 can be used in scripts. On frwiki, we have scripts that use async/await, and this language feature makes the codes incredibly simpler. We even had codes with the ?. operator, but I rewrote them to avoid using this operator (for now). But the async/await is a must have.
In T277675#9458236, @SD0001 wrote:People have also started using it in production wikis.
In T277675#9458236, @SD0001 wrote:
- async function methods.
I assume this is referring to async methods in classes and/or object literals. But it seems to work? […] Is there a reproducible edge case where it fails?
Change 990374 merged by jenkins-bot:
[mediawiki/libs/Minify@master] Add a few tests for ES2017 features
- async function methods.