From 666ea2fa346f0ff31d7a5e7a234de9b02ddd675d Mon Sep 17 00:00:00 2001 From: Jason Fields Date: Sun, 7 Feb 2021 17:40:31 -0500 Subject: [PATCH] Use source maps to get readable stack traces in production Using the 'source-map' option does blow up the package size quite a bit, but I couldn't find another option that was doing the trick. Fixes #5887 --- .vscodeignore | 1 - extension.ts | 4 ++++ package.json | 2 ++ src/taskQueue.ts | 8 ++++---- webpack.config.js | 2 +- webpack.dev.js | 1 - yarn.lock | 9 ++++++++- 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.vscodeignore b/.vscodeignore index 24ffcb71..a86e85f8 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -4,7 +4,6 @@ .vscode-test/** **/*.ts -**/*.map *.yml src/** diff --git a/extension.ts b/extension.ts index 5082131a..8b50213b 100644 --- a/extension.ts +++ b/extension.ts @@ -15,6 +15,8 @@ import './src/configuration/validators/remappingValidator'; import './src/configuration/validators/neovimValidator'; import './src/configuration/validators/vimrcValidator'; +import { install as installSourceMapSupport } from 'source-map-support'; + import * as vscode from 'vscode'; import { activate as activateFunc } from './extensionBase'; import { Globals } from './src/globals'; @@ -26,6 +28,8 @@ export async function activate(context: vscode.ExtensionContext) { // Set the storage path to be used by history files Globals.extensionStoragePath = context.globalStoragePath; + installSourceMapSupport(); + activateFunc(context); } diff --git a/package.json b/package.json index 4e6e2c53..5d217f4f 100644 --- a/package.json +++ b/package.json @@ -1097,6 +1097,7 @@ "lodash": "^4.17.20", "neovim": "4.9.0", "path-browserify": "1.0.1", + "source-map-support": "0.5.19", "untildify": "4.0.0", "winston": "3.3.3", "winston-console-for-electron": "0.0.6", @@ -1110,6 +1111,7 @@ "@types/mocha": "8.2.1", "@types/node": "12.20.6", "@types/sinon": "9.0.11", + "@types/source-map-support": "0.5.3", "@types/vscode": "1.42.0", "clean-webpack-plugin": "3.0.0", "event-stream": "4.0.1", diff --git a/src/taskQueue.ts b/src/taskQueue.ts index 77b09ab0..6bd4b046 100644 --- a/src/taskQueue.ts +++ b/src/taskQueue.ts @@ -43,11 +43,11 @@ class TaskQueue { vscode.window .showErrorMessage(e.message, reportButton) .then((picked: string | undefined) => { - let body = `**To Reproduce**\nSteps to reproduce the behavior:\n\n1. Go to '...'\n2. Click on '....'\n3. Scroll down to '....'\n4. See error\n\n**VSCodeVim version**: ${extensionVersion}`; - if (stack) { - body += `\n\n
Stack trace\n\n\`\`\`\n${stack}\n\`\`\`\n\n
`; - } if (picked === reportButton) { + let body = `**To Reproduce**\nSteps to reproduce the behavior:\n\n1. Go to '...'\n2. Click on '....'\n3. Scroll down to '....'\n4. See error\n\n**VSCodeVim version**: ${extensionVersion}`; + if (stack) { + body += `\n\n
Stack trace\n\n\`\`\`\n${stack}\n\`\`\`\n\n
`; + } vscode.commands.executeCommand( 'vscode.open', vscode.Uri.parse( diff --git a/webpack.config.js b/webpack.config.js index a3f490f7..703e0e5b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -70,7 +70,7 @@ const nodelessConfig = { filename: 'extensionWeb.js', libraryTarget: 'umd', }, - devtool: 'inline-source-map', + devtool: 'source-map', externals: { vscode: 'commonjs vscode', // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/ }, diff --git a/webpack.dev.js b/webpack.dev.js index e962638e..f2b66e0f 100644 --- a/webpack.dev.js +++ b/webpack.dev.js @@ -4,7 +4,6 @@ const prod_configs = require('./webpack.config.js'); module.exports = [ merge.merge(prod_configs[0], { mode: 'development', - devtool: 'inline-source-map', optimization: { minimize: false, removeAvailableModules: false, diff --git a/yarn.lock b/yarn.lock index 2dc5db56..446a2fd8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -231,6 +231,13 @@ resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9" integrity sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA== +"@types/source-map-support@0.5.3": + version "0.5.3" + resolved "https://registry.yarnpkg.com/@types/source-map-support/-/source-map-support-0.5.3.tgz#acb6b3e499c20692552d16934c16162c84594e16" + integrity sha512-fvjMjVH8Rmokw2dWh1dkj90iX5R8FPjeZzjNH+6eFXReh0QnHFf1YBl3B0CF0RohIAA3SDRJsGeeUWKl6d7HqA== + dependencies: + source-map "^0.6.0" + "@types/tapable@*": version "1.0.6" resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.6.tgz#a9ca4b70a18b270ccb2bc0aaafefd1d486b7ea74" @@ -5228,7 +5235,7 @@ source-map-resolve@^0.6.0: atob "^2.1.2" decode-uri-component "^0.2.0" -source-map-support@~0.5.12, source-map-support@~0.5.19: +source-map-support@0.5.19, source-map-support@~0.5.12, source-map-support@~0.5.19: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==