Page MenuHomePhabricator

ResourceLoader: Support CoffeeScript in MediaWiki:Common.js (and such)
Closed, DeclinedPublic

Description

While I understand there are as many people hating coffeescript as loving it, I think it could be a nice idea to allow linking directly to coffeescript files, which are processed into javascript on save

See http://coffeescript.org/ for more information.

Example:

instead of typing

$(function(){
  $(".foo").click(function(e){
    this.html("hello");
  });
});

you type:

$ ->
  $(".foo").click (e) ->
    @html "hello"

Details

Reference
bz38236

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:00 AM
bzimport added a project: MediaWiki-JavaScript.
bzimport set Reference to bz38236.
bzimport added a subscriber: Unknown Object (MLST).
AzaToth created this task.Jul 7 2012, 8:21 PM

Can you be more elaborate in what you're requesting?

How is this a request for MediaWiki core javascript? How do you see this working?

Perhaps this could be an idea for an Extension that extends Gadgets, but I'm not sure how this fits in core. Unless it would be a feature in to ResourceLoader.

cc-ing Roan.

brion added a comment.Jul 9 2012, 9:24 PM

I suppose you could have a filter in ResourceLoader that loads coffeescript modules by transforming them to JavaScript (shell out to converter or something?) Not sure how best to implement such a thing.

It would have to perform *very* well to be acceptable in ResourceLoader because of the high standards in performance and on-demand package generation.

If that level cannot be reached, this should likely become part of your build process and instead refer to the build dir from the module definition. This would at least work on the short term (as in, right now).

matmarex renamed this task from Allow direct usage of coffeescript in addition to normal javascript to ResourceLoader: Support CoffeeScript in MediaWiki:Common.js (and such).Dec 31 2014, 9:30 PM
matmarex updated the task description. (Show Details)
matmarex edited projects, added MediaWiki-ResourceLoader; removed MediaWiki-JavaScript.
matmarex set Security to None.
matmarex removed a subscriber: Unknown Object (MLST).
matmarex added a subscriber: matmarex.

Related: T56864.

Ricordisamoa added a subscriber: Ricordisamoa.
Ltrlg added a subscriber: Ltrlg.Jan 1 2015, 10:58 AM
He7d3r added a subscriber: He7d3r.Jan 3 2015, 3:07 PM
Krinkle lowered the priority of this task from Low to Lowest.Jan 8 2015, 11:14 AM

Performance and scalability aside, I don't expect Wikimedia to adopt CoffeeScript. And providing it as an option to gadgets wouldn't make sense. It'd only be burden for users to have to learn about its features (and bugs) when dealing with maintenance. CoffeeScript doesn't introduce any new features, so this isn't a blocker for development.

Note that several of the larger gadgets and libraries are maintained outside the wiki and imported upon deployment/release (e.g. GitHub). This allows convenience of review, testing and also concatenation/compilation. And even if it is stored solely on a wiki page, one can still have a .coffee and .js page and transform manually when updating the gadget.

The same used to be done for minification (many user scripts still do that manually as they aren't loaded by ResourceLoader).

Krinkle closed this task as Declined.May 8 2017, 12:58 AM