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

Feature: Export as module #432

Open
2 tasks done
aehlke opened this issue Sep 5, 2023 · 3 comments
Open
2 tasks done

Feature: Export as module #432

aehlke opened this issue Sep 5, 2023 · 3 comments

Comments

@aehlke
Copy link

aehlke commented Sep 5, 2023

Type of feature

✨ Feature

Current behavior

Can only export as variations of full HTML pages.

Suggested feature

It would be valuable to be able to edit a script which can then be built and exported as a reusable module rather than only as a webpage. In this case, markup/style would either be unneeded or used during dev only for testing integrating the module. I'd like to be able to define some functions that I can then export, host somewhere, and reuse as imports in another livecodes session.

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Contributing Docs

  • I agree to follow this project's Contribution Docs
@hatemhosny
Copy link
Collaborator

There are currently multiple ways to re-use scripts as modules that can be imported in other projects:

I hope this helps.
If you have other suggestions or ideas, I'd be happy to know about.

@aehlke
Copy link
Author

aehlke commented Sep 24, 2023

jsdelivr works well! thank you

My next question is how I could use the outputs of these together with another language, without having them isolated into separate sandboxes. Is there a good way to combine the built JS/wasm outputs together into one HTML file besides statically combining the rendered files outside of livecodes? for example, in order to run both python/pyodide & JS in the same document/frame. I understand it's not the focus of livecodes but maybe there's a simple way to extend it with this behavior. Thanks for your guidance

edit: I'd also like to use jsdelivr.gh: / skypack: prefixes for imports in these modules. How do you also reuse their module maps?

@hatemhosny
Copy link
Collaborator

hatemhosny commented Sep 24, 2023

As you mentioned, running multiple scripts/multi-file projects are out of the focus of LiveCodes.
However, you may use something like the methods described above to "import/re-use" code.

In addition, since you can use HTML, there is nothing that prevents you from adding a script tag there and add the JS code you want.

Example: https://livecodes.io/?x=id/cird58vjmfh (edit: added import from skypack)
In this example, you can increment the same counter from python and from JS code.
Also, module resolution works in script tags added to HTML (the example imports from skypack).

Is that what you mean?

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

2 participants