Skip to content

Commit d67658c

Browse files
committed
Fix bundle size
1 parent 4d2f15d commit d67658c

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

packages/react/src/jsx/ReactJSXElement.js

+22-9
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ function getOwner() {
6060
return null;
6161
}
6262

63+
/** @noinline */
64+
function UnknownOwner() {
65+
/** @noinline */
66+
return (() => Error('react-stack-top-frame'))();
67+
}
68+
const createFakeCallStack = {
69+
'react-stack-bottom-frame': function (callStackForError) {
70+
return callStackForError();
71+
},
72+
};
73+
6374
let specialPropKeyWarningShown;
6475
let didWarnAboutElementRef;
6576
let didWarnAboutOldJSXRuntime;
@@ -68,15 +79,13 @@ let unknownOwnerDebugTask;
6879

6980
if (__DEV__) {
7081
didWarnAboutElementRef = {};
71-
const unknownOwnerElement = {
72-
'react-stack-bottom-frame': () => {
73-
return (function UnknownOwner() {
74-
return jsxDEV(() => null, {}, null);
75-
})();
76-
},
77-
}['react-stack-bottom-frame']();
78-
unknownOwnerDebugStack = unknownOwnerElement._debugStack;
79-
unknownOwnerDebugTask = unknownOwnerElement._debugTask;
82+
83+
// We use this technique to trick minifiers to preserve the function name.
84+
unknownOwnerDebugStack = createFakeCallStack['react-stack-bottom-frame'].bind(
85+
createFakeCallStack,
86+
UnknownOwner,
87+
)();
88+
unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
8089
}
8190

8291
function hasValidRef(config) {
@@ -388,6 +397,7 @@ export function jsxProdSignatureRunningInDevWithDynamicChildren(
388397
if (__DEV__) {
389398
const isStaticChildren = false;
390399
const trackActualOwner =
400+
__DEV__ &&
391401
ReactSharedInternals.recentlyCreatedOwnerStacks++ < ownerStackLimit;
392402
return jsxDEVImpl(
393403
type,
@@ -418,6 +428,7 @@ export function jsxProdSignatureRunningInDevWithStaticChildren(
418428
if (__DEV__) {
419429
const isStaticChildren = true;
420430
const trackActualOwner =
431+
__DEV__ &&
421432
ReactSharedInternals.recentlyCreatedOwnerStacks++ < ownerStackLimit;
422433
return jsxDEVImpl(
423434
type,
@@ -448,6 +459,7 @@ const didWarnAboutKeySpread = {};
448459
*/
449460
export function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) {
450461
const trackActualOwner =
462+
__DEV__ &&
451463
ReactSharedInternals.recentlyCreatedOwnerStacks++ < ownerStackLimit;
452464
return jsxDEVImpl(
453465
type,
@@ -731,6 +743,7 @@ export function createElement(type, config, children) {
731743
}
732744
}
733745
const trackActualOwner =
746+
__DEV__ &&
734747
ReactSharedInternals.recentlyCreatedOwnerStacks++ < ownerStackLimit;
735748
return ReactElement(
736749
type,

0 commit comments

Comments
 (0)