Skip to content
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

Debugging using breakpoints not working -- missing source map urls? #370

Open
atorma opened this issue Sep 22, 2017 · 5 comments
Open

Debugging using breakpoints not working -- missing source map urls? #370

atorma opened this issue Sep 22, 2017 · 5 comments

Comments

@atorma
Copy link

atorma commented Sep 22, 2017

I am running Mocha tests of Streamlined code (fibers) in IntelliJ IDEA and Node 6.9. Debugging the code using breakpoints is not working. Either the IDE stops at a wrong line or does not stop at all.

I can see source map files are created in the .streamline cache directory. I tried adding a source map url to one of the generated _js files. That got breakpoints working. Should code generation add source map urls in the files?

@bjouhier
Copy link
Member

@atorma I ran some tests and I see the // #sourceMappingURL=... directive at the end of the generated source when the --source-maps option is true or inline. Which options are you using?

@atorma
Copy link
Author

atorma commented Oct 1, 2017

I was using IntelliJ IDEA's Mocha run configuration in Windows 10. It executed

C:\Tools\nodejs\node.exe --debug-brk=63761 --expose_debug_as=v8debug C:\Path\to\my\project\node_modules\mocha\bin\_mocha --timeout 0 --ui bdd --reporter C:\Users\MyName\.IntelliJIdea2017.2\config\plugins\NodeJS\js\mocha-intellij\lib\mochaIntellijReporter.js app\test\**\*Test.*js

My mocha.opts were

--recursive
--require app/test/mocha-init
--compilers _js:streamline/register
--colors

However, I got debugging with breakpoints to work when I created a module "register-streamline.js" like this

'use strict';

require('streamline').register({
    runtime: 'fibers',
    quiet: true,
    sourceMaps: 'inline'
});

and then used that as a compiler for *._js in mocha.opts:

--recursive
--require app/test/mocha-init
--compilers _js:app/test/register-streamline
--colors

However, I still don't see the // #sourceMappingURL=... in the cached files in C:\Users\MyName\.streamline.

I haven't tried pre-compiling with babel-plugin-streamline. Running using _node is difficult to get working with Mocha run configs in IDEA (at least in Windows), so I gave up on that.

@atorma
Copy link
Author

atorma commented Oct 1, 2017

Okay, sourceMappingURLs are generated when pre-compiling sources using babel. However, as the readme says, "The recommandation is to use the loader during development" and "The fibers mode gives superior development experience". I agree and would like to stick to that :)

Is there a reason why sourceMappingURLs are not generated in the cached files?

@bjouhier
Copy link
Member

bjouhier commented Oct 1, 2017

You could also set the options via a .streamline.json file (either in your project directory or your user's home directory). This is a bit simpler than creating a register-streamline.js script.

The sourceMappingURL directives are not included in the cached files but they are added dynamically after the source is retrieved from the cache. I don't remember the whole rationale but I think it was done this way to keep the cache independent from the source-map options.

@atorma
Copy link
Author

atorma commented Oct 2, 2017

With option sourceMaps: true Mocha tests simply crashed in the IDE when running in debug mode (normal mode was fine). That happened both with a streamline.json file and with a registration script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants