standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.26k stars 146 forks source link

Esm with --inspect causes empty objects to be logged #824

Open cathrinevaage opened 5 years ago

cathrinevaage commented 5 years ago

When you use the --inspect flag, and log an object (not a primitive) in a module where you import another module, an empty object is prepended to the logged string.

Versions

OS: macOS Mojave 10.14.4 Node version: 11.14.0 Esm version: 3.2.25

Steps to reproduce:

  1. Create a js file, a.js
    
    import './b.js'

console.log({ test: true })


2. Create a js file, `b.js`

// Empty file


3. Run `a.js` with `-r esm` and `--inspect`
`node --inspect -r esm a.js`

Debugger listening on ws://127.0.0.1:9229/0708c791-0b7e-4b0c-a8ed-ef8137b9d05d For help, see: https://nodejs.org/en/docs/inspector {} { test: true }


If you run `a.js` without `--inspect`, the output will be

{ test: true }


If you remove the import statement at the beginning of `a.js`, the output will also be

{ test: true }



Logging a primitive will not produce the prepended empty object.
The content of the imported module doesn't seem to change anything.
jdalton commented 5 years ago

Thanks @cathrinevaage!

I've experienced this before so this seems to be a bit of cat and mouse for us.

greggman commented 4 years ago

what does it mean "seems to be a bit of cat and mouse for us". Does it not repo above?