nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.63k stars 1.47k forks source link

Allow configuring js runtime for the compiler #20428

Open sigmaSd opened 2 years ago

sigmaSd commented 2 years ago

Summary

Adding a nim configuration option to choose which javascript runtime to run the js examples with docgen

Description

Currently docgen runs the javascript examples with node, but I want to run it with deno because I depend on Deno apis (when targeting deno) also maybe someone wants to target bun

Currently its hard coded here https://github.com/nim-lang/Nim/blob/1e0165186bb8539cfd8aca1a7af8d01dc278bd46/compiler/nim.nim#L101

I propose adding a configuration option that allows the user to choose the runtime.

Alternatives

No response

Standard Output Examples

No response

Backwards Compatibility

No response

Links

No response

sigmaSd commented 2 years ago

I noticed this also affects nim c -r --backend=js file.nim

sigmaSd commented 2 years ago

My current workaround is to use nimble tasks, for example https://github.com/sigmaSd/deno-nim/blob/master/deno_nim.nimble#L26 and mark the docs with "-r:off", while making nimble docs run them with deno

This allows me to write inline tests/examples image

koaledu commented 9 months ago

I was about to create a new issue but I noticed this exists. It would be amazing to let us use Bun for running the JS transpiler.