Skip to content

Commit 29b7b77

Browse files
committed
Fix UMD builds by re-exporting the scheduler priorities (facebook#14914)
1 parent b668168 commit 29b7b77

File tree

5 files changed

+81
-2
lines changed

5 files changed

+81
-2
lines changed

packages/react/src/ReactSharedInternals.js

+10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import {
1818
unstable_continueExecution,
1919
unstable_wrapCallback,
2020
unstable_getCurrentPriorityLevel,
21+
unstable_IdlePriority,
22+
unstable_ImmediatePriority,
23+
unstable_LowPriority,
24+
unstable_NormalPriority,
25+
unstable_UserBlockingPriority,
2126
} from 'scheduler';
2227
import {
2328
__interactionsRef,
@@ -60,6 +65,11 @@ if (__UMD__) {
6065
unstable_pauseExecution,
6166
unstable_continueExecution,
6267
unstable_getCurrentPriorityLevel,
68+
unstable_IdlePriority,
69+
unstable_ImmediatePriority,
70+
unstable_LowPriority,
71+
unstable_NormalPriority,
72+
unstable_UserBlockingPriority,
6373
},
6474
SchedulerTracing: {
6575
__interactionsRef,

packages/scheduler/npm/umd/scheduler.development.js

+20
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,25 @@
108108
unstable_continueExecution: unstable_continueExecution,
109109
unstable_pauseExecution: unstable_pauseExecution,
110110
unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
111+
get unstable_IdlePriority() {
112+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
113+
.Scheduler.unstable_IdlePriority;
114+
},
115+
get unstable_ImmediatePriority() {
116+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
117+
.Scheduler.unstable_ImmediatePriority;
118+
},
119+
get unstable_LowPriority() {
120+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
121+
.Scheduler.unstable_LowPriority;
122+
},
123+
get unstable_NormalPriority() {
124+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
125+
.Scheduler.unstable_NormalPriority;
126+
},
127+
get unstable_UserBlockingPriority() {
128+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
129+
.Scheduler.unstable_UserBlockingPriority;
130+
},
111131
});
112132
});

packages/scheduler/npm/umd/scheduler.production.min.js

+20
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,25 @@
102102
unstable_continueExecution: unstable_continueExecution,
103103
unstable_pauseExecution: unstable_pauseExecution,
104104
unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
105+
get unstable_IdlePriority() {
106+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
107+
.Scheduler.unstable_IdlePriority;
108+
},
109+
get unstable_ImmediatePriority() {
110+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
111+
.Scheduler.unstable_ImmediatePriority;
112+
},
113+
get unstable_LowPriority() {
114+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
115+
.Scheduler.unstable_LowPriority;
116+
},
117+
get unstable_NormalPriority() {
118+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
119+
.Scheduler.unstable_NormalPriority;
120+
},
121+
get unstable_UserBlockingPriority() {
122+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
123+
.Scheduler.unstable_UserBlockingPriority;
124+
},
105125
});
106126
});

packages/scheduler/npm/umd/scheduler.profiling.min.js

+20
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,25 @@
102102
unstable_continueExecution: unstable_continueExecution,
103103
unstable_pauseExecution: unstable_pauseExecution,
104104
unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
105+
get unstable_IdlePriority() {
106+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
107+
.Scheduler.unstable_IdlePriority;
108+
},
109+
get unstable_ImmediatePriority() {
110+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
111+
.Scheduler.unstable_ImmediatePriority;
112+
},
113+
get unstable_LowPriority() {
114+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
115+
.Scheduler.unstable_LowPriority;
116+
},
117+
get unstable_NormalPriority() {
118+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
119+
.Scheduler.unstable_NormalPriority;
120+
},
121+
get unstable_UserBlockingPriority() {
122+
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
123+
.Scheduler.unstable_UserBlockingPriority;
124+
},
105125
});
106126
});

packages/scheduler/src/__tests__/SchedulerUMDBundle-test.internal.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@ describe('Scheduling UMD bundle', () => {
1717
});
1818

1919
function filterPrivateKeys(name) {
20-
// TODO: Figure out how to forward priority levels.
21-
return !name.startsWith('_') && !name.endsWith('Priority');
20+
// Be very careful adding things to this whitelist!
21+
// It's easy to introduce bugs by doing it:
22+
// https://github.com/facebook/react/issues/14904
23+
switch (name) {
24+
case '__interactionsRef':
25+
case '__subscriberRef':
26+
// Don't forward these. (TODO: why?)
27+
return false;
28+
default:
29+
return true;
30+
}
2231
}
2332

2433
function validateForwardedAPIs(api, forwardedAPIs) {

0 commit comments

Comments
 (0)