Is it possible to make all node modules available when running via pulp repl
? It seems like some only work when invoked via pulp run
.
I'm following the pattern in the Purescript Book: https://github.com/paf31/purescript-book/blob/master/text/chapter12.md
exports.fooImpl = function(onSuccess, onFailure) {
return function() {
require('some-lib').doThing(function(error, data) {
if (error) onFailure(error.code)()
else onSuccess(data)();
}
}
}
Purescript definitions:
foreign import fooImpl
:: Fn2
(String -> Effect Unit)
(ErrorCode -> Effect Unit)
(Effect Unit)
foo:: (Either ErrorCode String -> Effect Unit) -> Effect Unit
foo path k =
runFn3 readFileImpl
path
(k <<< Right)
(k <<< Left)
Now if I hop into a REPL
pulp repl
and try to call my function, I get an error when I try to call the required library. .xxx is not a function
However, if I run via pulp run
everything runs as expected and the node library function is called without issue.
Similarly, if I run a node repl and call the library directly I similarly experience no problems.
Interestingly, not all node libraries have this issue. Built ins like fs
work fine, but third party ones are the ones that have trouble in the repl.
Is there a way to make these libraries available when running in the REPL?