Skip to content

Commit

Permalink
Make nicer stacks DEV-only
Browse files Browse the repository at this point in the history
No need to spend production bytes on this.
  • Loading branch information
gaearon committed Aug 9, 2018
1 parent 54d86eb commit d59b993
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/shared/describeComponentFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ export default function(
if (source) {
let path = source.fileName;
let fileName = path.replace(BEFORE_SLASH_RE, '');
if (/^index\./.test(fileName)) {
// Special case: include closest folder name for `index.*` filenames.
const match = path.match(BEFORE_SLASH_RE);
if (match) {
const pathBeforeSlash = match[1];
if (pathBeforeSlash) {
const folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
fileName = folderName + '/' + fileName;
if (__DEV__) {
// In DEV, include code for a common special case:
// prefer "folder/index.js" instead of just "index.js".
if (/^index\./.test(fileName)) {
const match = path.match(BEFORE_SLASH_RE);
if (match) {
const pathBeforeSlash = match[1];
if (pathBeforeSlash) {
const folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
fileName = folderName + '/' + fileName;
}
}
}
}
Expand Down

0 comments on commit d59b993

Please sign in to comment.