Esm: `node -r esm` and chrome devtools

Created on 1 Apr 2018  路  1Comment  路  Source: standard-things/esm

In my continuing quest to get top-level await in as little steps as possible, I am now running node --inspect and then connecting to it with Chrome Devtools, which has the await and lots of other niceties.

However, I found that when I do node -r esm --inspect, the REPL understands import syntax both as direct input and from imported files, but the devtools don't understand either.

Worse, trying to require('esm') in devtools doesn't change this, because it is already loaded.

However, when I do node --inspect followed by require('esm') in the devtools, I can require() files with import statements. Direct usage still doesn't work.

Contrast this with babel-register: When I do node -r babel-register --inspect, I can require() files with import statements. Direct usage doesn't work, but neither does it work from the REPL.

So, it seems that -r esm is doing something to make import work in the REPL, but it might be forgetting something that makes require work in devtools.

question

Most helpful comment

Hi @wmertens!

Make sure the inspector is in the node context. See the following demo:

demo

>All comments

Hi @wmertens!

Make sure the inspector is in the node context. See the following demo:

demo

Was this page helpful?
0 / 5 - 0 ratings