-
Notifications
You must be signed in to change notification settings - Fork 159
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
std.loadscript() equivalent #449
Comments
What do you need it for? Why not import a module directly? Or are you using the REPL? |
I’m currently experimenting with tjs run. Std.loadscript() is able to load scripts that would typically be in a html <script> tag, for example babel-standalone. |
Sorry I might be a bit obtuse but I still don't get the use case. There is no HTML here, so you can write a script that imports another. Perhaps an example would help. |
One example would be existing shims and pollyfills that can't be resolved using import. Not all useful javascript is distributed as a module. My reference to html is more a matter of a browsers javascript enfornment and how javascript is loaded into browser environments. This is the closest environment to quickjs as opposed to the standard server environments. "Browser" scripts which are not modules are loaded into the browser using <script src="baz"> which interprets everything at the global level. Such files can only be loaded into quickjs using std.loadscript(). |
It's basically the equivalent of dynamically creating a script tag in the dom in order to load a script from within a script. |
Gotcha. I think you could have a helper that uses tjs.readFile and then uses indirect eval() to evaluate it. That's how loadFile is implemented in qjs. |
Does txiki.js have the equivalent of quickjs's std.loadscript()?
The text was updated successfully, but these errors were encountered: