This adds support for ES6 and ES7 syntax to user scripts, thus
matching the wikimedia/minify library.
Bug: T75714
Depends-On: I43d4619a32e37eb42e1aaa55a1f602962609c52b
Depends-On: If3b2b4a75013baeaa0d9b92cd10dfb06e5534153
Change-Id: Ie309e761f8b20640f7c0e85def0a3d1ccc8a658e
* Have FileModule::getScript() always return an array with a filePath
or fakeFilePath, not a string. This allows source maps to be
constructed.
* Make the scripts returned from Module::buildContent() always be an
array. Module::getScript() may still return a string for b/c.
* In makeLoaderImplementScript(), interpret the new plainScripts array.
Factor out the package file normalization loop from
makeLoaderImplementScript().
* Fix missing base path in mediawiki.base.
* Improve relevant doc comments.
Bug: T47514
Change-Id: I392a8cce9a0febc707b6cb17412e3b723c9cc686
This is an intermediate step towards the linked bug, to help untangle
the performance impacts.
Bug: T343407
Change-Id: I086f173f811fb44683f4a67bf6bc415d7e27f593
It's awkward to construct a source map when the file contents is
modified after loading. Delivering deprecation warnings as JS code
seems like an odd convention anyway.
So, send the module deprecation warning as an additional parameter to
mediawiki.loader.implement().
Deprecation warnings are no longer displayed in only=scripts mode.
Remove deprecation tests from FileModuleTest since FileModule no longer
has any relevant deprecation code. Add tests to ModuleTest.
Deprecate Module::getDeprecationInformation().
Bug: T47514
Change-Id: I20938cf4ab78afc9a2d72fbd163a7c5f21755820
Follows-up 2c93649672 (I2b2905d7452bd2), which added the conditional
in order to silently accept case where setName was not called.
getName() is not conditinally accessed elsewhere. It being undefined
would be an error condition on the part of the caller. In this case,
Wikibase forgot to call setName, which I1cc5c54db42ca fixes.
See also ResourceLoader::getModule(), which indicates values that
must be injected in production code. In tests we can sometimes be
lazy and skip a required injection, such as Config and HookContainer,
that we only use in certain methods that perhaps your test doesn't
call. However, upon finding that a test starts exposing such need,
the test need to be updated to provide or mock that value, instead of
tolerating the absence in production code.
This change also fixes a bug in the previous change which would have
theoretically emitted 'all' without the per-module metric, which
would invalidate percentage-based calculations in Graphite as the
total would no longer be equal to the sum.
Depends-On: I1cc5c54db42ca3a9da38ab56cf88cd71dc5b8343
Change-Id: I3c9b7a17b1331750c631b8dc3e9e7ee04d79884f
The UA sniffs that overrode the feature tests are no longer needed.
* MSIE 10: Fine, rejected by feature checks.
* UC Mini "Speed Mode": Redundant, the version that this sniff
matched is pre-ES6. Current versions of UC Mini don't appear to
support enabling "Speed Mode" on random websites nor does it offer
it for Wikipedia specifically.
Details at https://phabricator.wikimedia.org/T178356#8740573.
* Google Web Light: Redundant, shutdown as of 2022.
Any references or extensions that still reach the proxy, get
redirected to our online URLs
https://googleweblight.com/?lite_url=https://en.m.wikipedia.org/wiki/Bananahttps://phabricator.wikimedia.org/T152602https://en.wikipedia.org/wiki/Google_Web_Light
* MeeGo: Redundant, discontinued and presumed rejected.
Either way, unsupported.
* Opera Mini: Fine, rejected by checks.
Details at https://phabricator.wikimedia.org/T178356#8740573.
* Ovi Browser: Redundant, discontinued and presumed rejected.
Either way, unsupported.
* Google Glass: Improve UX (since 2013, T58008).
* NetFront: Redundant. Old versions are presumed rejected.
Current versions are Chromium-based and presumed fine.
The exclusion was not UX based, but due to jQuery explicitly not
supporting it in 2013. This is no longer the case, so we can let
the feature test lead the way here.
* PlayStation: Redundant, same story as NetFront.
The version that matched the sniff is presumed rejected.
Current versions probably fine, but even not, don't match
our sniff so are already enabled today.
Bug: T178356
Change-Id: Ib6263ce3ffd11af5e501de8857f3e48a248c6210
In Ia062ff2d8b8732b0d3498c1a614bbf6a3e3a7ddb, we changed the default
targets to desktop/mobile. This broke CI for PageTriage, which has a RL
module that extends ResourceLoader\Module, and which sets the default
targets for "desktop" only.
I am not sure if leaving ResourceLoader\Module as "desktop" only was a
deliberate choice or an oversight, but it seems to be more consistent to
have it defined as desktop/mobile. This will fix the issue for
PageTriage and other extensions that extend ResourceLoader\Module and
don't have any targets explicitly defined for their RL modules.
Follows-Up: Ia062ff2d8b8732b0d3498c1a614bbf6a3e3a7ddb
Bug: T127268
Bug: T328497
Change-Id: I48ed19912610a74af66d620510c192c7ba87039a
Module::getName() is allowed to return null (and there are some existing
modules where it returns null, such as Wikibase’s SitesModule). Passing
the null name directly into strtr() produces a warning in PHP 8.1, but
more importantly, it will also result in tracking the metric
`resourceloader_build.` without any stat name (under any PHP version).
Fix this by not tracking the individual module in this case.
Bug: T319219
Change-Id: I2b2905d7452bd2694c5c1af3272e0fb0e95ff144
Use early returns to reduce nesting, unhoist variables,
should be a no-op in terms of functionality.
Change-Id: Ic6a63dccb982615b8b3e70aabd059dec70244374
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader itself.
Move the tests by analogy.
I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".
I did not address DependencyStore which continues to have a non-standard
location and namespace.
Revert of a241d83e0a.
Bug: T308718
Change-Id: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
This reverts commit e08ea8ccb9.
Reason for revert: Breaks Phan in extensions, and as far as I’m aware,
this change isn’t urgently needed for anything, so the simplest fix is
to revert it again for now. After PHP 7.4 it should be safer to try this
again (we hopefully won’t need the two “hack” classes by then).
Bug: T308443
Change-Id: Iff3318cbf97a67f821f78e60da62a583f63e389e
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader and
ResourceLoaderContext.
Move the tests by analogy.
I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".
I did not address DependencyStore which continues to have a non-standard
location and namespace.
Change-Id: I92998ae6a82e0b935c13e02a183e7c324fa410a3
2022-05-16 14:41:27 +10:00
Renamed from includes/resourceloader/ResourceLoaderModule.php (Browse further)