- ObservableSet.replace now preserves the iteration order of surviving values instead of reordering the entire set to match the argument, with newly added values appended
- Evaluate NODE_ENV once at module scope in env-agnostic ESM bundles instead of at every __DEV__ call site, improving observable write performance by roughly 10x in dev mode for consumers using Node ESM, vitest, or SSR
- Fix ObservableSet.replace emitting spurious delete/add events for unchanged values, now only firing delete for removed values and add for newly added ones
From MobX
Patch Changes
-
ec1b708026c1578e1c1f6c7bd90be18b26f7ce85#4695 Thanks @gesposito! - perf: evaluateNODE_ENVonce at module scope in the env-agnostic esm bundles (dist/<pkg>.esm.jsanddist/<pkg>.mjs) instead of at every__DEV__call site.process.envis an exotic object in Node, so each check performed a real environment lookup on hot paths; consumers that execute these files as-is (Node ESM, vitest, SSR) see roughly 10x faster observable writes in dev mode. All env-set artifacts and bundler output are unchanged. -
6d8b5fa6c7596d7e5b16e55e3121d81c0c5bb21a#4672 Thanks @chatman-media! - FixObservableSet.replaceemitting spuriousdelete/addevents (and triggering reactions) for values that are unchanged. It now only firesdeletefor removed values andaddfor newly added ones, mirroringObservableMap.replace.Note: because
replaceno longer clears and re-adds every value, the iteration order afterreplacechanges in a (subtle but observable) way. Surviving values now keep their original relative position and newly added values are appended, instead of the whole set being reordered to match the argument. For example,set(["a", "b", "c"]).replace(["d", "b", "a"])previously iterated asd, b, a, and now iterates asa, b, d. This is arguably the more correct behavior (unchanged values are genuinely unchanged), but if you relied onreplacereordering the set to match its argument, you may need to adjust.