-
Notifications
You must be signed in to change notification settings - Fork 1
Description
The issue
As of right now - and correct me if I'm wrong, as I'm writing this up only based on what I know about node.js
in general - attempting to do this:
$ git clone https://github.com/lys-lang/lys-compiler.git && cd lys-compiler
$ npm i # <-pretty sure this isn't strictly necessary?
$ make build
$ # assuming the directly `~/.local/bin` exists and is included in PATH
$ install node_module/.bin/lys ~/.local/bin
$ lys
...results in a "bad" binary in the sense that it throws an error1 (and I don't mean the one about a missing input file).
On my system it looks very similar to this (I've replaced the path to my home directory with ${HOME}
):
node:internal/modules/cjs/loader:1412
throw err;
^
Error: Cannot find module './index-bin'
Require stack:
- ${HOME}/.local/bin/lys
at Function._resolveFilename (node:internal/modules/cjs/loader:1409:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1060:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1065:22)
at Function._load (node:internal/modules/cjs/loader:1214:37)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)
at Module.require (node:internal/modules/cjs/loader:1495:12)
at require (node:internal/modules/helpers:135:16)
at Object.<anonymous> (${HOME}/.local/bin/lys:4:21)
at Module._compile (node:internal/modules/cjs/loader:1739:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '${HOME}/.local/bin/lys' ]
}
Node.js v23.6.0
My problem is that lys
should be a standalone binary at best... but to be real with ourselves an/some extra *.so
s/*.dll
s will likely be required. Currently it's very far from that, as I believe to have demonstrated (all this isn't even mentioning the fact it's non-obvious — without looking through node_modules
/doing a find
— where index-bin.js
is even located)
Obviously I'm aware of the fact that an x86/ARM can't execute WASM by itself (😉) which is the crux of the matter here.
My proposition:
- in the long term completely discard
node
as our runtime in lieu of a native one- ex.
wasmtime
is super simple — less than 50 lines of code in Python for ex. is able to spit out a native, AOT compiled ELF/Mach-O binary
- ex.
- for the time being - introduce some kind of a "bundling" step, so that one can just do something to the effect of
install node_modules/**/lys [...]
and have it work- doesn't necessarily have to be 1 file... just not the ~44
.js
files which currently make up thelys/dist
directory (not counting the.lys
files instdlib/
as having separate source files is unavoidable in this case); pack them into some archive duringmake build
, then extract into a temp directory at runtime — that sort of thing
- doesn't necessarily have to be 1 file... just not the ~44
Note:
I may have/have likely made many (many) false assumptions here and am aware of such a possibility. Please do correct any errors in my understanding. Having said that though, none of them take away from my broader point I believe.
Footnotes
-
as does the compilation command
make build
/make lys-build
itself (make lys-test
is... unaffected somehow?), likely due to incompatibilites with node v23. doesn't seem to matter much though as executing./node_modules/.bin/lys
is fine...? ↩