Load an NPM module


#1

https://actions.getdrafts.com/a/1Et

Won’t work for everything, obviously, but let me know if a basic code package isn’t loading.


#2

That’s pretty nifty. I can see this being a potential performance issue to load the library from the web every time it’s used in an action, but likely not too noticeable for smaller modules.


#3

Yeah, it ends up being just a single text .js file served from a fast cdn, usually a half-second to run. Loading one module that recursively loaded about 10 others only took 3-4 seconds. But still yes, best just for small utility packages.


#4

If you wanted to get fancy, you could extend it by saving the download to a local cache file with FileManager.write, and load that version if it exists.