From 4e3b484631f09bf8905524817608733cba44e445 Mon Sep 17 00:00:00 2001 From: Lukas Piatkowski Date: Fri, 5 Aug 2016 06:02:20 -0700 Subject: [PATCH] Put "file:line" when we can't resolve function name Reviewed By: michalgr Differential Revision: D3670558 fbshipit-source-id: 2a60babf16ac6e6be77ebb6e76f5179b024a77c6 --- local-cli/server/middleware/jscProfilerMiddleware.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/local-cli/server/middleware/jscProfilerMiddleware.js b/local-cli/server/middleware/jscProfilerMiddleware.js index c8890a23f..744f95c2c 100644 --- a/local-cli/server/middleware/jscProfilerMiddleware.js +++ b/local-cli/server/middleware/jscProfilerMiddleware.js @@ -11,6 +11,7 @@ const SourceMapConsumer = require('source-map').SourceMapConsumer; const fs = require('fs'); const http = require('http'); +const path = require('path'); const urlLib = require('url'); class TreeTransformator { @@ -31,7 +32,8 @@ class TreeTransformator { line: tree.lineNumber, column: tree.columnNumber, }); - tree.functionName = original.name; + tree.functionName = original.name + || (path.posix.basename(original.source) + ':' + original.line); tree.scriptId = tree.id; tree.url = 'file://' + original.source; tree.lineNumber = original.line; @@ -89,8 +91,7 @@ class TreeTransformator { resBody += chunk; }).on('end', () => { sawEnd = true; - const map = JSON.parse(resBody.replace(/^\)\]\}'/, '')); - this.urlResults[url] = new SourceMapConsumer(map); + this.urlResults[url] = new SourceMapConsumer(resBody); callback(); }).on('close', (err) => { if (!sawEnd) {