Esm: Unexpected behavior of console.log/util.inspect

Created on 10 Aug 2018  路  5Comments  路  Source: standard-things/esm

It seems like esm overrides eval somewhere.
I made a script that create a Map object, add 2 values and then call eval('Map Object created as string');
If I use normal node to execute that script it works just fine and shows the Map with values inside.
However if I use node -r esm to execute that script, it shows the Map as empty;
image
index.js being:
image

This seems to happen for both Map and Set
Is there is any reason it is behaving this way?
I need to see what is inside Map or Set with the eval function so I was surprised to find this out.

bug

Most helpful comment

v3.0.75 is released :tada:

All 5 comments

I don't know for certain, but I don't think that has anything to do with eval, but rather with console.log, and/or util.inspect (not sure how it's been implemented in node internally)

node -r esm

util.inspect(new Map([[1,2]]))  // Map {}

console.log(new Map([[1,2]])) // Map {}

If I try to eval('eval').
I get the following result:
image
If that help?

I only assumed it was eval because of that.

it seems esm is intercepting (proxying) the behavior of console and utils https://github.com/standard-things/esm/blob/master/src/builtin/console.js

I'm sure it can be fixed.

Alright, thanks for the fast answer and clearing my doubt about this issue!
Looking forward for the possible fix :+1:

v3.0.75 is released :tada:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clock157 picture clock157  路  3Comments

tunnckoCore picture tunnckoCore  路  3Comments

ericelliott picture ericelliott  路  3Comments

dnalborczyk picture dnalborczyk  路  3Comments

kherock picture kherock  路  3Comments