[pull] main from mobxjs:main - #77
Merged
Merged
Conversation
… while serving a cached value (#4694) Observation did not cascade, while unobservation always has. `isBeingObserved` was set only on the observable handed to `reportObserved`, so a computed that gained an observer without recomputing never re-reported its own dependencies and their `onBO()` never fired. Add `markObserved()`, which performs the transition and recurses through `observing_`, and call it from `ComputedValue.get()` on the cache-hit branch only, where the getter will not run and so will not re-report the dependencies itself.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix: ObservableSet.replace only emits events for actual changes ObservableSet.replace previously cleared the set and re-added every value, emitting a delete event for every existing element followed by an add event for every replacement element - even when the contents were unchanged. This also retriggered reactions unnecessarily. It now deletes only the values that are not part of the replacement and adds only the new ones (add/delete are already no-ops for unchanged values), mirroring the behavior of ObservableMap.replace. Closes #3761 * fix(set): address review feedback on ObservableSet.replace Per review on #3761: - Reuse `other` directly when it is already a Set instead of allocating a second one (observable sets are already snapshotted earlier and the Set is only read, never mutated). - Short-circuit the trivial cases: an empty replacement is a plain `clear()`, and replacing into an empty set only needs the adds. - Document the (observable) iteration-order change in the changeset: surviving values now keep their original position and new values are appended rather than the set being reordered to match the argument. - Reorder the replacement arrays in the tests so they assert the resulting iteration order and cover the documented behavior change. --------- Co-authored-by: Michel Weststrate <mweststrate@gmail.com>
…ds (#4695) The generic esm outputs (dist/<pkg>.esm.js and dist/<pkg>.mjs) shipped every __DEV__ check as a live process.env.NODE_ENV read (147 in mobx). process.env is an exotic object in Node, so each read performs a real environment lookup, which unbundled ESM consumers (Node SSR, vitest, RN dev) pay on hot paths. For env-agnostic builds only: skip babel-plugin-dev-expression, rename the free __DEV__ identifier to __MOBX_DEV__, and declare it once via output.intro. All env-set artifacts are byte-identical; 2M observed writes drop from 3324ms to 319ms on Node 26.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
… export condition (#4696) Node ESM consumers previously always loaded dist/<pkg>.mjs: unminified, dev-and-prod code decided per call by 147 live process.env.NODE_ENV reads, and a second module instance for apps that also require('mobx') (#1082 class). Adding a node condition (after react-native, before import) routes Node and Bun to dist/index.js, the existing runtime switch over the prebaked development/production CJS builds: single instance across import/require, env-correct code, working named and default imports via cjs-module-lexer. Bundler paths are unchanged (web ESM still gets .mjs, react-native still gets .esm.js; verified with an enhanced-resolve@5 condition matrix); the one disclosed change besides Node itself is bundlers targeting node, which now bundle the CJS entry. attw: node16-from-ESM goes from 'masquerading as CJS' to consistent CJS.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )