> is all this trickery on top of a library like this one still needed?
If the library is imported in the way that the article recommends in step two, it's not actually loaded as an ES6 module. This code checks to see if we're currently acting as a module and accordingly makes sure that the library is available as a global object. See this link for some examples: https://devhints.io/umdjs
> I have no idea how to read this ...
I tried to add some comments [0] which will hopefully help!
UMD does _not_ support standard JS module imports. The UMD code won't detect `exports` or `define` and will write to globals instead of producing any exports.
The GP wants to import into JS modules, and you said:
> Yes, this is the point of that code. It's boilerplate to ensure the module loads in different environments.
but the UDM header does not allow the module to load in JS modules. So I'm not quite sure what you meant actually. The header does nothing for standard modules.
They seem to be using Rollup for builds, which supports ESM output, so they wouldn't even need to do any refactoring for that. Couple of configuration changes would suffice.
This is how the Chart.js code begins:
I have no idea how to read this, what this means and how to invoke a construct like this.