简体   繁体   English

VSCode browserify源图调试似乎不起作用

[英]VSCode browserify source map debugging does not seem to work

I'm having an issue getting VSCode to set breakpoints in chrome with typescript/browserify. 我遇到一个问题,让VSCode在chrome中使用typescript / browserify设置断点。

If I run chrome by itself, AND refresh the page, the source maps load fine, and the built-in chrome debugger can step through my .ts files just fine. 如果我自己运行chrome,并刷新页面,源映射加载正常,内置的chrome调试器可以正常执行我的.ts文件。

However, when I try to launch chrome using the VSCode chrome debugger extension, it can't set breakpoints, and won't load the source map files. 但是,当我尝试使用VSCode chrome调试器扩展启动chrome时,它无法设置断点,也不会加载源映射文件。

However, when NOT using browserify, the source maps seems to load fine and the breakpoints work. 但是,当不使用browserify时,源映射似乎加载正常并且断点起作用。

I'm just not sure why when running chrome stand-alone, it needs to be refreshed for the source mapped files to show up. 我只是不确定为什么在运行chrome stand-alone时,需要刷新它才能显示源映射文件。

Anyway, attached is my gulp file: 无论如何,附件是我的gulp文件:

var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var tsify = require('tsify');
var sourcemaps = require('gulp-sourcemaps');
var buffer = require('vinyl-buffer');
var paths = {
    pages: ['*.html']
};

gulp.task('copyHtml', function () {
    return gulp.src(paths.pages)
        .pipe(gulp.dest('.'));  
});

gulp.task('default', function () {
    return browserify({
        basedir: '.',
        debug: true,
        entries: ['main.ts'],
        cache: {},
        packageCache: {}
    })
    .plugin(tsify)
    .bundle()
    .pipe(source('bundle.js'))
    .pipe(buffer())
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('.'));
});

And, the results of the VSCode debugger console: 并且,VSCode调试器控制台的结果:

›OS: darwin x64
›Node: v5.10.0
›vscode-chrome-debug-core: 0.1.6
›debugger-for-chrome: 0.4.4
›spawn('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',  ["--remote-debugging-port=9222","--no-first-run","--no-default-browser-check","file:///Users/andy/src/cayman/web/index.html"])
›Attempting to attach on port 9222
›SourceMaps.setBP: /Users/andy/src/cayman/web/main.ts can't be resolved to a loaded script. It may just not be loaded yet.
›SourceMaps.setBP: /Users/andy/src/cayman/web/greet.ts can't be resolved to a loaded script. It may just not be loaded yet.

Could you please share your launch setup? 你可以分享你的发布设置吗? Because if your breakpoint are not validated, you're probably not linking the sourcemaps properly. 因为如果未验证断点,则可能无法正确链接源图。

One thing to consider: 有一点需要考虑:

From VS Code Chrome debugging docs : 来自VS Code Chrome调试文档

This extension ignores sources that are inlined in the sourcemap - you may have a setup that works in Chrome Dev Tools, but not this extension, because the paths are incorrect, but Chrome Dev Tools are reading the inlined source content. 此扩展程序会忽略源地图中内联的来源 - 您可能有一个适用于Chrome开发者工具的设置,但不适用此扩展程序,因为路径不正确,但Chrome开发者工具正在阅读内联的源内容。

For all I can tell, browserify outputs the sources inlined in the sourcemaps, rather than provide the path to the file on disk. 据我所知,browserify输出源映射中内联的源,而不是提供磁盘上文件的路径。 This is to save some complexity and async loading of source files when debugging in the browser itself. 这是为了在浏览器本身进行调试时节省一些复杂性和源文件的异步加载。 But that doesn't pair with VSCode. 但这并不与VSCode配对。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM