I'm using CoffeeScript for a while to write Node.js programs. It's ok to debug with node-inspector
if I compile the sources with Source Maps.
However, when I try to create a mixed Javascript/CoffeeScript app by using coffee-script/register
:
#!/usr/bin/env node
require('coffee-script/register');
require('../src/client');
Then, node-inspector shows the compiled Javascript.
Is there how to see the actual *.coffee
sources in node-inspector
when I'm not explicity compiling it?
Disclaimer: I am a maintainer of Node Inspector
In order to see the actual
*.coffee
file in Node Inspector, you need to provide a source-map file describing how to map the transpiled javascript loaded inside Node/V8 runtime to you coffee-script source. Additionally, the filename of the transpiled javascript must be different from the original script name (AFAIK).This is the trouble with
require('coffee-script/register')
: it converts the coffee-script source to the javascript source while keeping the same file name. In other words, the runtime (and Node Inspector) see that your*.coffee
contain the transpiled javascript, thus it cannot display your coffee script for that very same filename. Also AFAIK, the coffee compiler does not emit any source map in this case.I see two possible approaches to fix the problem:
Modify
loadFile()
incoffee-script/register
:module._compile
, e.g.script.coffee.js
Modify
coffee-script/register
to emit an embedded source map. Fix Chrome DevTools and/or Node Inspector to support embedded source maps.References:
loadFile()
in coffee-script/registercoffee --nodejs --debug app.coffee
does not work now: https://github.com/node-inspector/node-inspector/issues/224