evanw / node-source-map-support

Adds source map support to node.js (for stack traces)
MIT License
2.16k stars 223 forks source link

Format the output so it can be clicked #296

Open linonetwo opened 3 years ago

linonetwo commented 3 years ago

Currently the error message will be like:

    at BrowserWindow.<anonymous> (/Applications/TiddlyGit.app/Contents/Resources/app.asar/.webpack/main/webpack:/TiddlyGit/src/services/windows/index.ts:227:24)

In which the former part can be clicked

( /Applications/TiddlyGit.app/Contents/Resources/app.asar/.webpack/main/webpack )

but it is actually useless.

I hope we can click on the later part

(/TiddlyGit/src/services/windows/index.ts:227:24)

but it is start with project folder name /TiddlyGit , so when open the log file with VSCode ,it won't detect this as path.

Hope we can properly format the path, so later part can be click or copy to used for the file jump.

WeslyG commented 2 years ago

I was able to do something like this. It doesn't work exactly as it should, but it will allow you to click on it.

webpack.dev.js

output: {
    devtoolModuleFilenameTemplate: info => {
      return `file:///${encodeURI(info.absoluteResourcePath)}`
    },
  },