diff --git a/packages/react-devtools-core/src/launchEditor.js b/packages/react-devtools-core/src/launchEditor.js index 7277c83bcc..78d48e89a6 100644 --- a/packages/react-devtools-core/src/launchEditor.js +++ b/packages/react-devtools-core/src/launchEditor.js @@ -105,8 +105,18 @@ function guessEditor() { } var _childProcess = null; -function launchEditor(filePath, lineNumber) { - if (!fs.existsSync(filePath)) { +function launchEditor(maybeRelativePath, lineNumber, absoluteProjectRoots) { + // We use relative paths at Facebook we deterministic builds. + // This is why our internal tooling calls React DevTools with absoluteProjectRoots. + // If the filename is absolute then we don't need to care about this. + var filePath = [maybeRelativePath] + .concat( + absoluteProjectRoots.map(root => path.join(root, maybeRelativePath)) + ).find(combinedPath => + fs.existsSync(combinedPath) + ); + + if (!filePath) { return; } diff --git a/packages/react-devtools-core/src/standalone.js b/packages/react-devtools-core/src/standalone.js index a0e6790543..529759dcec 100644 --- a/packages/react-devtools-core/src/standalone.js +++ b/packages/react-devtools-core/src/standalone.js @@ -22,6 +22,7 @@ var ReactDOM = require('react-dom'); var node = null; var onStatusChange = function noop() {}; +var projectRoots = []; var wall = null; var config = { @@ -31,7 +32,7 @@ var config = { done(wall); }, showElementSource(source) { - launchEditor(source.fileName, source.lineNumber); + launchEditor(source.fileName, source.lineNumber, projectRoots); }, }; @@ -170,6 +171,10 @@ var DevtoolsUI = { return DevtoolsUI; }, + setProjectRoots(_projectRoots) { + projectRoots = _projectRoots; + }, + setStatusListener(_listener) { onStatusChange = _listener; return DevtoolsUI; diff --git a/packages/react-devtools/app.html b/packages/react-devtools/app.html index 0b0d06b516..74a5979257 100644 --- a/packages/react-devtools/app.html +++ b/packages/react-devtools/app.html @@ -101,6 +101,7 @@