From f085447fad370b5565b1c9719c65b8c4783cd51b Mon Sep 17 00:00:00 2001 From: Yuri Skorokhodov Date: Tue, 25 Jun 2019 10:59:00 +0300 Subject: [PATCH 1/4] Delete redundant properties from initial debug scenarios --- package.json | 4 ---- src/common/remoteExtension.ts | 6 +++--- src/debugger/nodeDebugWrapper.ts | 7 +++++-- src/extension/debugConfigurationProvider.ts | 8 -------- src/extension/rn-extension.ts | 3 --- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index df5f73629..ebf932507 100644 --- a/package.json +++ b/package.json @@ -130,7 +130,6 @@ "type": "reactnative", "request": "launch", "platform": "android", - "sourceMaps": true, "outDir": "^\"\\${workspaceRoot}/.vscode/.react\"" } }, @@ -143,7 +142,6 @@ "type": "reactnative", "request": "launch", "platform": "ios", - "sourceMaps": true, "outDir": "^\"\\${workspaceRoot}/.vscode/.react\"" } }, @@ -155,7 +153,6 @@ "program": "^\"\\${workspaceRoot}/.vscode/launchReactNative.js\"", "type": "reactnative", "request": "attach", - "sourceMaps": true, "outDir": "^\"\\${workspaceRoot}/.vscode/.react\"" } }, @@ -168,7 +165,6 @@ "type": "reactnative", "request": "launch", "platform": "exponent", - "sourceMaps": true, "outDir": "^\"\\${workspaceRoot}/.vscode/.react\"" } } diff --git a/src/common/remoteExtension.ts b/src/common/remoteExtension.ts index eeea992b1..4b9bb23fb 100644 --- a/src/common/remoteExtension.ts +++ b/src/common/remoteExtension.ts @@ -19,7 +19,7 @@ export interface IExtensionApi extends ICommonApi { stopMonitoringLogcat(): Q.Promise; sendTelemetry(telemetryRequest: Telemetry.TelemetryRequest): Q.Promise; openFileAtLocation(openFileRequest: OpenFileRequest): Q.Promise; - getPackagerPort(program: string): Q.Promise; + getPackagerPort(): Q.Promise; showInformationMessage(infoMessage: string): Q.Promise; launch(request: any): Q.Promise; showDevMenu(deviceId?: string): Q.Promise; @@ -80,8 +80,8 @@ export class RemoteExtension { return this._api.Extension.openFileAtLocation(request); } - public getPackagerPort(program: string): Q.Promise { - return this._api.Extension.getPackagerPort(program); + public getPackagerPort(): Q.Promise { + return this._api.Extension.getPackagerPort(); } public showInformationMessage(infoMessage: string): Q.Promise { diff --git a/src/debugger/nodeDebugWrapper.ts b/src/debugger/nodeDebugWrapper.ts index 6c5bae4ff..b133552d6 100644 --- a/src/debugger/nodeDebugWrapper.ts +++ b/src/debugger/nodeDebugWrapper.ts @@ -84,7 +84,7 @@ export function makeSession( return this.remoteExtension.launch(request); }) .then(() => { - return this.remoteExtension.getPackagerPort(request.arguments.program); + return this.remoteExtension.getPackagerPort(); }) .then((packagerPort: number) => { this.attachRequest({ @@ -104,7 +104,7 @@ export function makeSession( this.requestSetup(request.arguments) .then(() => { logger.verbose(`Handle attach request: ${JSON.stringify(request.arguments, null , 2)}`); - return this.remoteExtension.getPackagerPort(request.arguments.program); + return this.remoteExtension.getPackagerPort(); }) .then((packagerPort: number) => { this.attachRequest({ @@ -150,6 +150,9 @@ export function makeSession( logger.setup(Logger.LogLevel.Log, chromeDebugCoreLogs || false); } + if (!args.sourceMaps) { + args.sourceMaps = true; + } const projectRootPath = getProjectRoot(args); return ReactNativeProjectHelper.isReactNativeProject(projectRootPath) .then((result) => { diff --git a/src/extension/debugConfigurationProvider.ts b/src/extension/debugConfigurationProvider.ts index 1ea53d09c..0bbf268f0 100644 --- a/src/extension/debugConfigurationProvider.ts +++ b/src/extension/debugConfigurationProvider.ts @@ -11,37 +11,29 @@ export class ReactNativeDebugConfigProvider implements vscode.DebugConfiguration private debugConfigurations = { "Debug Android": { "name": "Debug Android", - "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", "platform": "android", - "sourceMaps": true, "outDir": "${workspaceRoot}/.vscode/.react", }, "Debug iOS": { "name": "Debug iOS", - "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", "platform": "ios", - "sourceMaps": true, "outDir": "${workspaceRoot}/.vscode/.react", }, "Attach to packager": { "name": "Attach to packager", - "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "attach", - "sourceMaps": true, "outDir": "${workspaceRoot}/.vscode/.react", }, "Debug in Exponent": { "name": "Debug in Exponent", - "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", "platform": "exponent", - "sourceMaps": true, "outDir": "${workspaceRoot}/.vscode/.react", }, }; diff --git a/src/extension/rn-extension.ts b/src/extension/rn-extension.ts index 895610556..b369584bb 100644 --- a/src/extension/rn-extension.ts +++ b/src/extension/rn-extension.ts @@ -67,11 +67,8 @@ export function activate(context: vscode.ExtensionContext): Q.Promise { context.subscriptions.push(vscode.workspace.onDidChangeConfiguration((event) => onChangeConfiguration(context))); debugConfigProvider = vscode.debug.registerDebugConfigurationProvider("reactnative", configProvider); - let activateExtensionEvent = TelemetryHelper.createTelemetryEvent("activate"); Telemetry.send(activateExtensionEvent); - - let promises: any = []; if (workspaceFolders) { outputChannelLogger.debug(`Projects found: ${workspaceFolders.length}`); From e1094cc9aa9e86d44774b9311a37f392d50f8e94 Mon Sep 17 00:00:00 2001 From: Yuri Skorokhodov Date: Tue, 25 Jun 2019 12:05:36 +0300 Subject: [PATCH 2/4] Remove outDir property from initial debug configs --- package.json | 22 ++++----------------- package.nls.json | 1 - src/extension/debugConfigurationProvider.ts | 8 ++++---- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index ebf932507..57e12afea 100644 --- a/package.json +++ b/package.json @@ -129,8 +129,7 @@ "program": "^\"\\${workspaceRoot}/.vscode/launchReactNative.js\"", "type": "reactnative", "request": "launch", - "platform": "android", - "outDir": "^\"\\${workspaceRoot}/.vscode/.react\"" + "platform": "android" } }, { @@ -141,8 +140,7 @@ "program": "^\"\\${workspaceRoot}/.vscode/launchReactNative.js\"", "type": "reactnative", "request": "launch", - "platform": "ios", - "outDir": "^\"\\${workspaceRoot}/.vscode/.react\"" + "platform": "ios" } }, { @@ -152,8 +150,7 @@ "name": "Attach to packager", "program": "^\"\\${workspaceRoot}/.vscode/launchReactNative.js\"", "type": "reactnative", - "request": "attach", - "outDir": "^\"\\${workspaceRoot}/.vscode/.react\"" + "request": "attach" } }, { @@ -164,8 +161,7 @@ "program": "^\"\\${workspaceRoot}/.vscode/launchReactNative.js\"", "type": "reactnative", "request": "launch", - "platform": "exponent", - "outDir": "^\"\\${workspaceRoot}/.vscode/.react\"" + "platform": "exponent" } } ], @@ -184,11 +180,6 @@ "description": "%reactNative.attach.sourceMaps.description%", "default": false }, - "outDir": { - "type": "string", - "description": "%reactNative.attach.outDir.description%", - "default": null - }, "sourceMapPathOverrides": { "type": "object", "description": "%reactNative.attach.sourceMapsPathOverrides.description%" @@ -291,11 +282,6 @@ "ReactNativeJS:V" ] }, - "outDir": { - "type": "string", - "description": "%reactNative.launch.outDir.description%", - "default": null - }, "runArguments": { "type": "array", "description": "%reactNative.launch.runArguments.description%" diff --git a/package.nls.json b/package.nls.json index 294f58d8e..058ae9873 100644 --- a/package.nls.json +++ b/package.nls.json @@ -19,7 +19,6 @@ "reactNative.snippets.debugExpo.description":"A new configuration for launching Expo app", "reactNative.attach.program.description":"The path to launchReactNative.js in the vscode folder", "reactNative.attach.sourceMaps.description":"Whether to use JavaScript source maps to map the generated bundled code back to its original sources", - "reactNative.attach.outDir.description":"The location of the generated JavaScript code (the bundle file). Normally this should be \"${workspaceRoot}/.vscode/.react\"", "reactNative.attach.sourceMapsPathOverrides.description":"A set of mappings for rewriting the locations of source files from what the source map says, to their locations on disk. See https://github.com/Microsoft/vscode-react-native/blob/master/doc/debugging.md#debugging-with-typescript-and-haul for details", "reactNative.attach.trace.description":"Setup logging level in debugger.", "reactNative.attach.address.description":"TCP/IP address of debug port. Default is 'localhost'.", diff --git a/src/extension/debugConfigurationProvider.ts b/src/extension/debugConfigurationProvider.ts index 0bbf268f0..310dc03bb 100644 --- a/src/extension/debugConfigurationProvider.ts +++ b/src/extension/debugConfigurationProvider.ts @@ -11,30 +11,30 @@ export class ReactNativeDebugConfigProvider implements vscode.DebugConfiguration private debugConfigurations = { "Debug Android": { "name": "Debug Android", + "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", "platform": "android", - "outDir": "${workspaceRoot}/.vscode/.react", }, "Debug iOS": { "name": "Debug iOS", + "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", "platform": "ios", - "outDir": "${workspaceRoot}/.vscode/.react", }, "Attach to packager": { "name": "Attach to packager", + "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "attach", - "outDir": "${workspaceRoot}/.vscode/.react", }, "Debug in Exponent": { "name": "Debug in Exponent", + "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", "platform": "exponent", - "outDir": "${workspaceRoot}/.vscode/.react", }, }; From 6522bfb5e87a765e2633f164acf18eb432c97623 Mon Sep 17 00:00:00 2001 From: Yuri Skorokhodov Date: Tue, 25 Jun 2019 12:41:59 +0300 Subject: [PATCH 3/4] Restore program property for debug scenarios Remove outDir and sourceMaps property from debug scenarios Update docs --- doc/debugging.md | 8 ++------ src/common/remoteExtension.ts | 6 +++--- src/debugger/nodeDebugWrapper.ts | 4 ++-- test/smoke/resources/launch.json | 8 -------- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/doc/debugging.md b/doc/debugging.md index c594c3a47..185e6c408 100644 --- a/doc/debugging.md +++ b/doc/debugging.md @@ -51,9 +51,7 @@ For UWP apps use `windows` target platform in `launch.json` configuration, e.g.: "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", - "platform": "windows", - "sourceMaps": true, - "outDir": "${workspaceRoot}/.vscode/.react" + "platform": "windows" } ``` @@ -65,8 +63,6 @@ For WPF apps use `wpf`, e.g.(WPF debugging available only for react-native-windo "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", - "platform": "wpf", - "sourceMaps": true, - "outDir": "${workspaceRoot}/.vscode/.react" + "platform": "wpf" } ``` diff --git a/src/common/remoteExtension.ts b/src/common/remoteExtension.ts index 4b9bb23fb..eeea992b1 100644 --- a/src/common/remoteExtension.ts +++ b/src/common/remoteExtension.ts @@ -19,7 +19,7 @@ export interface IExtensionApi extends ICommonApi { stopMonitoringLogcat(): Q.Promise; sendTelemetry(telemetryRequest: Telemetry.TelemetryRequest): Q.Promise; openFileAtLocation(openFileRequest: OpenFileRequest): Q.Promise; - getPackagerPort(): Q.Promise; + getPackagerPort(program: string): Q.Promise; showInformationMessage(infoMessage: string): Q.Promise; launch(request: any): Q.Promise; showDevMenu(deviceId?: string): Q.Promise; @@ -80,8 +80,8 @@ export class RemoteExtension { return this._api.Extension.openFileAtLocation(request); } - public getPackagerPort(): Q.Promise { - return this._api.Extension.getPackagerPort(); + public getPackagerPort(program: string): Q.Promise { + return this._api.Extension.getPackagerPort(program); } public showInformationMessage(infoMessage: string): Q.Promise { diff --git a/src/debugger/nodeDebugWrapper.ts b/src/debugger/nodeDebugWrapper.ts index b133552d6..c688a1e02 100644 --- a/src/debugger/nodeDebugWrapper.ts +++ b/src/debugger/nodeDebugWrapper.ts @@ -84,7 +84,7 @@ export function makeSession( return this.remoteExtension.launch(request); }) .then(() => { - return this.remoteExtension.getPackagerPort(); + return this.remoteExtension.getPackagerPort(request.arguments.program); }) .then((packagerPort: number) => { this.attachRequest({ @@ -104,7 +104,7 @@ export function makeSession( this.requestSetup(request.arguments) .then(() => { logger.verbose(`Handle attach request: ${JSON.stringify(request.arguments, null , 2)}`); - return this.remoteExtension.getPackagerPort(); + return this.remoteExtension.getPackagerPort(request.arguments.program); }) .then((packagerPort: number) => { this.attachRequest({ diff --git a/test/smoke/resources/launch.json b/test/smoke/resources/launch.json index 617717633..383cdf4a2 100644 --- a/test/smoke/resources/launch.json +++ b/test/smoke/resources/launch.json @@ -7,8 +7,6 @@ "type": "reactnative", "request": "launch", "platform": "android", - "sourceMaps": true, - "outDir": "${workspaceRoot}/.vscode/.react" }, { "name": "Debug iOS", @@ -16,16 +14,12 @@ "type": "reactnative", "request": "launch", "platform": "ios", - "sourceMaps": true, - "outDir": "${workspaceRoot}/.vscode/.react" }, { "name": "Attach to packager", "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "attach", - "sourceMaps": true, - "outDir": "${workspaceRoot}/.vscode/.react" }, { "name": "Debug in Exponent", @@ -33,8 +27,6 @@ "type": "reactnative", "request": "launch", "platform": "exponent", - "sourceMaps": true, - "outDir": "${workspaceRoot}/.vscode/.react" } ] } \ No newline at end of file From 12507ceca27adb11d3ec3c01314923187841e1db Mon Sep 17 00:00:00 2001 From: Yuri Skorokhodov Date: Tue, 25 Jun 2019 12:43:32 +0300 Subject: [PATCH 4/4] Fix smoke test debug configuration --- test/smoke/resources/launch.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/smoke/resources/launch.json b/test/smoke/resources/launch.json index 383cdf4a2..409953f83 100644 --- a/test/smoke/resources/launch.json +++ b/test/smoke/resources/launch.json @@ -6,27 +6,27 @@ "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", - "platform": "android", + "platform": "android" }, { "name": "Debug iOS", "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", - "platform": "ios", + "platform": "ios" }, { "name": "Attach to packager", "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", - "request": "attach", + "request": "attach" }, { "name": "Debug in Exponent", "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", - "platform": "exponent", + "platform": "exponent" } ] -} \ No newline at end of file +}