Add js global classes to be injected in the vm context #14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
I had a problem with some code on the repl calling the node core api
https://groups.google.com/d/msg/clojurescript/znsyTrAyplw/5J_NY0uo8oUJ
It would appear that the JS classes like Error (and I guess it happens the same with Array, Object, etc.) are different in the vm and in the node core context, so when getting results from core apis like fs the constructors aren't the same leading to some problems in clojurescript where those are checked/used (
instance?
type
and thejs->clj
functions for example).Example:
(The last false should be true?)
A solution proposed by David would be to inject also those classes into the vm's context in here:
https://github.com/bodil/cljs-noderepl/blob/master/cljs-noderepl/src/cljs/repl/node_repl.js#L7
So I've added them to contextProperties:
I've taken into account the line that checks
hasOwnProperty
, I've tried it on the repl and it seems that even those properties are not listed when printing the object they are actually there (so all good):I've tried using checkouts in a local example repo after doing
lein install
in my fork, but I'm not sure if I'm using the modified version and in the repl I get the same (incorrect) behavior...I'm a super noob so If you could point me to how to check it myself or check if the behavior is corrected it would be great.
Cheers