mobx 7.0.1 → 7.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mobx.esm.js CHANGED
@@ -1,3 +1,5 @@
1
+ const __MOBX_DEV__ = process.env.NODE_ENV !== "production";
2
+
1
3
  const niceErrors = {
2
4
  0: `Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'`,
3
5
  1(annotationType, key) {
@@ -84,9 +86,9 @@ const niceErrors = {
84
86
  return `'${annotationType}' can only be used with 'makeObservable'`;
85
87
  }
86
88
  };
87
- const errors = process.env.NODE_ENV !== "production" ? niceErrors : {};
89
+ const errors = __MOBX_DEV__ ? niceErrors : {};
88
90
  function die(error, ...args) {
89
- if (process.env.NODE_ENV !== "production") {
91
+ if (__MOBX_DEV__) {
90
92
  let e = typeof error === "string" ? error : errors[error];
91
93
  if (typeof e === "function") e = e.apply(null, args);
92
94
  throw new Error(`[MobX] ${e}`);
@@ -246,7 +248,7 @@ function setFlag(flags, mask, newValue) {
246
248
  }
247
249
 
248
250
  function assert20223DecoratorType(context, types) {
249
- if (process.env.NODE_ENV !== "production" && !types.includes(context.kind)) {
251
+ if (__MOBX_DEV__ && !types.includes(context.kind)) {
250
252
  die(`The decorator applied to '${String(context.name)}' cannot be used on a ${context.kind} element`);
251
253
  }
252
254
  }
@@ -257,7 +259,7 @@ class Atom {
257
259
  * Create a new atom. For debugging purposes it is recommended to give it a name.
258
260
  * The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
259
261
  */
260
- constructor(name_ = process.env.NODE_ENV !== "production" ? "Atom@" + getNextId() : "Atom") {
262
+ constructor(name_ = __MOBX_DEV__ ? "Atom@" + getNextId() : "Atom") {
261
263
  this.name_ = void 0;
262
264
  this.flags_ = 0b000;
263
265
  // Allocated lazily on first observer to save memory.
@@ -412,7 +414,7 @@ function shallowEnhancer(v, _, name) {
412
414
  deep: false
413
415
  });
414
416
  }
415
- if (process.env.NODE_ENV !== "production") {
417
+ if (__MOBX_DEV__) {
416
418
  die("The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets");
417
419
  }
418
420
  }
@@ -421,7 +423,7 @@ function referenceEnhancer(newValue) {
421
423
  return newValue;
422
424
  }
423
425
  function refStructEnhancer(v, oldValue) {
424
- if (process.env.NODE_ENV !== "production" && isObservable(v)) {
426
+ if (__MOBX_DEV__ && isObservable(v)) {
425
427
  die(`observable.struct should not be used with observable values`);
426
428
  }
427
429
  if (deepEqual(v, oldValue)) {
@@ -441,11 +443,11 @@ function isOverride(annotation) {
441
443
  }
442
444
  function make_$6(adm, key) {
443
445
  // Must not be plain object
444
- if (process.env.NODE_ENV !== "production" && adm.isPlainObject_) {
446
+ if (__MOBX_DEV__ && adm.isPlainObject_) {
445
447
  die(`Cannot apply '${this.annotationType_}' to '${adm.name_}.${key.toString()}':` + `\n'${this.annotationType_}' cannot be used on plain objects.`);
446
448
  }
447
449
  // Must override something
448
- if (process.env.NODE_ENV !== "production" && !hasProp(adm.appliedAnnotations_, key)) {
450
+ if (__MOBX_DEV__ && !hasProp(adm.appliedAnnotations_, key)) {
449
451
  die(`'${adm.name_}.${key.toString()}' is annotated with '${this.annotationType_}', ` + `but no such annotated member was found on prototype.`);
450
452
  }
451
453
  return 0 /* MakeResult.Cancel */;
@@ -487,7 +489,7 @@ function extend_$4(adm, key, descriptor, proxyTrap) {
487
489
  return adm.defineProperty_(key, actionDescriptor, proxyTrap);
488
490
  }
489
491
  function decorateAction20223_(annotation, mthd, context) {
490
- if (process.env.NODE_ENV !== "production") {
492
+ if (__MOBX_DEV__) {
491
493
  assert20223DecoratorType(context, ["method", "field"]);
492
494
  }
493
495
  const {
@@ -536,7 +538,7 @@ function assertActionDescriptor(adm, {
536
538
  }, key, {
537
539
  value
538
540
  }) {
539
- if (process.env.NODE_ENV !== "production" && !isFunction(value)) {
541
+ if (__MOBX_DEV__ && !isFunction(value)) {
540
542
  die(`Cannot apply '${annotationType_}' to '${adm.name_}.${key.toString()}':` + `\n'${annotationType_}' can only be used on properties with a function value.`);
541
543
  }
542
544
  }
@@ -604,7 +606,7 @@ function extend_$3(adm, key, descriptor, proxyTrap) {
604
606
  }
605
607
  function decorateFlow20223_(annotation, mthd, context) {
606
608
  var _annotation$options_;
607
- if (process.env.NODE_ENV !== "production") {
609
+ if (__MOBX_DEV__) {
608
610
  assert20223DecoratorType(context, ["method"]);
609
611
  }
610
612
  const {
@@ -629,7 +631,7 @@ function assertFlowDescriptor(adm, {
629
631
  }, key, {
630
632
  value
631
633
  }) {
632
- if (process.env.NODE_ENV !== "production" && !isFunction(value)) {
634
+ if (__MOBX_DEV__ && !isFunction(value)) {
633
635
  die(`Cannot apply '${annotationType_}' to '${adm.name_}.${key.toString()}':` + `\n'${annotationType_}' can only be used on properties with a generator function value.`);
634
636
  }
635
637
  }
@@ -683,7 +685,7 @@ function extend_$2(adm, key, descriptor, proxyTrap) {
683
685
  }), proxyTrap);
684
686
  }
685
687
  function decorateComputed20223_(annotation, get, context) {
686
- if (process.env.NODE_ENV !== "production") {
688
+ if (__MOBX_DEV__) {
687
689
  assert20223DecoratorType(context, ["getter"]);
688
690
  }
689
691
  const ann = annotation;
@@ -700,7 +702,7 @@ function decorateComputed20223_(annotation, get, context) {
700
702
  get,
701
703
  context: target
702
704
  });
703
- options.name || (options.name = process.env.NODE_ENV !== "production" ? `${adm.name_}.${key.toString()}` : `ObservableObject.${key.toString()}`);
705
+ options.name || (options.name = __MOBX_DEV__ ? `${adm.name_}.${key.toString()}` : `ObservableObject.${key.toString()}`);
704
706
  return new ComputedValue(options);
705
707
  }
706
708
  addInitializer(function () {
@@ -734,7 +736,7 @@ function assertComputedDescriptor(adm, {
734
736
  }, key, {
735
737
  get
736
738
  }) {
737
- if (process.env.NODE_ENV !== "production" && !get) {
739
+ if (__MOBX_DEV__ && !get) {
738
740
  die(`Cannot apply '${annotationType_}' to '${adm.name_}.${key.toString()}':` + `\n'${annotationType_}' can only be used on getter(+setter) properties.`);
739
741
  }
740
742
  }
@@ -756,7 +758,7 @@ function extend_$1(adm, key, descriptor, proxyTrap) {
756
758
  return adm.defineObservableProperty_(key, descriptor.value, (_this$options_$enhanc = (_this$options_ = this.options_) == null ? void 0 : _this$options_.enhancer_) != null ? _this$options_$enhanc : deepEnhancer, proxyTrap);
757
759
  }
758
760
  function decorateObservable20223_(annotation, desc, context) {
759
- if (process.env.NODE_ENV !== "production") {
761
+ if (__MOBX_DEV__) {
760
762
  if (context.kind === "field") {
761
763
  throw die(`Please use \`@observable accessor ${String(context.name)}\` instead of \`@observable ${String(context.name)}\``);
762
764
  }
@@ -778,7 +780,7 @@ function decorateObservable20223_(annotation, desc, context) {
778
780
  const adm = asObservableObject(target)[$mobx];
779
781
  ((_adm$lazyObservableKe = adm.lazyObservableKeys_) != null ? _adm$lazyObservableKe : adm.lazyObservableKeys_ = new Map()).set(name, () => {
780
782
  var _ann$options_$enhance, _ann$options_;
781
- return new ObservableValue(value, (_ann$options_$enhance = (_ann$options_ = ann.options_) == null ? void 0 : _ann$options_.enhancer_) != null ? _ann$options_$enhance : deepEnhancer, process.env.NODE_ENV !== "production" ? `${adm.name_}.${name.toString()}` : `ObservableObject.${name.toString()}`, false);
783
+ return new ObservableValue(value, (_ann$options_$enhance = (_ann$options_ = ann.options_) == null ? void 0 : _ann$options_.enhancer_) != null ? _ann$options_$enhance : deepEnhancer, __MOBX_DEV__ ? `${adm.name_}.${name.toString()}` : `ObservableObject.${name.toString()}`, false);
782
784
  });
783
785
  return adm;
784
786
  }
@@ -802,7 +804,7 @@ function decorateObservable20223_(annotation, desc, context) {
802
804
  function assertObservableDescriptor(adm, {
803
805
  annotationType_
804
806
  }, key, descriptor) {
805
- if (process.env.NODE_ENV !== "production" && !("value" in descriptor)) {
807
+ if (__MOBX_DEV__ && !("value" in descriptor)) {
806
808
  die(`Cannot apply '${annotationType_}' to '${adm.name_}.${key.toString()}':` + `\n'${annotationType_}' cannot be used on getter/setter properties`);
807
809
  }
808
810
  }
@@ -893,7 +895,7 @@ function createDecoratorAnnotation(annotation, decorate) {
893
895
  if (context && typeof context.kind === "string") {
894
896
  return decorate(annotation, value, context);
895
897
  }
896
- if (process.env.NODE_ENV !== "production") {
898
+ if (__MOBX_DEV__) {
897
899
  die(`Invalid arguments for \`${annotation.annotationType_}\``);
898
900
  }
899
901
  return undefined;
@@ -1021,7 +1023,7 @@ const computed = function computed(arg1, arg2) {
1021
1023
  return createComputedDecoratorAnnotation(createComputedAnnotation(COMPUTED, arg1));
1022
1024
  }
1023
1025
  // computed(expr, options?)
1024
- if (process.env.NODE_ENV !== "production") {
1026
+ if (__MOBX_DEV__) {
1025
1027
  if (!isFunction(arg1)) {
1026
1028
  die("First argument to `computed` should be an expression.");
1027
1029
  }
@@ -1050,7 +1052,7 @@ const tmpNameDescriptor = {
1050
1052
  enumerable: false
1051
1053
  };
1052
1054
  function createAction(actionName, fn, autoAction = false, ref) {
1053
- if (process.env.NODE_ENV !== "production") {
1055
+ if (__MOBX_DEV__) {
1054
1056
  if (!isFunction(fn)) {
1055
1057
  die("`action` can only be invoked on functions");
1056
1058
  }
@@ -1083,7 +1085,7 @@ function executeAction(actionName, canRunAsDerivation, fn, scope, args) {
1083
1085
  function _startAction(actionName, canRunAsDerivation,
1084
1086
  // true for autoAction
1085
1087
  scope, args) {
1086
- const notifySpy_ = process.env.NODE_ENV !== "production" && isSpyEnabled() && !!actionName;
1088
+ const notifySpy_ = __MOBX_DEV__ && isSpyEnabled() && !!actionName;
1087
1089
  let startTime_ = 0;
1088
1090
  if (notifySpy_) {
1089
1091
  startTime_ = Date.now();
@@ -1101,12 +1103,12 @@ scope, args) {
1101
1103
  let prevAllowStateChanges_ = globalState.allowStateChanges; // by default preserve previous allow
1102
1104
  if (runAsAction) {
1103
1105
  untrackedStart();
1104
- if (process.env.NODE_ENV !== "production") {
1106
+ if (__MOBX_DEV__) {
1105
1107
  prevAllowStateChanges_ = allowStateChangesStart(true);
1106
1108
  }
1107
1109
  }
1108
1110
  const prevAllowStateReads_ = globalState.allowStateReads;
1109
- if (process.env.NODE_ENV !== "production") {
1111
+ if (__MOBX_DEV__) {
1110
1112
  allowStateReadsStart(true);
1111
1113
  }
1112
1114
  const runInfo = {
@@ -1130,7 +1132,7 @@ function _endAction(runInfo) {
1130
1132
  if (runInfo.error_ !== undefined) {
1131
1133
  globalState.suppressReactionErrors = true;
1132
1134
  }
1133
- if (process.env.NODE_ENV !== "production") {
1135
+ if (__MOBX_DEV__) {
1134
1136
  allowStateChangesEnd(runInfo.prevAllowStateChanges_);
1135
1137
  allowStateReadsEnd(runInfo.prevAllowStateReads_);
1136
1138
  }
@@ -1138,7 +1140,7 @@ function _endAction(runInfo) {
1138
1140
  if (runInfo.runAsAction_) {
1139
1141
  untrackedEnd(runInfo.prevDerivation_);
1140
1142
  }
1141
- if (process.env.NODE_ENV !== "production" && runInfo.notifySpy_) {
1143
+ if (__MOBX_DEV__ && runInfo.notifySpy_) {
1142
1144
  spyReportEnd({
1143
1145
  time: Date.now() - runInfo.startTime_
1144
1146
  });
@@ -1164,7 +1166,7 @@ function allowStateChangesEnd(prev) {
1164
1166
 
1165
1167
  const CREATE = "create";
1166
1168
  class ObservableValue extends Atom {
1167
- constructor(value, enhancer_, name_ = process.env.NODE_ENV !== "production" ? "ObservableValue@" + getNextId() : "ObservableValue", notifySpy = true, equals_ = compareDefault) {
1169
+ constructor(value, enhancer_, name_ = __MOBX_DEV__ ? "ObservableValue@" + getNextId() : "ObservableValue", notifySpy = true, equals_ = compareDefault) {
1168
1170
  super(name_);
1169
1171
  this.enhancer_ = void 0;
1170
1172
  this.name_ = void 0;
@@ -1178,7 +1180,7 @@ class ObservableValue extends Atom {
1178
1180
  this.name_ = name_;
1179
1181
  this.equals_ = equals_;
1180
1182
  this.value_ = enhancer_(value, undefined, name_);
1181
- if (process.env.NODE_ENV !== "production" && notifySpy && isSpyEnabled()) {
1183
+ if (__MOBX_DEV__ && notifySpy && isSpyEnabled()) {
1182
1184
  var _this$value_;
1183
1185
  // only notify spy if this is a stand-alone observable
1184
1186
  spyReport({
@@ -1200,8 +1202,8 @@ class ObservableValue extends Atom {
1200
1202
  const oldValue = this.value_;
1201
1203
  newValue = this.prepareNewValue_(newValue);
1202
1204
  if (newValue !== globalState.UNCHANGED) {
1203
- const notifySpy = process.env.NODE_ENV !== "production" && isSpyEnabled();
1204
- if (process.env.NODE_ENV !== "production" && notifySpy) {
1205
+ const notifySpy = __MOBX_DEV__ && isSpyEnabled();
1206
+ if (__MOBX_DEV__ && notifySpy) {
1205
1207
  spyReportStart({
1206
1208
  type: UPDATE,
1207
1209
  object: this,
@@ -1212,7 +1214,7 @@ class ObservableValue extends Atom {
1212
1214
  });
1213
1215
  }
1214
1216
  this.setNewValue_(newValue);
1215
- if (process.env.NODE_ENV !== "production" && notifySpy) {
1217
+ if (__MOBX_DEV__ && notifySpy) {
1216
1218
  spyReportEnd();
1217
1219
  }
1218
1220
  }
@@ -1310,9 +1312,9 @@ class ComputedValue {
1310
1312
  die(31);
1311
1313
  }
1312
1314
  this.derivation = options.get;
1313
- this.name_ = options.name || (process.env.NODE_ENV !== "production" ? "ComputedValue@" + getNextId() : "ComputedValue");
1315
+ this.name_ = options.name || (__MOBX_DEV__ ? "ComputedValue@" + getNextId() : "ComputedValue");
1314
1316
  if (options.set) {
1315
- this.setter_ = createAction(process.env.NODE_ENV !== "production" ? this.name_ + "-setter" : "ComputedValue-setter", options.set);
1317
+ this.setter_ = createAction(__MOBX_DEV__ ? this.name_ + "-setter" : "ComputedValue-setter", options.set);
1316
1318
  }
1317
1319
  this.equals_ = options.equals || compareDefault;
1318
1320
  this.scope_ = options.context;
@@ -1427,7 +1429,7 @@ class ComputedValue {
1427
1429
  const changed = wasSuspended || isCaughtException(oldValue) || isCaughtException(newValue) || !this.equals_(oldValue, newValue);
1428
1430
  if (changed) {
1429
1431
  this.value_ = newValue;
1430
- if (process.env.NODE_ENV !== "production" && isSpyEnabled()) {
1432
+ if (__MOBX_DEV__ && isSpyEnabled()) {
1431
1433
  spyReport({
1432
1434
  observableKind: "computed",
1433
1435
  debugObjectName: this.name_,
@@ -1443,7 +1445,7 @@ class ComputedValue {
1443
1445
  computeValue_(track) {
1444
1446
  this.isComputing = true;
1445
1447
  // don't allow state changes during computation
1446
- const prev = process.env.NODE_ENV !== "production" ? allowStateChangesStart(false) : false;
1448
+ const prev = __MOBX_DEV__ ? allowStateChangesStart(false) : false;
1447
1449
  let res;
1448
1450
  if (track) {
1449
1451
  res = trackDerivedFunction(this, this.derivation, this.scope_);
@@ -1458,7 +1460,7 @@ class ComputedValue {
1458
1460
  }
1459
1461
  }
1460
1462
  }
1461
- if (process.env.NODE_ENV !== "production") {
1463
+ if (__MOBX_DEV__) {
1462
1464
  allowStateChangesEnd(prev);
1463
1465
  }
1464
1466
  this.isComputing = false;
@@ -1471,7 +1473,7 @@ class ComputedValue {
1471
1473
  }
1472
1474
  }
1473
1475
  warnAboutUntrackedRead_() {
1474
- if (!(process.env.NODE_ENV !== "production")) {
1476
+ if (!__MOBX_DEV__) {
1475
1477
  return;
1476
1478
  }
1477
1479
  if (typeof this.requiresReaction_ === "boolean" ? this.requiresReaction_ : globalState.computedRequiresReaction) {
@@ -1521,7 +1523,7 @@ function shouldCompute(derivation) {
1521
1523
  case 1 /* IDerivationState_.POSSIBLY_STALE_ */:
1522
1524
  {
1523
1525
  // state propagation can occur outside of action/reactive context #2195
1524
- const prevAllowStateReads = process.env.NODE_ENV !== "production" ? allowStateReadsStart(true) : true;
1526
+ const prevAllowStateReads = __MOBX_DEV__ ? allowStateReadsStart(true) : true;
1525
1527
  const prevUntracked = untrackedStart(); // no need for those computeds to be reported, they will be picked up in trackDerivedFunction.
1526
1528
  const obs = derivation.observing_,
1527
1529
  l = obs.length;
@@ -1536,7 +1538,7 @@ function shouldCompute(derivation) {
1536
1538
  } catch (e) {
1537
1539
  // we are not interested in the value *or* exception at this moment, but if there is one, notify all
1538
1540
  untrackedEnd(prevUntracked);
1539
- if (process.env.NODE_ENV !== "production") {
1541
+ if (__MOBX_DEV__) {
1540
1542
  allowStateReadsEnd(prevAllowStateReads);
1541
1543
  }
1542
1544
  return true;
@@ -1547,7 +1549,7 @@ function shouldCompute(derivation) {
1547
1549
  // invariantShouldCompute(derivation)
1548
1550
  if (derivation.dependenciesState_ === 2 /* IDerivationState_.STALE_ */) {
1549
1551
  untrackedEnd(prevUntracked);
1550
- if (process.env.NODE_ENV !== "production") {
1552
+ if (__MOBX_DEV__) {
1551
1553
  allowStateReadsEnd(prevAllowStateReads);
1552
1554
  }
1553
1555
  return true;
@@ -1556,7 +1558,7 @@ function shouldCompute(derivation) {
1556
1558
  }
1557
1559
  changeDependenciesStateTo0(derivation);
1558
1560
  untrackedEnd(prevUntracked);
1559
- if (process.env.NODE_ENV !== "production") {
1561
+ if (__MOBX_DEV__) {
1560
1562
  allowStateReadsEnd(prevAllowStateReads);
1561
1563
  }
1562
1564
  return false;
@@ -1567,7 +1569,7 @@ function isComputingDerivation() {
1567
1569
  return globalState.trackingDerivation !== null; // filter out actions inside computations
1568
1570
  }
1569
1571
  function checkIfStateModificationsAreAllowed(atom) {
1570
- if (!(process.env.NODE_ENV !== "production")) {
1572
+ if (!__MOBX_DEV__) {
1571
1573
  return;
1572
1574
  }
1573
1575
  const hasObservers = !!atom.observers_ && atom.observers_.size > 0;
@@ -1577,7 +1579,7 @@ function checkIfStateModificationsAreAllowed(atom) {
1577
1579
  }
1578
1580
  }
1579
1581
  function checkIfStateReadsAreAllowed(observable) {
1580
- if (process.env.NODE_ENV !== "production" && !globalState.allowStateReads && globalState.observableRequiresReaction) {
1582
+ if (__MOBX_DEV__ && !globalState.allowStateReads && globalState.observableRequiresReaction) {
1581
1583
  console.warn(`[mobx] Observable '${observable.name_}' being read outside a reactive context.`);
1582
1584
  }
1583
1585
  }
@@ -1587,7 +1589,7 @@ function checkIfStateReadsAreAllowed(observable) {
1587
1589
  * as observer of any of the accessed observables.
1588
1590
  */
1589
1591
  function trackDerivedFunction(derivation, f, context) {
1590
- const prevAllowStateReads = process.env.NODE_ENV !== "production" ? allowStateReadsStart(true) : true;
1592
+ const prevAllowStateReads = __MOBX_DEV__ ? allowStateReadsStart(true) : true;
1591
1593
  changeDependenciesStateTo0(derivation);
1592
1594
  // Preallocate array; will be trimmed by bindDependencies.
1593
1595
  derivation.newObserving_ = new Array(
@@ -1613,13 +1615,13 @@ function trackDerivedFunction(derivation, f, context) {
1613
1615
  globalState.trackingDerivation = prevTracking;
1614
1616
  bindDependencies(derivation);
1615
1617
  warnAboutDerivationWithoutDependencies(derivation);
1616
- if (process.env.NODE_ENV !== "production") {
1618
+ if (__MOBX_DEV__) {
1617
1619
  allowStateReadsEnd(prevAllowStateReads);
1618
1620
  }
1619
1621
  return result;
1620
1622
  }
1621
1623
  function warnAboutDerivationWithoutDependencies(derivation) {
1622
- if (!(process.env.NODE_ENV !== "production")) {
1624
+ if (!__MOBX_DEV__) {
1623
1625
  return;
1624
1626
  }
1625
1627
  if (derivation.observing_.length !== 0) {
@@ -2136,7 +2138,7 @@ function propagateMaybeChanged(observable) {
2136
2138
  }
2137
2139
 
2138
2140
  class Reaction {
2139
- constructor(name_ = process.env.NODE_ENV !== "production" ? "Reaction@" + getNextId() : "Reaction", onInvalidate_, errorHandler_, requiresObservable_) {
2141
+ constructor(name_ = __MOBX_DEV__ ? "Reaction@" + getNextId() : "Reaction", onInvalidate_, errorHandler_, requiresObservable_) {
2140
2142
  this.name_ = void 0;
2141
2143
  this.onInvalidate_ = void 0;
2142
2144
  this.errorHandler_ = void 0;
@@ -2206,7 +2208,7 @@ class Reaction {
2206
2208
  this.isTrackPending = true;
2207
2209
  try {
2208
2210
  this.onInvalidate_();
2209
- if (process.env.NODE_ENV !== "production" && this.isTrackPending && isSpyEnabled()) {
2211
+ if (__MOBX_DEV__ && this.isTrackPending && isSpyEnabled()) {
2210
2212
  // onInvalidate didn't trigger track right away..
2211
2213
  spyReport({
2212
2214
  name: this.name_,
@@ -2227,9 +2229,9 @@ class Reaction {
2227
2229
  // console.warn("Reaction already disposed") // Note: Not a warning / error in mobx 4 either
2228
2230
  }
2229
2231
  startBatch();
2230
- const notify = process.env.NODE_ENV !== "production" && isSpyEnabled();
2232
+ const notify = __MOBX_DEV__ && isSpyEnabled();
2231
2233
  let startTime;
2232
- if (process.env.NODE_ENV !== "production" && notify) {
2234
+ if (__MOBX_DEV__ && notify) {
2233
2235
  startTime = Date.now();
2234
2236
  spyReportStart({
2235
2237
  name: this.name_,
@@ -2250,7 +2252,7 @@ class Reaction {
2250
2252
  if (isCaughtException(result)) {
2251
2253
  this.reportExceptionInDerivation_(result.cause);
2252
2254
  }
2253
- if (process.env.NODE_ENV !== "production" && notify) {
2255
+ if (__MOBX_DEV__ && notify) {
2254
2256
  spyReportEnd({
2255
2257
  time: Date.now() - startTime
2256
2258
  });
@@ -2265,14 +2267,14 @@ class Reaction {
2265
2267
  if (globalState.disableErrorBoundaries) {
2266
2268
  throw error;
2267
2269
  }
2268
- const message = process.env.NODE_ENV !== "production" ? `[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}'` : `[mobx] uncaught error in '${this}'`;
2270
+ const message = __MOBX_DEV__ ? `[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}'` : `[mobx] uncaught error in '${this}'`;
2269
2271
  if (!globalState.suppressReactionErrors) {
2270
2272
  console.error(message, error);
2271
2273
  /** If debugging brought you here, please, read the above message :-). Tnx! */
2272
- } else if (process.env.NODE_ENV !== "production") {
2274
+ } else if (__MOBX_DEV__) {
2273
2275
  console.warn(`[mobx] (error in reaction '${this.name_}' suppressed, fix error of causing action below)`);
2274
2276
  } // prettier-ignore
2275
- if (process.env.NODE_ENV !== "production" && isSpyEnabled()) {
2277
+ if (__MOBX_DEV__ && isSpyEnabled()) {
2276
2278
  spyReport({
2277
2279
  type: "error",
2278
2280
  name: this.name_,
@@ -2341,7 +2343,7 @@ function runReactionsHelper() {
2341
2343
  // we converge to no remaining reactions after a while.
2342
2344
  while (allReactions.length > 0) {
2343
2345
  if (++iterations === MAX_REACTION_ITERATIONS) {
2344
- console.error(process.env.NODE_ENV !== "production" ? `Reaction doesn't converge to a stable state after ${MAX_REACTION_ITERATIONS} iterations.` + ` Probably there is a cycle in the reactive function: ${allReactions[0]}` : `[mobx] cycle in reaction: ${allReactions[0]}`);
2346
+ console.error(__MOBX_DEV__ ? `Reaction doesn't converge to a stable state after ${MAX_REACTION_ITERATIONS} iterations.` + ` Probably there is a cycle in the reactive function: ${allReactions[0]}` : `[mobx] cycle in reaction: ${allReactions[0]}`);
2345
2347
  allReactions.splice(0); // clear reactions
2346
2348
  }
2347
2349
  let remainingReactions = allReactions.splice(0);
@@ -2358,10 +2360,10 @@ function setReactionScheduler(fn) {
2358
2360
  }
2359
2361
 
2360
2362
  function isSpyEnabled() {
2361
- return process.env.NODE_ENV !== "production" && !!globalState.spyListeners.length;
2363
+ return __MOBX_DEV__ && !!globalState.spyListeners.length;
2362
2364
  }
2363
2365
  function spyReport(event) {
2364
- if (!(process.env.NODE_ENV !== "production")) {
2366
+ if (!__MOBX_DEV__) {
2365
2367
  return;
2366
2368
  } // dead code elimination can do the rest
2367
2369
  if (!globalState.spyListeners.length) {
@@ -2373,7 +2375,7 @@ function spyReport(event) {
2373
2375
  }
2374
2376
  }
2375
2377
  function spyReportStart(event) {
2376
- if (!(process.env.NODE_ENV !== "production")) {
2378
+ if (!__MOBX_DEV__) {
2377
2379
  return;
2378
2380
  }
2379
2381
  const change = assign({}, event, {
@@ -2386,7 +2388,7 @@ const END_EVENT = {
2386
2388
  spyReportEnd: true
2387
2389
  };
2388
2390
  function spyReportEnd(change) {
2389
- if (!(process.env.NODE_ENV !== "production")) {
2391
+ if (!__MOBX_DEV__) {
2390
2392
  return;
2391
2393
  }
2392
2394
  if (change) {
@@ -2399,7 +2401,7 @@ function spyReportEnd(change) {
2399
2401
  }
2400
2402
  }
2401
2403
  function spy(listener) {
2402
- if (!(process.env.NODE_ENV !== "production")) {
2404
+ if (!__MOBX_DEV__) {
2403
2405
  console.warn(`[mobx.spy] Is a no-op in production builds`);
2404
2406
  return function () {};
2405
2407
  } else {
@@ -2449,7 +2451,7 @@ function createActionFactory(autoAction) {
2449
2451
  autoAction
2450
2452
  }));
2451
2453
  }
2452
- if (process.env.NODE_ENV !== "production") {
2454
+ if (__MOBX_DEV__) {
2453
2455
  die("Invalid arguments for `action`");
2454
2456
  }
2455
2457
  };
@@ -2476,7 +2478,7 @@ function isAction(thing) {
2476
2478
  */
2477
2479
  function autorun(view, opts = EMPTY_OBJECT) {
2478
2480
  var _opts$name, _opts$signal;
2479
- if (process.env.NODE_ENV !== "production") {
2481
+ if (__MOBX_DEV__) {
2480
2482
  if (!isFunction(view)) {
2481
2483
  die("Autorun expects a function as first argument");
2482
2484
  }
@@ -2484,7 +2486,7 @@ function autorun(view, opts = EMPTY_OBJECT) {
2484
2486
  die("Autorun does not accept actions since actions are untrackable");
2485
2487
  }
2486
2488
  }
2487
- const name = (_opts$name = opts == null ? void 0 : opts.name) != null ? _opts$name : process.env.NODE_ENV !== "production" ? view.name || "Autorun@" + getNextId() : "Autorun";
2489
+ const name = (_opts$name = opts == null ? void 0 : opts.name) != null ? _opts$name : __MOBX_DEV__ ? view.name || "Autorun@" + getNextId() : "Autorun";
2488
2490
  const runSync = !opts.scheduler && !opts.delay;
2489
2491
  let reaction;
2490
2492
  if (runSync) {
@@ -2522,7 +2524,7 @@ function createSchedulerFromOptions(opts) {
2522
2524
  }
2523
2525
  function reaction(expression, effect, opts = EMPTY_OBJECT) {
2524
2526
  var _opts$name2, _opts$signal2;
2525
- if (process.env.NODE_ENV !== "production") {
2527
+ if (__MOBX_DEV__) {
2526
2528
  if (!isFunction(expression) || !isFunction(effect)) {
2527
2529
  die("First and second argument to reaction should be functions");
2528
2530
  }
@@ -2530,7 +2532,7 @@ function reaction(expression, effect, opts = EMPTY_OBJECT) {
2530
2532
  die("Third argument of reactions should be an object");
2531
2533
  }
2532
2534
  }
2533
- const name = (_opts$name2 = opts.name) != null ? _opts$name2 : process.env.NODE_ENV !== "production" ? "Reaction@" + getNextId() : "Reaction";
2535
+ const name = (_opts$name2 = opts.name) != null ? _opts$name2 : __MOBX_DEV__ ? "Reaction@" + getNextId() : "Reaction";
2534
2536
  const effectAction = action(name, opts.onError ? wrapErrorHandler(opts.onError, effect) : effect);
2535
2537
  const runSync = !opts.scheduler && !opts.delay;
2536
2538
  const scheduler = createSchedulerFromOptions(opts);
@@ -2628,7 +2630,7 @@ function configure(options) {
2628
2630
  }
2629
2631
  });
2630
2632
  globalState.allowStateReads = !globalState.observableRequiresReaction;
2631
- if (process.env.NODE_ENV !== "production" && globalState.disableErrorBoundaries === true) {
2633
+ if (__MOBX_DEV__ && globalState.disableErrorBoundaries === true) {
2632
2634
  console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled.");
2633
2635
  }
2634
2636
  if (options.reactionScheduler) {
@@ -2637,7 +2639,7 @@ function configure(options) {
2637
2639
  }
2638
2640
 
2639
2641
  function extendObservable(target, properties, annotations, options) {
2640
- if (process.env.NODE_ENV !== "production") {
2642
+ if (__MOBX_DEV__) {
2641
2643
  if (arguments.length > 4) {
2642
2644
  die("'extendObservable' expected 2-4 arguments");
2643
2645
  }
@@ -2721,17 +2723,17 @@ const flow = /*#__PURE__*/assign(function flow(arg1, arg2) {
2721
2723
  return decorateFlow20223_(flowAnnotation, arg1, arg2);
2722
2724
  }
2723
2725
  // flow(fn)
2724
- if (process.env.NODE_ENV !== "production" && arguments.length !== 1) {
2726
+ if (__MOBX_DEV__ && arguments.length !== 1) {
2725
2727
  die(`Flow expects single argument with generator function`);
2726
2728
  }
2727
2729
  const generator = arg1;
2728
- const name = generator.name || (process.env.NODE_ENV !== "production" ? "<unnamed flow>" : "flow");
2730
+ const name = generator.name || (__MOBX_DEV__ ? "<unnamed flow>" : "flow");
2729
2731
  // Implementation based on https://github.com/tj/co/blob/master/index.js
2730
2732
  const res = function res() {
2731
2733
  const ctx = this;
2732
2734
  const args = arguments;
2733
- const runId = process.env.NODE_ENV !== "production" ? ++generatorId : 0;
2734
- const gen = action(process.env.NODE_ENV !== "production" ? `${name} - runid: ${runId} - init` : name, generator).apply(ctx, args);
2735
+ const runId = __MOBX_DEV__ ? ++generatorId : 0;
2736
+ const gen = action(__MOBX_DEV__ ? `${name} - runid: ${runId} - init` : name, generator).apply(ctx, args);
2735
2737
  let rejector;
2736
2738
  let pendingPromise = undefined;
2737
2739
  const promise = new Promise(function (resolve, reject) {
@@ -2741,7 +2743,7 @@ const flow = /*#__PURE__*/assign(function flow(arg1, arg2) {
2741
2743
  pendingPromise = undefined;
2742
2744
  let ret;
2743
2745
  try {
2744
- ret = action(process.env.NODE_ENV !== "production" ? `${name} - runid: ${runId} - yield ${stepId++}` : name, gen.next).call(gen, res);
2746
+ ret = action(__MOBX_DEV__ ? `${name} - runid: ${runId} - yield ${stepId++}` : name, gen.next).call(gen, res);
2745
2747
  } catch (e) {
2746
2748
  return reject(e);
2747
2749
  }
@@ -2751,7 +2753,7 @@ const flow = /*#__PURE__*/assign(function flow(arg1, arg2) {
2751
2753
  pendingPromise = undefined;
2752
2754
  let ret;
2753
2755
  try {
2754
- ret = action(process.env.NODE_ENV !== "production" ? `${name} - runid: ${runId} - yield ${stepId++}` : name, gen.throw).call(gen, err);
2756
+ ret = action(__MOBX_DEV__ ? `${name} - runid: ${runId} - yield ${stepId++}` : name, gen.throw).call(gen, err);
2755
2757
  } catch (e) {
2756
2758
  return reject(e);
2757
2759
  }
@@ -2771,7 +2773,7 @@ const flow = /*#__PURE__*/assign(function flow(arg1, arg2) {
2771
2773
  }
2772
2774
  onFulfilled(undefined); // kick off the process
2773
2775
  });
2774
- const cancelActionName = process.env.NODE_ENV !== "production" ? `${name} - runid: ${runId} - cancel` : name;
2776
+ const cancelActionName = __MOBX_DEV__ ? `${name} - runid: ${runId} - cancel` : name;
2775
2777
  promise.cancel = action(cancelActionName, function () {
2776
2778
  try {
2777
2779
  if (pendingPromise) {
@@ -2812,14 +2814,14 @@ function interceptReads(thing, propOrHandler, handler) {
2812
2814
  if (isObservableMap(thing) || isObservableArray(thing) || isObservableValue(thing)) {
2813
2815
  target = getAdministration(thing);
2814
2816
  } else if (isObservableObject(thing)) {
2815
- if (process.env.NODE_ENV !== "production" && !isStringish(propOrHandler)) {
2817
+ if (__MOBX_DEV__ && !isStringish(propOrHandler)) {
2816
2818
  return die(`InterceptReads can only be used with a specific property, not with an object in general`);
2817
2819
  }
2818
2820
  target = getAdministration(thing, propOrHandler);
2819
- } else if (process.env.NODE_ENV !== "production") {
2821
+ } else if (__MOBX_DEV__) {
2820
2822
  return die(`Expected observable map, object or array as first array`);
2821
2823
  }
2822
- if (process.env.NODE_ENV !== "production" && target.dehancer !== undefined) {
2824
+ if (__MOBX_DEV__ && target.dehancer !== undefined) {
2823
2825
  return die(`An intercept reader was already established`);
2824
2826
  }
2825
2827
  target.dehancer = typeof propOrHandler === "function" ? propOrHandler : handler;
@@ -2861,13 +2863,13 @@ function _isComputed(value, property) {
2861
2863
  return isComputedValue(atom);
2862
2864
  }
2863
2865
  function isComputed(value) {
2864
- if (process.env.NODE_ENV !== "production" && arguments.length > 1) {
2866
+ if (__MOBX_DEV__ && arguments.length > 1) {
2865
2867
  return die(`isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`);
2866
2868
  }
2867
2869
  return _isComputed(value);
2868
2870
  }
2869
2871
  function isComputedProp(value, propName) {
2870
- if (process.env.NODE_ENV !== "production" && !isStringish(propName)) {
2872
+ if (__MOBX_DEV__ && !isStringish(propName)) {
2871
2873
  return die(`isComputed expected a property name as second argument`);
2872
2874
  }
2873
2875
  return _isComputed(value, propName);
@@ -2878,7 +2880,7 @@ function _isObservable(value, property) {
2878
2880
  return false;
2879
2881
  }
2880
2882
  if (property !== undefined) {
2881
- if (process.env.NODE_ENV !== "production" && (isObservableMap(value) || isObservableArray(value))) {
2883
+ if (__MOBX_DEV__ && (isObservableMap(value) || isObservableArray(value))) {
2882
2884
  return die("isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.");
2883
2885
  }
2884
2886
  if (isObservableObject(value)) {
@@ -2892,13 +2894,13 @@ function _isObservable(value, property) {
2892
2894
  return isObservableObject(value) || !!value[$mobx] || isAtom(value) || isReaction(value) || isComputedValue(value);
2893
2895
  }
2894
2896
  function isObservable(value) {
2895
- if (process.env.NODE_ENV !== "production" && arguments.length !== 1) {
2897
+ if (__MOBX_DEV__ && arguments.length !== 1) {
2896
2898
  die(`isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property`);
2897
2899
  }
2898
2900
  return _isObservable(value);
2899
2901
  }
2900
2902
  function isObservableProp(value, propName) {
2901
- if (process.env.NODE_ENV !== "production" && !isStringish(propName)) {
2903
+ if (__MOBX_DEV__ && !isStringish(propName)) {
2902
2904
  return die(`expected a property name as second argument`);
2903
2905
  }
2904
2906
  return _isObservable(value, propName);
@@ -3060,15 +3062,15 @@ function observeObservable(thing, listener, fireImmediately) {
3060
3062
  });
3061
3063
  }
3062
3064
  } else if (isObservableMap(thing)) {
3063
- if (process.env.NODE_ENV !== "production" && fireImmediately === true) {
3065
+ if (__MOBX_DEV__ && fireImmediately === true) {
3064
3066
  die("`observe` doesn't support fireImmediately=true in combination with maps.");
3065
3067
  }
3066
3068
  } else if (isObservableSet(thing)) {
3067
- if (process.env.NODE_ENV !== "production" && fireImmediately === true) {
3069
+ if (__MOBX_DEV__ && fireImmediately === true) {
3068
3070
  die("`observe` doesn't support fireImmediately=true in combination with sets.");
3069
3071
  }
3070
3072
  } else if (isObservableObject(thing)) {
3071
- if (process.env.NODE_ENV !== "production" && fireImmediately === true) {
3073
+ if (__MOBX_DEV__ && fireImmediately === true) {
3072
3074
  die("`observe` doesn't support the fire immediately property for observable objects.");
3073
3075
  }
3074
3076
  } else {
@@ -3166,7 +3168,7 @@ function toJSHelper(source, __alreadySeen) {
3166
3168
  * Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
3167
3169
  */
3168
3170
  function toJS(source, options) {
3169
- if (process.env.NODE_ENV !== "production" && options) {
3171
+ if (__MOBX_DEV__ && options) {
3170
3172
  die("toJS no longer supports options");
3171
3173
  }
3172
3174
  return toJSHelper(source, new Map());
@@ -3209,8 +3211,8 @@ function _when(predicate, effect, opts) {
3209
3211
  }
3210
3212
  }, opts.timeout);
3211
3213
  }
3212
- opts.name = process.env.NODE_ENV !== "production" ? opts.name || "When@" + getNextId() : "When";
3213
- const effectAction = createAction(process.env.NODE_ENV !== "production" ? opts.name + "-effect" : "When-effect", effect);
3214
+ opts.name = __MOBX_DEV__ ? opts.name || "When@" + getNextId() : "When";
3215
+ const effectAction = createAction(__MOBX_DEV__ ? opts.name + "-effect" : "When-effect", effect);
3214
3216
  // eslint-disable-next-line
3215
3217
  var disposer = autorun(r => {
3216
3218
  // predicate should not change state
@@ -3227,7 +3229,7 @@ function _when(predicate, effect, opts) {
3227
3229
  }
3228
3230
  function whenPromise(predicate, opts) {
3229
3231
  var _opts$signal;
3230
- if (process.env.NODE_ENV !== "production" && opts && opts.onError) {
3232
+ if (__MOBX_DEV__ && opts && opts.onError) {
3231
3233
  return die(`the options 'onError' and 'promise' cannot be combined`);
3232
3234
  }
3233
3235
  if (opts != null && (_opts$signal = opts.signal) != null && _opts$signal.aborted) {
@@ -3375,7 +3377,7 @@ function makeObservable(target, annotations, options) {
3375
3377
  // proto[keysSymbol] = new Set<PropertyKey>()
3376
3378
  const keysSymbol = /*#__PURE__*/Symbol("mobx-keys");
3377
3379
  function makeAutoObservable(target, overrides, options) {
3378
- if (process.env.NODE_ENV !== "production") {
3380
+ if (__MOBX_DEV__) {
3379
3381
  if (!isPlainObject(target) && !isPlainObject(Object.getPrototypeOf(target))) {
3380
3382
  die(`'makeAutoObservable' can only be used for classes that don't have a superclass`);
3381
3383
  }
@@ -3471,7 +3473,7 @@ const arrayTraps = {
3471
3473
  }
3472
3474
  };
3473
3475
  class ObservableArrayAdministration {
3474
- constructor(name = process.env.NODE_ENV !== "production" ? "ObservableArray@" + getNextId() : "ObservableArray", enhancer, owned_) {
3476
+ constructor(name = __MOBX_DEV__ ? "ObservableArray@" + getNextId() : "ObservableArray", enhancer, owned_) {
3475
3477
  this.owned_ = void 0;
3476
3478
  this.atom_ = void 0;
3477
3479
  this.values_ = [];
@@ -3484,7 +3486,7 @@ class ObservableArrayAdministration {
3484
3486
  this.lastKnownLength_ = 0;
3485
3487
  this.owned_ = owned_;
3486
3488
  this.atom_ = new Atom(name);
3487
- this.enhancer_ = (newV, oldV) => enhancer(newV, oldV, process.env.NODE_ENV !== "production" ? name + "[..]" : "ObservableArray[..]");
3489
+ this.enhancer_ = (newV, oldV) => enhancer(newV, oldV, __MOBX_DEV__ ? name + "[..]" : "ObservableArray[..]");
3488
3490
  }
3489
3491
  dehanceValue_(value) {
3490
3492
  if (this.dehancer !== undefined) {
@@ -3559,7 +3561,7 @@ class ObservableArrayAdministration {
3559
3561
  newItems = change.added;
3560
3562
  }
3561
3563
  newItems = newItems.length === 0 ? newItems : newItems.map(v => this.enhancer_(v, undefined));
3562
- if (process.env.NODE_ENV !== "production") {
3564
+ if (__MOBX_DEV__) {
3563
3565
  const lengthDelta = newItems.length - deleteCount;
3564
3566
  this.updateArrayLength_(length, lengthDelta); // checks if internal array wasn't modified
3565
3567
  }
@@ -3589,7 +3591,7 @@ class ObservableArrayAdministration {
3589
3591
  }
3590
3592
  }
3591
3593
  notifyArrayChildUpdate_(index, newValue, oldValue) {
3592
- const notifySpy = process.env.NODE_ENV !== "production" && !this.owned_ && isSpyEnabled();
3594
+ const notifySpy = __MOBX_DEV__ && !this.owned_ && isSpyEnabled();
3593
3595
  const notify = hasListeners(this);
3594
3596
  const change = notify || notifySpy ? {
3595
3597
  observableKind: "array",
@@ -3602,19 +3604,19 @@ class ObservableArrayAdministration {
3602
3604
  } : null;
3603
3605
  // The reason why this is on right hand side here (and not above), is this way the uglifier will drop it, but it won't
3604
3606
  // cause any runtime overhead in development mode without NODE_ENV set, unless spying is enabled
3605
- if (process.env.NODE_ENV !== "production" && notifySpy) {
3607
+ if (__MOBX_DEV__ && notifySpy) {
3606
3608
  spyReportStart(change);
3607
3609
  }
3608
3610
  this.atom_.reportChanged();
3609
3611
  if (notify) {
3610
3612
  notifyListeners(this, change);
3611
3613
  }
3612
- if (process.env.NODE_ENV !== "production" && notifySpy) {
3614
+ if (__MOBX_DEV__ && notifySpy) {
3613
3615
  spyReportEnd();
3614
3616
  }
3615
3617
  }
3616
3618
  notifyArraySplice_(index, added, removed) {
3617
- const notifySpy = process.env.NODE_ENV !== "production" && !this.owned_ && isSpyEnabled();
3619
+ const notifySpy = __MOBX_DEV__ && !this.owned_ && isSpyEnabled();
3618
3620
  const notify = hasListeners(this);
3619
3621
  const change = notify || notifySpy ? {
3620
3622
  observableKind: "array",
@@ -3627,7 +3629,7 @@ class ObservableArrayAdministration {
3627
3629
  removedCount: removed.length,
3628
3630
  addedCount: added.length
3629
3631
  } : null;
3630
- if (process.env.NODE_ENV !== "production" && notifySpy) {
3632
+ if (__MOBX_DEV__ && notifySpy) {
3631
3633
  spyReportStart(change);
3632
3634
  }
3633
3635
  this.atom_.reportChanged();
@@ -3635,7 +3637,7 @@ class ObservableArrayAdministration {
3635
3637
  if (notify) {
3636
3638
  notifyListeners(this, change);
3637
3639
  }
3638
- if (process.env.NODE_ENV !== "production" && notifySpy) {
3640
+ if (__MOBX_DEV__ && notifySpy) {
3639
3641
  spyReportEnd();
3640
3642
  }
3641
3643
  }
@@ -3680,7 +3682,7 @@ class ObservableArrayAdministration {
3680
3682
  }
3681
3683
  }
3682
3684
  }
3683
- function createObservableArray(initialValues, enhancer, name = process.env.NODE_ENV !== "production" ? "ObservableArray@" + getNextId() : "ObservableArray", owned = false) {
3685
+ function createObservableArray(initialValues, enhancer, name = __MOBX_DEV__ ? "ObservableArray@" + getNextId() : "ObservableArray", owned = false) {
3684
3686
  return initObservable(() => {
3685
3687
  const adm = new ObservableArrayAdministration(name, enhancer, owned);
3686
3688
  addHiddenFinalProp(adm.values_, $mobx, adm);
@@ -3855,7 +3857,7 @@ const DELETE = "delete";
3855
3857
  // just extend Map? See also https://gist.github.com/nestharus/13b4d74f2ef4a2f4357dbd3fc23c1e54
3856
3858
  // But: https://github.com/mobxjs/mobx/issues/1556
3857
3859
  class ObservableMap {
3858
- constructor(initialData, enhancer_ = deepEnhancer, name_ = process.env.NODE_ENV !== "production" ? "ObservableMap@" + getNextId() : "ObservableMap") {
3860
+ constructor(initialData, enhancer_ = deepEnhancer, name_ = __MOBX_DEV__ ? "ObservableMap@" + getNextId() : "ObservableMap") {
3859
3861
  this.enhancer_ = void 0;
3860
3862
  this.name_ = void 0;
3861
3863
  this[$mobx] = ObservableMapMarker;
@@ -3869,7 +3871,7 @@ class ObservableMap {
3869
3871
  this.enhancer_ = enhancer_;
3870
3872
  this.name_ = name_;
3871
3873
  initObservable(() => {
3872
- this.keysAtom_ = createAtom(process.env.NODE_ENV !== "production" ? `${this.name_}.keys()` : "ObservableMap.keys()");
3874
+ this.keysAtom_ = createAtom(__MOBX_DEV__ ? `${this.name_}.keys()` : "ObservableMap.keys()");
3873
3875
  this.data_ = new Map();
3874
3876
  this.hasMap_ = new Map();
3875
3877
  if (initialData) {
@@ -3886,7 +3888,7 @@ class ObservableMap {
3886
3888
  }
3887
3889
  let entry = this.hasMap_.get(key);
3888
3890
  if (!entry) {
3889
- const newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, process.env.NODE_ENV !== "production" ? `${this.name_}.${stringifyKey(key)}?` : "ObservableMap.key?", false);
3891
+ const newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, __MOBX_DEV__ ? `${this.name_}.${stringifyKey(key)}?` : "ObservableMap.key?", false);
3890
3892
  this.hasMap_.set(key, newEntry);
3891
3893
  newEntry.onBUOL = new Set([() => this.hasMap_.delete(key)]);
3892
3894
  }
@@ -3926,7 +3928,7 @@ class ObservableMap {
3926
3928
  }
3927
3929
  }
3928
3930
  if (this.has_(key)) {
3929
- const notifySpy = process.env.NODE_ENV !== "production" && isSpyEnabled();
3931
+ const notifySpy = __MOBX_DEV__ && isSpyEnabled();
3930
3932
  const notify = hasListeners(this);
3931
3933
  const change = notify || notifySpy ? {
3932
3934
  observableKind: "map",
@@ -3936,7 +3938,7 @@ class ObservableMap {
3936
3938
  oldValue: this.data_.get(key).value_,
3937
3939
  name: key
3938
3940
  } : null;
3939
- if (process.env.NODE_ENV !== "production" && notifySpy) {
3941
+ if (__MOBX_DEV__ && notifySpy) {
3940
3942
  spyReportStart(change);
3941
3943
  } // TODO fix type
3942
3944
  transaction(() => {
@@ -3950,7 +3952,7 @@ class ObservableMap {
3950
3952
  if (notify) {
3951
3953
  notifyListeners(this, change);
3952
3954
  }
3953
- if (process.env.NODE_ENV !== "production" && notifySpy) {
3955
+ if (__MOBX_DEV__ && notifySpy) {
3954
3956
  spyReportEnd();
3955
3957
  }
3956
3958
  return true;
@@ -3961,7 +3963,7 @@ class ObservableMap {
3961
3963
  const observable = this.data_.get(key);
3962
3964
  newValue = observable.prepareNewValue_(newValue);
3963
3965
  if (newValue !== globalState.UNCHANGED) {
3964
- const notifySpy = process.env.NODE_ENV !== "production" && isSpyEnabled();
3966
+ const notifySpy = __MOBX_DEV__ && isSpyEnabled();
3965
3967
  const notify = hasListeners(this);
3966
3968
  const change = notify || notifySpy ? {
3967
3969
  observableKind: "map",
@@ -3972,14 +3974,14 @@ class ObservableMap {
3972
3974
  name: key,
3973
3975
  newValue
3974
3976
  } : null;
3975
- if (process.env.NODE_ENV !== "production" && notifySpy) {
3977
+ if (__MOBX_DEV__ && notifySpy) {
3976
3978
  spyReportStart(change);
3977
3979
  } // TODO fix type
3978
3980
  observable.setNewValue_(newValue);
3979
3981
  if (notify) {
3980
3982
  notifyListeners(this, change);
3981
3983
  }
3982
- if (process.env.NODE_ENV !== "production" && notifySpy) {
3984
+ if (__MOBX_DEV__ && notifySpy) {
3983
3985
  spyReportEnd();
3984
3986
  }
3985
3987
  }
@@ -3988,13 +3990,13 @@ class ObservableMap {
3988
3990
  checkIfStateModificationsAreAllowed(this.keysAtom_);
3989
3991
  transaction(() => {
3990
3992
  var _this$hasMap_$get2;
3991
- const observable = new ObservableValue(newValue, this.enhancer_, process.env.NODE_ENV !== "production" ? `${this.name_}.${stringifyKey(key)}` : "ObservableMap.key", false);
3993
+ const observable = new ObservableValue(newValue, this.enhancer_, __MOBX_DEV__ ? `${this.name_}.${stringifyKey(key)}` : "ObservableMap.key", false);
3992
3994
  this.data_.set(key, observable);
3993
3995
  newValue = observable.value_; // value might have been changed
3994
3996
  (_this$hasMap_$get2 = this.hasMap_.get(key)) == null || _this$hasMap_$get2.setNewValue_(true);
3995
3997
  this.keysAtom_.reportChanged();
3996
3998
  });
3997
- const notifySpy = process.env.NODE_ENV !== "production" && isSpyEnabled();
3999
+ const notifySpy = __MOBX_DEV__ && isSpyEnabled();
3998
4000
  const notify = hasListeners(this);
3999
4001
  const change = notify || notifySpy ? {
4000
4002
  observableKind: "map",
@@ -4004,13 +4006,13 @@ class ObservableMap {
4004
4006
  name: key,
4005
4007
  newValue
4006
4008
  } : null;
4007
- if (process.env.NODE_ENV !== "production" && notifySpy) {
4009
+ if (__MOBX_DEV__ && notifySpy) {
4008
4010
  spyReportStart(change);
4009
4011
  } // TODO fix type
4010
4012
  if (notify) {
4011
4013
  notifyListeners(this, change);
4012
4014
  }
4013
- if (process.env.NODE_ENV !== "production" && notifySpy) {
4015
+ if (__MOBX_DEV__ && notifySpy) {
4014
4016
  spyReportEnd();
4015
4017
  }
4016
4018
  }
@@ -4227,7 +4229,7 @@ function convertToMap(dataStructure) {
4227
4229
 
4228
4230
  const ObservableSetMarker = {};
4229
4231
  class ObservableSet {
4230
- constructor(initialData, enhancer = deepEnhancer, name_ = process.env.NODE_ENV !== "production" ? "ObservableSet@" + getNextId() : "ObservableSet") {
4232
+ constructor(initialData, enhancer = deepEnhancer, name_ = __MOBX_DEV__ ? "ObservableSet@" + getNextId() : "ObservableSet") {
4231
4233
  this.name_ = void 0;
4232
4234
  this[$mobx] = ObservableSetMarker;
4233
4235
  this.data_ = new Set();
@@ -4288,7 +4290,7 @@ class ObservableSet {
4288
4290
  this.data_.add(this.enhancer_(value, undefined));
4289
4291
  this.atom_.reportChanged();
4290
4292
  });
4291
- const notifySpy = process.env.NODE_ENV !== "production" && isSpyEnabled();
4293
+ const notifySpy = __MOBX_DEV__ && isSpyEnabled();
4292
4294
  const notify = hasListeners(this);
4293
4295
  const change = notify || notifySpy ? {
4294
4296
  observableKind: "set",
@@ -4297,13 +4299,13 @@ class ObservableSet {
4297
4299
  object: this,
4298
4300
  newValue: value
4299
4301
  } : null;
4300
- if (notifySpy && process.env.NODE_ENV !== "production") {
4302
+ if (notifySpy && __MOBX_DEV__) {
4301
4303
  spyReportStart(change);
4302
4304
  }
4303
4305
  if (notify) {
4304
4306
  notifyListeners(this, change);
4305
4307
  }
4306
- if (notifySpy && process.env.NODE_ENV !== "production") {
4308
+ if (notifySpy && __MOBX_DEV__) {
4307
4309
  spyReportEnd();
4308
4310
  }
4309
4311
  }
@@ -4321,7 +4323,7 @@ class ObservableSet {
4321
4323
  }
4322
4324
  }
4323
4325
  if (this.has(value)) {
4324
- const notifySpy = process.env.NODE_ENV !== "production" && isSpyEnabled();
4326
+ const notifySpy = __MOBX_DEV__ && isSpyEnabled();
4325
4327
  const notify = hasListeners(this);
4326
4328
  const change = notify || notifySpy ? {
4327
4329
  observableKind: "set",
@@ -4330,7 +4332,7 @@ class ObservableSet {
4330
4332
  object: this,
4331
4333
  oldValue: value
4332
4334
  } : null;
4333
- if (notifySpy && process.env.NODE_ENV !== "production") {
4335
+ if (notifySpy && __MOBX_DEV__) {
4334
4336
  spyReportStart(change);
4335
4337
  }
4336
4338
  transaction(() => {
@@ -4340,7 +4342,7 @@ class ObservableSet {
4340
4342
  if (notify) {
4341
4343
  notifyListeners(this, change);
4342
4344
  }
4343
- if (notifySpy && process.env.NODE_ENV !== "production") {
4345
+ if (notifySpy && __MOBX_DEV__) {
4344
4346
  spyReportEnd();
4345
4347
  }
4346
4348
  return true;
@@ -4417,17 +4419,40 @@ class ObservableSet {
4417
4419
  if (isObservableSet(other)) {
4418
4420
  other = new Set(other);
4419
4421
  }
4420
- transaction(() => {
4421
- if (Array.isArray(other)) {
4422
- this.clear();
4423
- other.forEach(value => this.add(value));
4424
- } else if (isES6Set(other)) {
4425
- this.clear();
4426
- other.forEach(value => this.add(value));
4427
- } else if (other !== null && other !== undefined) {
4428
- die(41, other);
4429
- }
4430
- });
4422
+ if (Array.isArray(other) || isES6Set(other)) {
4423
+ // Only emit `delete`/`add` events (and `reportChanged`) for values that
4424
+ // actually change, instead of clearing and re-adding everything. `add` and
4425
+ // `delete` are already no-ops for values that are respectively already
4426
+ // present or already absent, so we just need to avoid deleting values that
4427
+ // are part of the replacement. See #3761.
4428
+ transaction(() => {
4429
+ // Collect the desired values for quick lookup. `other` is already a Set
4430
+ // here when it was passed (or snapshotted from an observable set) as one,
4431
+ // so reuse it rather than allocating another; arrays are wrapped (which
4432
+ // also dedupes them).
4433
+ const replacementValues = isES6Set(other) ? other : new Set(other);
4434
+ // Short-circuit the trivial cases: an empty replacement is just a clear,
4435
+ // and replacing into an empty set only needs the adds.
4436
+ if (replacementValues.size === 0) {
4437
+ this.clear();
4438
+ return;
4439
+ }
4440
+ if (this.data_.size === 0) {
4441
+ replacementValues.forEach(value => this.add(value));
4442
+ return;
4443
+ }
4444
+ // Delete values that are not part of the replacement.
4445
+ for (const value of this.data_.values()) {
4446
+ if (!replacementValues.has(this.dehanceValue_(value))) {
4447
+ this.delete(value);
4448
+ }
4449
+ }
4450
+ // Add new values; values that are already present are a no-op.
4451
+ replacementValues.forEach(value => this.add(value));
4452
+ });
4453
+ } else if (other !== null && other !== undefined) {
4454
+ die(41, other);
4455
+ }
4431
4456
  return this;
4432
4457
  }
4433
4458
  toJSON() {
@@ -4473,13 +4498,13 @@ class ObservableObjectAdministration {
4473
4498
  this.values_ = values_;
4474
4499
  this.name_ = name_;
4475
4500
  this.defaultAnnotation_ = defaultAnnotation_;
4476
- this.keysAtom_ = new Atom(process.env.NODE_ENV !== "production" ? `${this.name_}.keys` : "ObservableObject.keys");
4501
+ this.keysAtom_ = new Atom(__MOBX_DEV__ ? `${this.name_}.keys` : "ObservableObject.keys");
4477
4502
  // Optimization: we use this frequently
4478
4503
  this.isPlainObject_ = isPlainObject(this.target_);
4479
- if (process.env.NODE_ENV !== "production" && !isAnnotation(this.defaultAnnotation_)) {
4504
+ if (__MOBX_DEV__ && !isAnnotation(this.defaultAnnotation_)) {
4480
4505
  die(`defaultAnnotation must be valid annotation`);
4481
4506
  }
4482
- if (process.env.NODE_ENV !== "production") {
4507
+ if (__MOBX_DEV__) {
4483
4508
  // Prepare structure for tracking which fields were already annotated
4484
4509
  this.appliedAnnotations_ = {};
4485
4510
  }
@@ -4542,7 +4567,7 @@ class ObservableObjectAdministration {
4542
4567
  // notify spy & observers
4543
4568
  if (newValue !== globalState.UNCHANGED) {
4544
4569
  const notify = hasListeners(this);
4545
- const notifySpy = process.env.NODE_ENV !== "production" && isSpyEnabled();
4570
+ const notifySpy = __MOBX_DEV__ && isSpyEnabled();
4546
4571
  const change = notify || notifySpy ? {
4547
4572
  type: UPDATE,
4548
4573
  observableKind: "object",
@@ -4552,14 +4577,14 @@ class ObservableObjectAdministration {
4552
4577
  name: key,
4553
4578
  newValue
4554
4579
  } : null;
4555
- if (process.env.NODE_ENV !== "production" && notifySpy) {
4580
+ if (__MOBX_DEV__ && notifySpy) {
4556
4581
  spyReportStart(change);
4557
4582
  }
4558
4583
  observable.setNewValue_(newValue);
4559
4584
  if (notify) {
4560
4585
  notifyListeners(this, change);
4561
4586
  }
4562
- if (process.env.NODE_ENV !== "production" && notifySpy) {
4587
+ if (__MOBX_DEV__ && notifySpy) {
4563
4588
  spyReportEnd();
4564
4589
  }
4565
4590
  }
@@ -4613,7 +4638,7 @@ class ObservableObjectAdministration {
4613
4638
  this.pendingKeys_ || (this.pendingKeys_ = new Map());
4614
4639
  let entry = this.pendingKeys_.get(key);
4615
4640
  if (!entry) {
4616
- entry = new ObservableValue(key in this.target_, referenceEnhancer, process.env.NODE_ENV !== "production" ? `${this.name_}.${stringifyKey(key)}?` : "ObservableObject.key?", false);
4641
+ entry = new ObservableValue(key in this.target_, referenceEnhancer, __MOBX_DEV__ ? `${this.name_}.${stringifyKey(key)}?` : "ObservableObject.key?", false);
4617
4642
  this.pendingKeys_.set(key, entry);
4618
4643
  }
4619
4644
  return entry.get();
@@ -4729,7 +4754,7 @@ class ObservableObjectAdministration {
4729
4754
  } else {
4730
4755
  defineProperty(this.target_, key, descriptor);
4731
4756
  }
4732
- const observable = new ObservableValue(value, enhancer, process.env.NODE_ENV !== "production" ? `${this.name_}.${key.toString()}` : "ObservableObject.key", false);
4757
+ const observable = new ObservableValue(value, enhancer, __MOBX_DEV__ ? `${this.name_}.${key.toString()}` : "ObservableObject.key", false);
4733
4758
  this.values_.set(key, observable);
4734
4759
  // Notify (value possibly changed by ObservableValue)
4735
4760
  this.notifyPropertyAddition_(key, observable.value_);
@@ -4761,7 +4786,7 @@ class ObservableObjectAdministration {
4761
4786
  return null;
4762
4787
  }
4763
4788
  }
4764
- options.name || (options.name = process.env.NODE_ENV !== "production" ? `${this.name_}.${key.toString()}` : "ObservableObject.key");
4789
+ options.name || (options.name = __MOBX_DEV__ ? `${this.name_}.${key.toString()}` : "ObservableObject.key");
4765
4790
  options.context = this.proxy_ || this.target_;
4766
4791
  const cachedDescriptor = getCachedObservablePropDescriptor(key);
4767
4792
  const descriptor = {
@@ -4815,7 +4840,7 @@ class ObservableObjectAdministration {
4815
4840
  var _this$pendingKeys_;
4816
4841
  startBatch();
4817
4842
  const notify = hasListeners(this);
4818
- const notifySpy = process.env.NODE_ENV !== "production" && isSpyEnabled();
4843
+ const notifySpy = __MOBX_DEV__ && isSpyEnabled();
4819
4844
  const observable = this.values_.get(key);
4820
4845
  // Value needed for spies/listeners
4821
4846
  let value = undefined;
@@ -4833,7 +4858,7 @@ class ObservableObjectAdministration {
4833
4858
  delete this.target_[key];
4834
4859
  }
4835
4860
  // Allow re-annotating this field
4836
- if (process.env.NODE_ENV !== "production") {
4861
+ if (__MOBX_DEV__) {
4837
4862
  delete this.appliedAnnotations_[key];
4838
4863
  }
4839
4864
  // Clear observable
@@ -4861,13 +4886,13 @@ class ObservableObjectAdministration {
4861
4886
  oldValue: value,
4862
4887
  name: key
4863
4888
  };
4864
- if (process.env.NODE_ENV !== "production" && notifySpy) {
4889
+ if (__MOBX_DEV__ && notifySpy) {
4865
4890
  spyReportStart(change);
4866
4891
  }
4867
4892
  if (notify) {
4868
4893
  notifyListeners(this, change);
4869
4894
  }
4870
- if (process.env.NODE_ENV !== "production" && notifySpy) {
4895
+ if (__MOBX_DEV__ && notifySpy) {
4871
4896
  spyReportEnd();
4872
4897
  }
4873
4898
  }
@@ -4879,7 +4904,7 @@ class ObservableObjectAdministration {
4879
4904
  notifyPropertyAddition_(key, value) {
4880
4905
  var _this$pendingKeys_2;
4881
4906
  const notify = hasListeners(this);
4882
- const notifySpy = process.env.NODE_ENV !== "production" && isSpyEnabled();
4907
+ const notifySpy = __MOBX_DEV__ && isSpyEnabled();
4883
4908
  if (notify || notifySpy) {
4884
4909
  const change = notify || notifySpy ? {
4885
4910
  type: ADD,
@@ -4889,13 +4914,13 @@ class ObservableObjectAdministration {
4889
4914
  name: key,
4890
4915
  newValue: value
4891
4916
  } : null;
4892
- if (process.env.NODE_ENV !== "production" && notifySpy) {
4917
+ if (__MOBX_DEV__ && notifySpy) {
4893
4918
  spyReportStart(change);
4894
4919
  }
4895
4920
  if (notify) {
4896
4921
  notifyListeners(this, change);
4897
4922
  }
4898
- if (process.env.NODE_ENV !== "production" && notifySpy) {
4923
+ if (__MOBX_DEV__ && notifySpy) {
4899
4924
  spyReportEnd();
4900
4925
  }
4901
4926
  }
@@ -4920,19 +4945,19 @@ class ObservableObjectAdministration {
4920
4945
  }
4921
4946
  function asObservableObject(target, options) {
4922
4947
  var _options$name;
4923
- if (process.env.NODE_ENV !== "production" && options && isObservableObject(target)) {
4948
+ if (__MOBX_DEV__ && options && isObservableObject(target)) {
4924
4949
  die(`Options can't be provided for already observable objects.`);
4925
4950
  }
4926
4951
  if (hasProp(target, $mobx)) {
4927
- if (process.env.NODE_ENV !== "production" && !(getAdministration(target) instanceof ObservableObjectAdministration)) {
4952
+ if (__MOBX_DEV__ && !(getAdministration(target) instanceof ObservableObjectAdministration)) {
4928
4953
  die(`Cannot convert '${getDebugName(target)}' into observable object:` + `\nThe target is already observable of different type.` + `\nExtending builtins is not supported.`);
4929
4954
  }
4930
4955
  return target;
4931
4956
  }
4932
- if (process.env.NODE_ENV !== "production" && !Object.isExtensible(target)) {
4957
+ if (__MOBX_DEV__ && !Object.isExtensible(target)) {
4933
4958
  die("Cannot make the designated object observable; it is not extensible");
4934
4959
  }
4935
- const name = (_options$name = options == null ? void 0 : options.name) != null ? _options$name : process.env.NODE_ENV !== "production" ? `${isPlainObject(target) ? "ObservableObject" : target.constructor.name}@${getNextId()}` : "ObservableObject";
4960
+ const name = (_options$name = options == null ? void 0 : options.name) != null ? _options$name : __MOBX_DEV__ ? `${isPlainObject(target) ? "ObservableObject" : target.constructor.name}@${getNextId()}` : "ObservableObject";
4936
4961
  const adm = new ObservableObjectAdministration(target, new Map(), String(name), getAnnotationFromOptions(options));
4937
4962
  addHiddenProp(target, $mobx, adm);
4938
4963
  return target;
@@ -4955,20 +4980,20 @@ function isObservableObject(thing) {
4955
4980
  return false;
4956
4981
  }
4957
4982
  function recordAnnotationApplied(adm, annotation, key) {
4958
- if (process.env.NODE_ENV !== "production") {
4983
+ if (__MOBX_DEV__) {
4959
4984
  adm.appliedAnnotations_[key] = annotation;
4960
4985
  }
4961
4986
  }
4962
4987
  function assertAnnotable(adm, annotation, key) {
4963
4988
  // Valid annotation
4964
- if (process.env.NODE_ENV !== "production" && !isAnnotation(annotation)) {
4989
+ if (__MOBX_DEV__ && !isAnnotation(annotation)) {
4965
4990
  die(`Cannot annotate '${adm.name_}.${key.toString()}': Invalid annotation.`);
4966
4991
  }
4967
4992
  /*
4968
4993
  // Configurable, not sealed, not frozen
4969
4994
  // Possibly not needed, just a little better error then the one thrown by engine.
4970
4995
  // Cases where this would be useful the most (subclass field initializer) are not interceptable by this.
4971
- if (__DEV__) {
4996
+ if (__MOBX_DEV__) {
4972
4997
  const configurable = getDescriptor(adm.target_, key)?.configurable
4973
4998
  const frozen = Object.isFrozen(adm.target_)
4974
4999
  const sealed = Object.isSealed(adm.target_)
@@ -4995,7 +5020,7 @@ function assertAnnotable(adm, annotation, key) {
4995
5020
  }
4996
5021
  */
4997
5022
  // Not annotated
4998
- if (process.env.NODE_ENV !== "production" && !isOverride(annotation) && hasProp(adm.appliedAnnotations_, key)) {
5023
+ if (__MOBX_DEV__ && !isOverride(annotation) && hasProp(adm.appliedAnnotations_, key)) {
4999
5024
  const fieldName = `${adm.name_}.${key.toString()}`;
5000
5025
  const currentAnnotationType = adm.appliedAnnotations_[key].annotationType_;
5001
5026
  const requestedAnnotationType = annotation.annotationType_;
@@ -5087,13 +5112,13 @@ function getDebugName(thing, property) {
5087
5112
  */
5088
5113
  function initObservable(cb) {
5089
5114
  const derivation = untrackedStart();
5090
- const allowStateChanges = process.env.NODE_ENV !== "production" ? allowStateChangesStart(true) : true;
5115
+ const allowStateChanges = __MOBX_DEV__ ? allowStateChangesStart(true) : true;
5091
5116
  startBatch();
5092
5117
  try {
5093
5118
  return cb();
5094
5119
  } finally {
5095
5120
  endBatch();
5096
- if (process.env.NODE_ENV !== "production") {
5121
+ if (__MOBX_DEV__) {
5097
5122
  allowStateChangesEnd(allowStateChanges);
5098
5123
  }
5099
5124
  untrackedEnd(derivation);
@@ -5285,7 +5310,7 @@ function isAnnotation(thing) {
5285
5310
  * - utils/ Utility stuff.
5286
5311
  *
5287
5312
  */
5288
- if (process.env.NODE_ENV !== "production") {
5313
+ if (__MOBX_DEV__) {
5289
5314
  const g = globalThis;
5290
5315
  ["Symbol", "Map", "Set", "Proxy"].forEach(m => {
5291
5316
  if (typeof g[m] === "undefined") {
@@ -5293,7 +5318,7 @@ if (process.env.NODE_ENV !== "production") {
5293
5318
  }
5294
5319
  });
5295
5320
  }
5296
- if (process.env.NODE_ENV !== "production" && typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__ === "object") {
5321
+ if (__MOBX_DEV__ && typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__ === "object") {
5297
5322
  // See: https://github.com/andykog/mobx-devtools/
5298
5323
  __MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({
5299
5324
  spy,