esm icon indicating copy to clipboard operation
esm copied to clipboard

Esm with --inspect causes empty objects to be logged

Open cathrinevaage opened this issue 5 years ago • 2 comments

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 })
  1. Create a js file, b.js
// Empty file
  1. 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.

cathrinevaage avatar Jun 24 '19 12:06 cathrinevaage

Thanks @cathrinevaage!

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

jdalton avatar Jul 16 '19 17:07 jdalton

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

greggman avatar Mar 19 '20 12:03 greggman