Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permit direct module import? #7

Open
Rosuav opened this issue Nov 29, 2019 · 5 comments
Open

Permit direct module import? #7

Rosuav opened this issue Nov 29, 2019 · 5 comments

Comments

@Rosuav
Copy link
Contributor

Rosuav commented Nov 29, 2019

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.

@hugodahl
Copy link
Sponsor

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.

@instafluff
Copy link
Owner

OH! Thank you so much @hugodahl I forgot about this open issue!

@Rosuav
Copy link
Contributor Author

Rosuav commented Jan 23, 2020

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 "<script type=module>" for Comfy, even if they don't do that for their own modules.

@instafluff
Copy link
Owner

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";

@instafluff instafluff reopened this Jan 24, 2020
@Rosuav
Copy link
Contributor Author

Rosuav commented Jan 24, 2020

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants