2.1.55 introduced “import/export improvements,” per the changelog. Unfortunately, it seems the ability to export javascript files with a deck .apkg was unintentionally lost. This is not mentioned in the changelog, but is new as of 2.1.55 qt5.
Tested this with a collection containing a .js file in collection.media.
Prior to 2.1.55 (i.e. in 2.1.54), exporting the deck to an .apkg would include any files in collection.media.
From 2.1.55+, the javascript files are not exported to the .apkg file (but .css and any other images in collection.media are, as expected)
To include javascript files in 2.1.55+, it seems like you have to export the entire collection .colpkg.
This is problematic because we have a .apkg containing our custom note type, which previously allowed for easy updating of the note type. For now I’ve downgraded to 2.1.54 so I can export my note type containing the .js file in collection media.
Should add the javascript file is appended with a “" to avoid checking. Even with the prepended "”, the file was being exported to .apkg files prior to 2.1.54. Should also mention it works correctly in <= 2.1.54 when exporting just a single deck (do not need to export all decks).
Removing the prepended “_” does not change the behavior in 2.1.55; the .js file is still not exported.
CSS and image files with the prepended “_” are being exported normally in 2.1.55+.
We were using the template detailed by @kleinerpirat in a post from 2021…except I just realized our import was called directly in the body of the as opposed to being nested within a function.
Nesting it within an async function, as detailed in that thread, seems to have fixed the problem and now the .js file is exported correctly.
That post you referenced is a bit dated - I was enthusiastic about finding a way to import librairies, but it definitely isn’t the easiest or most reliable method.
The way I do it today is to include a <script src="_my-script.js"> tag in the card template that initializes the rest of the functionality.