JavaScript source breakpoint not working despite sourcemap

Greetings,

I'm trying to get an ES6 source breakpoint to trip when running a Mocha test against its ES5 transpiled output, with external sourcemap.  The project is on GitHub.

I set the breakpoint at line 9 of "src/hash-clean.js".  I execute "npm run build" to transpile the ES6 source with Babel to the ES5 "dist/hash-clean.js", along with "dist/hash-clean.js.map".

If I debug from either test case in "test/hash-clean.spec.js", the console output from line 9 of "src/hash-clean.js" prints, but the breakpoint in "src/hash-clean.js" never suspends execution.  If I place a breakpoint directly in "dist/hash-clean.js", and run the test again, execution is suspended.

The test imports '../dist/hash-clean.js', which has a source map comment for the relative "//# sourceMappingURL=hash-clean.js.map", which in turn has a relative "sources" entry for "../src/hash-clean.js".  

Is that not all correct, or have I otherwise configured something wrong?

Note that the project includes a run configuration for the Mocha test.  The configuration specifies the "-r babel-register" Node option, thereby allowing the ES6 test to be run directly (i.e. without being transpiled to ES5 first).

IntelliJ IDEA 2017.1.3
Build #IU-171.4424.56, built on May 12, 2017
JRE: 1.8.0_112-release-736-b21 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.5

NodeJS Plugin Version: 171.4424.63

Node Version: v6.10.3

0
2 comments

Recreated when using Node 6.10. Seems the problem is that both "-r babel-register" and precompiled sources are used... Faced similar issue when using node-inspector for debugging

I was able to debug `\src\hash-clean.js` by changing import in hash-clean.spec.js to

import HashCleanWebpackPlugin from '../src/hash-clean.js'

so that the ES6 version is loaded instead of the precompiled one (as you are running with "-r babel-register", there doesn't seem to be necessary to get part of your sources precompoiled)

Another workaround (if you need importing files from 'dist' for some reason) is using Node 7 - debugging works for me when using it

0

Thanks, Elena!

With Node 6 being the recommended LTS version, I want to stick with that over Node 7 for now.  I was only testing the transpiled ES5 source to prove that the project build and sourcemap generation was setup correctly.  I can just keep a separate smoke test around for that, and do all the unit and functional testing (where any debugging would be likely to occur) against the ES6 source.

Best,

Ian

0

Please sign in to leave a comment.