Skip to content

Commit d59b993

Browse files
committed
Make nicer stacks DEV-only
No need to spend production bytes on this.
1 parent 54d86eb commit d59b993

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

packages/shared/describeComponentFrame.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ export default function(
1818
if (source) {
1919
let path = source.fileName;
2020
let fileName = path.replace(BEFORE_SLASH_RE, '');
21-
if (/^index\./.test(fileName)) {
22-
// Special case: include closest folder name for `index.*` filenames.
23-
const match = path.match(BEFORE_SLASH_RE);
24-
if (match) {
25-
const pathBeforeSlash = match[1];
26-
if (pathBeforeSlash) {
27-
const folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
28-
fileName = folderName + '/' + fileName;
21+
if (__DEV__) {
22+
// In DEV, include code for a common special case:
23+
// prefer "folder/index.js" instead of just "index.js".
24+
if (/^index\./.test(fileName)) {
25+
const match = path.match(BEFORE_SLASH_RE);
26+
if (match) {
27+
const pathBeforeSlash = match[1];
28+
if (pathBeforeSlash) {
29+
const folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
30+
fileName = folderName + '/' + fileName;
31+
}
2932
}
3033
}
3134
}

0 commit comments

Comments
 (0)