-
Notifications
You must be signed in to change notification settings - Fork 12
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
Interop with Node/CommonJS module system when compiling to JS #4
Comments
I think it's desirable to have interop with JS libraries as much as we can without changing the language semantics! Are you interested in any specific libraries, or more importantly any specific ways of interacting with those libraries? In the simplest case, if you have JavaScript code loaded into a browser window you can access them as normal global variables in the Oak code. Calling into/out of JS functions from Oak should mostly "just work", though you may occasionally have to call a If you're asking about something more like interop with a JS toolchain like webpack so that you can import from/export to JS.... that feels like a big can of worms 😅 Down to discuss to see if there's a way to make it work, but I think the tradeoffs become more questionable there. |
Yes, I was mostly thinking of libraries like puppeteer (and, to a certain extent, chalk) which I use(d) quite a bit when I scripting with node. I don't particularly care about exporting to node - oak feels perfect for small tools, and I was more interested in using the few npm libraries I used frequently working in it. That's also why I was wondering if it would be desirable to do this, since the npm ecosystem is great, but maybe that's not what "server-side" oak is supposed to be. |
Ah, I see. I believe what you're asking is whether there's a good way/workflow to have Oak code that (by compiling to target Node.js as the runtime) can interop with NPM libraries on the server-side? I don't think there's any fundamental reason that this can't be a goal of the project. I think:
The other consideration here is that right now "compile to JS and then run with Node" is not a single command you can run, you have to do something messy like compiling to a temporary file and then giving that to Node to run. It might be nice to have TLDR Since Oak-to-JS currently emits good JS code, I think it's just a matter of making import/export work within Node's CommonJS module system. Doable, though I don't have bandwidth at the moment. I'll keep this open for when I get some time to hack on Oak (or in case someone else wants to try it). |
Given that oak can be transpiled to js, is it:
to allow interop with js libraries?
(Sorry if this is the wrong place to put this - if this is better asked in another place or a discussion thread, please let me know 🙇♂️)
The text was updated successfully, but these errors were encountered: