The error string "Module "jquery" is not loaded" actually comes from
mw.loader.require,
unlike the "Unknown dependency: jquery" error which can come from
mw.loader.load.

It looks like the "masonry.pkgd.js" script is detecting a
CommonJS-compatible environment
and therefore assumes jQuery must also be available through require().

ResourceLoader in MediaWiki only recently added support for module.exports
and require.
While it is available, it is not yet the default for most modules,
including jQuery.
However, this assumption is reasonable and actually fairly common in
libraries so we should
definitely add support for it. Either that, or we need a way for registered
modules to opt-out
of having require/module.exports available, so that libraries such as these
can be loaded
without problem.

-- Timo


On Tue, Apr 18, 2017 at 4:04 PM, James Montalvo <[email protected]>
wrote:

> No jquery dependency specified. I put together a minimal extension to
> demonstrate the issue. Below is a link to the comparison of the first
> commit (using ResourceLoader) and the second (using OutputPage::addScript).
>
> https://github.com/jamesmontalvo3/JustMasonry/compare/ResourceLoader...
> addScript
>
> On the `ResourceLoader` branch I get the 'Module "jquery" is not loaded'
> error. On the `addScript` branch I do not, and I'm able to use the library
> like:
>
> var test = new Masonry("#bodyContent");
>
> OS:
> CentOS Linux release 7.3.1611
>
> Installed software:
> MediaWiki 1.27.2 (1c409c5)
> PHP 5.6.30 (apache2handler)
> MariaDB 5.5.52-MariaDB
> ICU 50.1.2
>
> Skins:
> Vector – (d11a80a) 12:02, 19 May 2016
>
> Extensions:
> JustMasonry 2017.4.18 (68bcd0a) 17:47, 18 April 2017
> I removed all other extensions and confirmed this is still an issue.
>
> Thanks,
> James
>
> On Tue, Apr 18, 2017 at 1:51 PM, Legoktm <[email protected]>
> wrote:
>
> > Hi,
> >
> > On 04/17/2017 02:17 PM, James Montalvo wrote:
> > > Uncaught Error: Module "jquery" is not loaded.
> >
> > Does your module definition have a dependency on 'jquery'? You should
> > remove that as it will cause errors like this. jQuery is always loaded
> > before any other RL modules are.
> >
> > -- Legoktm
> >
> > _______________________________________________
> > Wikitech-l mailing list
> > [email protected]
> > https://lists.wikimedia.org/mailman/listinfo/wikitech-l
> _______________________________________________
> Wikitech-l mailing list
> [email protected]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to