Mapped file path is not complete

Hello

For the mapped file of haxe file at chrome, I notice that it misses the src/ when click on it, thus, chrome will not find it.

So, the hyperlink misses the src/ part, how can this be fixed?
I tried to seek support at chrome forum too:

Hello @hopewise, can you send me an example of a project that I can reproduce?

Oh, its a huge project here in a private repo, is there anything you like me to apply and test result for?

Is it possible to reproduce the problem by creating a smaller project?

As I understand it, when you call trace(), Haxe automatically adds the file path and line number to the front of any text that it prints to the console. However, it’s just plain text. Neither Haxe nor OpenFL purposefully does anything to format that text as a hyperlink. That’s your web browser’s developer tools (looks like Chrome to me) trying to be helpful/smart by scanning the console output for things that look like URLs and turning them into hyperlinks. It’s not perfect, though. Sometimes, there are false positives or other parsing issues. I guess that they decided it’s still helpful enough when it does recognize an URL correctly, that’s it’s worth having some links that don’t work.

You could potentially replace haxe.Log.trace() with your own custom implementation that prints a “better” URL. Maybe as an absolute path or starting with file:/. You’ll just have to play around with it, if you want to try this.

There’s a Haxe define called absolute-path that prints the absolute file paths in trace messages. Build your app with -Dabsolute-path or use <haxedef name="absolute-path" /> in your project.xml.

Note that Chrome will still not open the source files by clicking on the links in the console because of the missing protocol, but you’ll see a more detailed path of the actual hx file. For that, you have to either follow Josh’s instructions or override/modify haxe.Log formatOutput() and/or trace() functions.

Needless to say, but if someone else is looking at this specific debug build of your app, they’ll only find the source files behind the links if they have exactly the same folder structure (which is unlikely).

1 Like

Alternatively, if you use js.html.Console.log() (or any other Console function), Chrome will properly link to the source file and will open it in in DevTools’ Source tab.