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

Support Node.js and Native #631

Open
armanbilge opened this issue Feb 28, 2022 · 3 comments
Open

Support Node.js and Native #631

armanbilge opened this issue Feb 28, 2022 · 3 comments

Comments

@armanbilge
Copy link
Contributor

Serializing this Discord discussion. Linking to scala-native/scala-native#2529.

I initially asked if it would be possible to support running Scala.js in Node.js for a (static) output more similar to JVM (as an alternative to the current mdoc.js which generates JS files for embedding in a webpage and running in the browser).

@olafurpg replies:

If we make it work then it would probably unlock native support as well. Requires the same IPC infrastructure

If you design a main method that reads serialized input from a file or stdin, and prints the evaluated output to a file or stdout, then you’ve drawn most of the owl already

the biggest change that I anticipate is that we'll need a way to serialize the mdoc-runtime Document class

final case class Document(instrumented: InstrumentedInput, sections: List[Section])

we may need to add constraints to the T type parameter on the Binder class
But it's maybe not necessary if we just stick with PPrint

final class Binder[T](val value: T, val name: String, val tpe: TPrint[T], val pos: RangePosition) {

@Atry
Copy link

Atry commented Feb 1, 2023

Also it would be nice if a code snippet could have multiple modifiers. For example, executing the Scala.js in Node.js and printing the output, while allowing the reader to interact with the HTML UI in a browser.

@armanbilge
Copy link
Contributor Author

For example, executing the Scala.js in Node.js and printing the output, while allowing the reader to interact with the HTML UI in a browser.

@Atry hm, I'm not sure I understand. It's highly unlikely that some Scala.js would be able to run in both Node.js and in browsers. If it involves HTML, it won't work in Node.js (no DOM APIs). If it doesn't involve HTML, then there's nothing to interact with in the browser. /shrug

@Atry
Copy link

Atry commented Feb 1, 2023

It's common to use jsdom in Node.js for testing purpose.

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