How to ship javascript library with plugin?

Sorry for necroing this thread, but this is where Google has brought me. I’ve been trying for a couple of hours to get a JS library to load inside my plugin.

  • In my app’s assets/javascripts folder, I have a file named argdown-core.js.
  • In my plugin.rb file, I’m doing register_asset 'javascripts/argdown-core.js'.
  • In assets/javascripts/discourse-markdown/argdown.js.es6, I’m doing import { argdown } from "argdown-core.js".

I’ve tried lots of variations on the above and I keep getting Uncaught Error: Could not find module argdown-core.js imported from discourse/plugins/Argdown/discourse-markdown/argdown.

Some of the things I’ve tried:

  • Moving the file into various folders
  • Lots of permutations on the import line
  • Putting .es6 on the file extension - other JS files seem to need that to run
  • Putting :server_side at the end of my register_asset line in plugin.rb, since that’s where this should run
  • Looking for other plugins that require third-party libraries - can’t find any that use strategies I’m not using
  • Digging through Discourse’s code to try to understand the bundling system

This is probably simple and there’s something obvious I’m missing. Can anyone help?