[00:27:04] This again. `InvalidArgumentException: A module may not set both 'scripts' and 'packageFiles'` -- Hmmm, 44 hours ago I was discussing about this in Discord and mentioned https://doc.wikimedia.org/mediawiki-core/master/php/ResourceLoaderFileModule_8php_source.html and https://mediawiki.org/wiki/Release_notes/1.35 [00:32:36] In my extension.json, I replaced {"ResourceModules": {"ext.photoSwipe": {"scripts": "ext.photoSwipe.js"}}} with {"ResourceModules": {"ext.photoSwipe": {"packageFiles": ["ext.photoSwipe.js"]}}} but I don't know what to look for that is different. [01:07:16] Damn. I am lost again. Okay, so, 1) PhotoSwipe/extension.json, 2) Hooks->BeforePageDisplay (this hook runs before any others), then... 3) I still have no idea how this connects to do anything with ResourceModules->ext.photoSwipe->packageFiles: [ "ext.photoSwipe.js" ] (because this JS file,the contents never run [01:08:10] I even tried creating duplicate "ext.photoSwipe.js" files with different console.log('text') lines to figure out which one of them is the right path,and none of them are running. [01:09:14] "By default the first JavaScript file in the packageFiles array will be considered the module's main file (or "entry point")." (there is only 1, so it should be the entry point [01:10:01] I don't even know what "entry point" means given that I have not observed any entry-like activity [01:11:18] and a couple days ago I had the JS script working somehow using "scripts" but I can't even get that to work anymore either [02:12:07] Aha! In hook BeforePageDisplay, the PHP function called, if I add `$out->addModules( 'ext.photoSwipe' );` then the "packageFiles" main script runs! [02:12:57] so then instead of PHP preparing the scripts to generate JS to deliver to the client, PHP no longer has the environment to do so? [02:13:42] I guess after var PhotoSwipe = require('./lib/photoswipe-lightbox.cjs.js'); then I'll have to convert the PHP to JS to generate what PHP did instead [03:50:29] ryzenda: I suppose this is more of a general JavaScript and web server development question at this point. Glad to figured it out :) [03:52:38] You can prepare data in PHP and send it along, either from a virtual file within the same module if the data is the same on all pages, or if what you need to give the script varies on a per-page or per-user basis you can do it from BeforePageDisplay by calling addJsVars and then retrieve it via mw.config.get [03:59:04] It seems that the path in `var PhotoSwipeLightBox = require('./lib/photoswipe-lightbox.cjs.js'); is not correct. "Error: Cannot require undefined file lib/photoswipe-lightbox.cjs.js" The JS script path generating this error message is https://domain.com/w/load.php which suggests that ./lib/photoswipe-lightbox.cjs.js would imply that the path is https://domain.com/w/lib/photoswipe-lightbox.cjs.js but that is not correct. [04:04:37] This path works though https://domain.com/w/extensions/PhotoSwipe/modules/ext.photoSwipe/lib/photoswipe-lightbox.cjs.js [04:05:16] So then this should work `var PhotoSwipeLightBox = require('./extensions/PhotoSwipe/modules/ext.photoSwipe/lib/photoswipe-lightbox.cjs.js');` [04:08:23] damn, even that doesn't work [04:13:23] What? I am so confused! Even specifying the full entire path doesn't work? That's impossible! `var PhotoSwipeLightBox = require('https://moasspedia.org/w/extensions/PhotoSwipe/modules/ext.photoSwipe/lib/photoswipe-lightbox.cjs.js');` <-- This should work! No? I can access the JS file contents visiting the path directly. Error is: "Error: Module "https://moasspedia.org/w/extensions/PhotoSwipe/modules/ext.photoSwipe/lib/photo [04:13:23] swipe-lightbox.cjs.js" is not loaded" [04:26:51] Aha! I figured it out! [04:27:13] I need to include more than one JS file in "packageFiles" array [04:29:41] but if I don't want to include ALL THE INDIVIDUAL JS FILES, and want to customize loading only 1 of them, or a few of them, JSON can't have JS logic inside it [04:41:32] Oh, I suppose I should add 10 or so individual modules to "ResourceModules" in extension.json, each module with a single "packageFiles" script associated with it, and then use php logic to figure out which ones to load or not [04:43:20] 6 files (excluding the 4 already minified js files) [04:54:50] Oh crap! So, if I use separate modules, which also have their own separate directories, then the subdir "lib" in each one will be separate/isoolated from each other [04:55:39] but maybe I can use ../othermodulename/lib/filename.js [04:59:59] ugh! and back to the same problem of cannot require undefined file if the file is not referenced in the same module, even if a different module already loaded the file for all the modules to use the file [05:35:52] mediawiki-1.37.2]$ grep -r "build-lib" includes/ resources/ ---- 0 results! How does an extension automatically execute the "build-lib" script for end users that use an extension that requires this process to execute to build dependenies for the extension to function correctly? [05:38:02] something about using Grunt task runner for complex build processes, but for end users that don't know about grunt or using it, then what? [13:22:45] ryzenda: you run "npm run build-dev" and add the resit to your repository [13:22:53] End users don't factor into it [13:23:20] Or build-lib. I just suggested it as name for your command [13:23:30] It can be called anything [13:23:50] { scripts: { foo: command } } [13:24:01] npm run foo, will run that command [13:24:34] you could also run the curl /esbuild command once yourself and not specify it in package.json [13:25:03] I suggested putting it there as a way of leaving it as a trace for your future self to ease updating to a new version [13:26:11] End users of the extension just add the extension to their wiki and enable it. They won't need git npm or anything else [13:27:43] You mentioned earlier that you had created git repositories for several files. That's fine, but it sounds unusual and might be making things more complicated. It might be part of the problem at this point. [20:19:54] I feel like MW with php 8.0 uses more CPU time than with 7.4 [20:20:05] like twice as much [20:21:50] 04th was when I switched MW to 8.0: https://i.koumakan.jp/2022-04-20/1650486088.png [20:24:06] https://www.mediawiki.org/wiki/Template:MediaWiki_PHP_8 [20:24:30] per "MediaWiki is not yet compatible with PHP 8. See task T248925 for more information." it's interesting it works at all [20:24:30] T248925: Make MediaWiki compatible with PHP 8 - https://phabricator.wikimedia.org/T248925 [20:27:06] there are a known couple incompatibilities but there are several people who have it functioning on php8 [20:27:41] Remilia: maybe https://haydenjames.io/php-8-compatibility-check-and-performance-tips/#anchor-2 could help (check of opcache is enabled etc) [20:28:31] mutante: I follow that task [20:28:50] also without opcache it would be hitting load avg of 5-6 [20:37:55] mutante: that's mostly because we've not tested it in anger [20:38:04] It should mostly work [20:38:17] Fandom have, IIRC [20:38:27] We've fixed most of the big issues, so it should definitely run [20:38:31] As for perf... Who knows [20:38:56] Remilia: Ofc if you can narrow it down some... bug reports appreciated etc [20:41:10] mutante: The other big thing... is CI mostly isn't running PHP 8.0 against MW due to vendor dependancies [20:41:46] Reedy: ACK, good to know [20:41:55] > that's mostly because we've not tested it in anger [20:41:58] lmao [20:42:04] on wikipedia == in anger :P [20:42:13] oh great, good to know you're always mad at us :( [20:42:34] if we can't blame the users... [20:42:44] :upside_down: