From 6570a015cad6d36c42a03f853d6f5ffa863d713c Mon Sep 17 00:00:00 2001 From: roblou Date: Sun, 1 Jan 2017 14:22:54 -0800 Subject: [PATCH] Enable sourceMaps by default for Microsoft/vscode-chrome-debug-core#134 --- README.md | 12 ++++++------ package.json | 6 ++---- src/chromeDebugAdapter.ts | 3 ++- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4febcef5..c4e29f69 100644 --- a/README.md +++ b/README.md @@ -51,17 +51,17 @@ Two example `launch.json` configs with `"request": "launch"`. You must specify e "version": "0.1.0", "configurations": [ { - "name": "Launch localhost with sourcemaps", + "name": "Launch localhost", "type": "chrome", "request": "launch", "url": "http://localhost/mypage.html", - "webRoot": "${workspaceRoot}/app/files", - "sourceMaps": true + "webRoot": "${workspaceRoot}/app/files" }, { - "name": "Launch index.html (without sourcemaps)", + "name": "Launch index.html (disable sourcemaps)", "type": "chrome", "request": "launch", + "sourceMaps": false, "file": "${workspaceRoot}/index.html" }, ] @@ -92,11 +92,10 @@ An example `launch.json` config. "version": "0.1.0", "configurations": [ { - "name": "Attach with sourcemaps", + "name": "Attach", "type": "chrome", "request": "attach", "port": 9222, - "sourceMaps": true, "url": "" }, { @@ -124,6 +123,7 @@ See our wiki page for some configured example apps: [Examples](https://github.co * `runtimeArgs`: Optional arguments passed to the runtime executable * `userDataDir`: Can be set to a temp directory, then Chrome will use that directory as the user profile directory. If Chrome is already running when you start debugging with a launch config, then the new instance won't start in remote debugging mode. If you don't want to close the original instance, you can set this property and the new instance will correctly be in remote debugging mode. * `url`: Required for a 'launch' config. For an attach config, the debugger will search for a tab that has that URL. It can also contain wildcards, for example, `"localhost:*/app"` will match either `"http://localhost:123/app"` or `"http://localhost:456/app"`, but not `"http://stackoverflow.com"`. +* `sourceMaps`: By default, the adapter will use sourcemaps and your original sources whenever possible. You can disable this by setting `sourceMaps` to false. * `sourceMapPathOverrides`: A mapping of source paths from the sourcemap, to the locations of these sources on disk. Useful when the sourcemap isn't accurate or can't be fixed in the build process. The left hand side of the mapping is a pattern that can contain a wildcard, and will be tested against the `sourceRoot` + `sources` entry in the source map. If it matches, the source file will be resolved to the path on the right hand side, which should be an absolute path to the source file on disk. A couple mappings are applied by default, corresponding to the default configs for Webpack and Meteor - ``` diff --git a/package.json b/package.json index 5704bfd1..0d129773 100644 --- a/package.json +++ b/package.json @@ -80,19 +80,17 @@ "aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217", "initialConfigurations": [ { - "name": "Launch Chrome against localhost, with sourcemaps", + "name": "Launch Chrome against localhost", "type": "chrome", "request": "launch", "url": "http://localhost:8080", - "sourceMaps": true, "webRoot": "${workspaceRoot}" }, { - "name": "Attach to Chrome, with sourcemaps", + "name": "Attach to Chrome", "type": "chrome", "request": "attach", "port": 9222, - "sourceMaps": true, "webRoot": "${workspaceRoot}" } ], diff --git a/src/chromeDebugAdapter.ts b/src/chromeDebugAdapter.ts index 43cd89be..14aabd41 100644 --- a/src/chromeDebugAdapter.ts +++ b/src/chromeDebugAdapter.ts @@ -83,7 +83,8 @@ export class ChromeDebugAdapter extends CoreDebugAdapter { return super.attach(args); } - public commonArgs(args: ICommonRequestArgs): void { + protected commonArgs(args: ICommonRequestArgs): void { + args.sourceMaps = typeof args.sourceMaps === 'undefined' || args.sourceMaps; args.sourceMapPathOverrides = getSourceMapPathOverrides(args.webRoot, args.sourceMapPathOverrides); args.skipFileRegExps = ['^chrome-extension:.*'];