jaridmargolin / inspect-process

🔍 Dead simple debugging for node.js using chrome-devtools.
425 stars 26 forks source link

How inspect with babel? #37

Closed Zummer closed 7 years ago

Zummer commented 7 years ago

when I use: "inspect src/index.js" I will take this error:

(function (exports, require, module, __filename, __dirname) { import express from 'express';
                                                              ^^^^^^

how can I use "inspect" like this way? "nodemon --watch ./ --inspect src/index --exec babel-node",

penx commented 7 years ago

I've been wondering this too, my debug script is as follows:

"start:debug": "nodemon -w src src/index.js --exec 'babel-node --inspect=1234'"

This allows me to:

Is it possible to add inspect-process to my debug script and still do all of the above?

jaridmargolin commented 7 years ago

At a high level, much of this is not currently possible with inspect-process. Read below for more detailed explanation:


debug/step through ES6 sourcemaps rather than transpiled code (using babel-node)

babel-node is an interesting case. We implement almost identical functionality for handling node args:

https://github.com/babel/babel/blob/master/packages/babel-cli/src/babel-node.js https://github.com/jaridmargolin/inspect-process/blob/dev/bin/inspect.js

Unfortunately, this code requires a child_process to be spawned which temporarily breaks inspect-process (See #5). If they exposed the underlying module _babel-node as an executable, you would be able to use that: inspect _babel-node myscript.js

watch for changes (using nodemon)

I would like to have a watch feature implemented directly into inspect-process, as this is the only way to avoid having the inspect window open and close every time a change is made. See #3

specify a debug port (with --inspect=1234)

Currently the port is auto discovered and can not be passed in as an arg... I would be more than willing to implement in the future. You are the first to request.

jaridmargolin commented 7 years ago

Also, I do recall a previous issue where a user was attempting to use babel-register. Perhaps this could be a solution rather than using babel-node?

inspect --require babel-register src/index.js
Zummer commented 7 years ago

оk, but when I execute babel-node --inspect src/index.js I can see and interact with all modules in my project http://storage3.static.itmages.com/i/17/0225/h_1488028303_9985673_83c627e86d.png

whatever I execute inspect --require babel-register src/index.js I can see only src/index.js http://storage6.static.itmages.com/i/17/0225/h_1488028371_4676020_ebc1706177.png

What can I do to access another files?

jaridmargolin commented 7 years ago

@Zummer - I'm not going to be able to help you, as I am not incredibly familiar with the babel toolchain. I can tell you however that we are working on supporting child_processes, which will allow you to use babel-node. Feel free to subscribe to updates over at issue #5.