-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
babel-node-inspector? node-inspector + babel #6
Comments
babel-node-inspector
? node-inspector
and babel
You can accomplish this with the regular $ babel-node --debug-brk=8010 test.js
Debugger listening on port 8010 As an aside, breaking at the first line of application code was the primary motivation for building Building something like |
I attempted to implement a Below is my attempt. It seems it would 100% work, except there's no way to get a value for The best way / only way to solve this would be for #!/usr/bin/env node
var util = require('util')
var Debugger = require('yadc').Debugger
var OriginalDebugServer = require('node-inspector/lib/debug-server').DebugServer
function DebugServer() {
var debugServer = this
OriginalDebugServer.apply(this, arguments)
var oldStart = debugServer.start
debugServer.start = function start(config) {
var returnValue = oldStart.apply(this, arguments)
continueToMainFile(debugServer, config)
return returnValue
}
return debugServer
}
util.inherits(DebugServer, OriginalDebugServer)
require('node-inspector/lib/debug-server').DebugServer = DebugServer
function continueToMainFile(debugServer, config) {
debugServer.on('listening', function() {
setTimeout(function() {
console.log(config)
var debug = new Debugger({
port: config.debugPort,
host: '127.0.0.1'
})
debug.send({command: 'continue'}, function() {
debug.send({
command: 'setBreakpoint',
arguments: {
type: 'scriptRegExp',
target: config.script,
line: 1,
column: 1
}
}, function(err, result) {
if (err) return
debug.on('event', function listener(event) {
if (event.event === 'break') {
debug.send({
command: 'clearbreakpoint',
arguments: {
type: 'scriptRegExp',
breakpoint: result.res.body.breakpoint
}
})
debug.client.end()
debug.removeListener('event', listener)
debug.removeListener('error', onError)
}
})
})
})
function onError(errObj) {}
debug.on('error', onError)
}, 1000)
})
}
require('node-inspector/bin/inspector') |
Oh wow, so much info. Thanks a ton! I originally didn't create an issue because I thought this was kind of abandoned (the last issue about --save-live-edit is created a month ago), but you really came through here! Indeed, I can confirm that your proposed solution works (although startup times are obscene on this one):
Here's a GIF of it in action (real time, about 20 sec of startup): https://i.imgur.com/Cr1XOlC.gifv GIF shows debugging of a V8 instance started via As you can see, it needs quite some time to get to the actual code of the application, but it works nevertheless. I'll be monitoring those issues you created. Thanks! |
There's not much activity on the project because it's new and very niche (babel's babel-node + node-inspector's node-debug). Also, it seemed to be pretty much "done" in that there weren't any real bugs that needed to be solved in this project. Thanks for reaching out to me. I think something very good will come of this. |
Below copied from email discussion with 3rd party.
There is a debugging scheme I often use with stock node (i.e. without babel):
Start the actual process with --debug flag:
# node --debug-brk=8010 test.js Debugger listening on port 8010
Start the standalone instance of node-inspector:
Navigate to the following URL to access the web interface:
TLDR; We start a standalone instance of node inspector and tell it to connect to some other V8 debugger.
Is it possible to achieve something similar when using babel?
If I substitute commands with babel-related ones (bode-debug instead of node-inspector and babel-node instead of node) I get the debugger that looks at babel’s internal files, not my script. I reckon it’s because there is no susbstitute for node-inspector command in your package (only for node-debug).
Any help will be greatly appreciated. Have a great day!
The text was updated successfully, but these errors were encountered: