Closed ynohtna closed 7 years ago
I found related issue while writing unit-tests for this, and went a bit deeper with the fix. I believe this should cover your specific use-case and more. If you're still up for it, could you confirm that on current master
things look fine?
Thanks for your help!
It's a great fix. Thank you!
I've been interactively testing my interoperation of eslisp with bog standard JS within a Node REPL.
However, macros can not be defined within this environment due to the assumption that
require.main
will always be valid made at https://github.com/anko/eslisp/blob/master/src/built-in-macros.ls#L404-L423 ("hack around require makes loading macros from relative paths work").require.main
isundefined
when eslisp (or any module) is imported interactively into the Node REPL. Evaluating any macro within eslisp within the REPL environment results in the following exception:The change in this PR calls
env.compile-to-js
with Node's globalrequire
whenrequire.main
isundefined
, allowing macros to be used within the REPL, and with relative imports based at the folder where the Node REPL was executed.