ComfyJS
ComfyJS copied to clipboard
Permit direct module import?
Currently, ComfyJS is available either by copying it to your own project, or using NPM. If this repo had GitHub Pages active, it could also be available as:
import ComfyJS from "https://instafluff.github.io/ComfyJS/dist/comfy";
or equivalently:
<script type=module src="https://instafluff.github.io/ComfyJS/dist/comfy"></script>
I'm okay with copying an MIT-licensed file into my own project from a licensing perspective, but it means that any project using this is going to be frozen in time, upgrading only when it's explicitly redownloaded.
Hey @Rosuav! Don't know if this is still an issue or something you're needing, but if so, @instafluff added some details in the README on using the jsdelivr.net CDN.
So to use it in the manner you mentioned, you'd just need to use https://cdn.jsdelivr.net/npm/comfy.js/dist/comfy.min.js
as the URL.
OH! Thank you so much @hugodahl I forgot about this open issue!
Ah, cool. Thanks. It still can't be directly imported into the local namespace due to compatibility difficulties across the multiple use-cases, but I can at least remove it from my repo.
Would be awesome if it could actually be imported directly, but that would probably break compatibility with non-module usage. At very best, it would require non-module users to say "
Does GitHub pages do something special to enable modules or does something like this work through the CDN?
import ComfyJS from "https://cdn.jsdelivr.net/npm/comfy.js/dist/comfy";
No, it would mean a small change to the code, I think, but I'm not 100% sure how to do it in a way that wouldn't break other usage.
The easiest and cleanest way is to disallow non-module use, which means that anyone using it in a script tag needs to say type="module"
(but then it can still attach itself to the window object). I'd be curious how Babel would attempt to do multi-paradigm export, if it can.
In order to make that export line work, there needs to be an export named "default".