https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43622

--- Comment #1 from Jonathan Druart <[email protected]> ---
Created attachment 206668
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=206668&action=edit
Bug 43622: Prevent plugin UMD scripts from conflicting with RequireJS

The advanced cataloguing editor (cataloguing/editor.pl) loads RequireJS.
Plugin JavaScript injected via intranet_js is loaded afterwards with plain
script tags. UMD bundles detect define.amd and register themselves as
anonymous AMD modules instead of setting their global, which makes
RequireJS throw "Mismatched anonymous define() module" and leaves the
plugin code without the library it expects.

This patch hides define.amd while plugin JavaScript is loaded, and
restores it afterwards. define itself is kept so the editor's own
asynchronously loaded modules keep working.

Test plan:
1. Install a plugin that loads a UMD library from intranet_js
   (e.g. the "Ask the manual" plugin, which uses typesense-docsearch)
2. Go to Cataloguing > Advanced editor (cataloguing/editor.pl#catalog/4)
3. Notice the JS errors in the console:
   "Mismatched anonymous define() module" and "docsearch is not defined"
4. Apply this patch
5. Reload the page
6. No more JS errors, the plugin works and the editor loads the record

Co-Authored-By: Claude Opus 5.5 <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to