Thank you, that’s very helpful! Putting my library in the assets/lib folder is helping a lot.
Now that I have the correct path to it, the library is misbehaving. It’s a large library with lots of submodules - argdown.js requires ArgdownApplication.js and a bunch of others. When it tries to load ArgdownApplication.js it says “Uncaught ReferenceError: exports is not defined.”
I’ve tried bundling the whole thing into one file using Webpack, but for some reason the bundle is missing a third-party library called “punycode”. I’ve tried adding punycode into the compiled module, I’ve tried uploading it to the lib folder and adding register_asset 'lib/punycode.js'
to plugin.rb, and I’m not having much luck.
The library works on my computer and in another plugin I’ve written. Is there a recommended way to add an NPM module to a Discourse plugin? This thread says to copy the module’s folder into your /lib/ folder; that’s not working for me.* Can you point me to an example of someone successfully shipping a complex NPM module with a Discourse plugin so I can see what I’m doing wrong?
*In that thread they’re trying to load the module remotely from unpkg.com; I’d rather do it locally, although maybe I should try that.