Search code examples
javascriptregexgoogle-chrometypescriptjavascript-debugger

Remove all files that are not *.ts and *.map.js in Chrome Debugger Blackbox


As the title states, I'm trying to get the debugger to blackbox any file that is not a Typescript file or a js map file.

I'm using this regex:

^(?!.*\.map\.js$)(?!.*\.ts$).*$

which works using regex101.com to test, however it fails to properly blackbox in Chrome.

Are there special rules that Chrome follows? Why does this not work, and can any one help me get a functional regex for this purpose?


Solution

  • Turns out I am stupid, thanks to 1252748 for pointing that out. For my webpack/angular project this is the correct regex to use to get rid of everything that isn't user code:

    ^(?!.*\map$)(?!.*\.ts$)(?!.*\.bundle\.js)(?!.*\.dll\.js).*

    It removes everything that isn't *.js.map, *.ts, *.bundle.js, and *.dll.js. Other projects may need tweaking on this general theme, but since I couldn't find a nice template for the chrome debugger blackbox I'll just leave this here.