Last modified: 2014-06-12 04:09:16 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T68390, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 66390 - ResourceLoader: Modules should be able to specify dependencies evaluated at run-time
ResourceLoader: Modules should be able to specify dependencies evaluated at r...
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
ResourceLoader (Other open bugs)
1.24rc
All All
: High enhancement (vote)
: 1.24.0 release
Assigned To: Krinkle
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-06-09 19:27 UTC by James Forrester
Modified: 2014-06-12 04:09 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description James Forrester 2014-06-09 19:27:20 UTC
Sometimes modules have dependencies that can't be determined until runtime; most obviously, code that requires shims for browser functionality that may be missing on a few clients.

It would be great if instead of static dependencies, modules could specify dependencies that are evaluated at run-time and only loaded if needed.
Comment 1 Gerrit Notification Bot 2014-06-09 19:27:52 UTC
Change 135085 had a related patch set uploaded by Jforrester:
[WIP] resourceloader: Implement "skip function" feature

https://gerrit.wikimedia.org/r/135085
Comment 2 Krinkle 2014-06-09 19:51:18 UTC
Per discussion between Roan and me we're taking this use case as a story rather than a specific call to implementation.

We won't be adding a feature to conditionally declare something as a dependency. So the following will not be the how it is used:

visualeditor.dependencies = [es5]
->
visualeditor.dependencies = function (deps) {
  if ( browser doesn't support es5 ) {
    deps.push( es5);
  }
};


Instead we're going to take it the other way around and have the condition be on the target module (e.g. es5.js instead of visualeditor).

visualeditor.dependencies = [es5]
es5.skip = function () {
  return browser supports es5;
};

This way will result in much less duplication, and feels more semantically correct because it doesn't make sense for an application to have a dependency that can change. Modules are supposed to be a canonical representation of an interface, not a specific implementation, skin, language or file. Either the module to provide it or it doesn't. Instead visualeditor (or indeed, oojs) would declare it needs the thing that es5-shim.js provides. And es5-shim can decide to forego fetching of any actual files if it detects the environment has it already (either by native or another polyfill).

This will make the experience for developers much easier (no need to duplicate if -conditions for es5 all over the place) and practically removes any possibility of abusing this feature for implementing any bad ideas.
Comment 3 Gerrit Notification Bot 2014-06-12 04:08:13 UTC
Change 135085 merged by jenkins-bot:
resourceloader: Implement "skip function" feature

https://gerrit.wikimedia.org/r/135085

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links