Skip to content

mobx-view-model 11 - #88

Merged
js2me merged 109 commits into
masterfrom
next-version
Oct 3, 2026
Merged

js2me merged 109 commits into
masterfrom
next-version

Conversation

@js2me

@js2me js2me commented Jul 24, 2026 •

Copy link
Copy Markdown
Owner

Summary by cubic

Splits mobx-view-model into a framework-agnostic core with React bindings in mobx-view-model-react, adds SolidJS support via a new mobx-view-model-solid package, and migrates docs to docusite with versioned v9/v10 content. The ViewModel lifecycle is hardened to fix React 19 lazy/Suspense duplication and orphaning, and framework contexts are namespaced to support microfrontends.

  • Solid bindings in mobx-view-model-solid (powered by mobx-solid): withViewModel, withPropsViewModel, useCreateViewModel, useViewModel, ViewModelsProvider, OnlyViewModel.
  • React lifecycle: explicit Suspense retry-loop detection; stabilized mount/unmount and staged vs committed disposal; SSR mode for useCreateViewModel; regression tests for React 19 lazy/Suspense.
  • Store/API: define(), create(), connect(), unmount(), generateId() replace the attachment lifecycle; stores support an optional resource data source; automatic global ID generation removed; vm metadata exposes vm.state and vm.data; processRender replaces processViewComponent; payload comparison uses a configurable comparer; the disableWrapping option was removed.
  • React/Solid contexts are namespaced per framework and stay microfrontend-friendly; SSR is supported and tested for both bindings.
  • Docs: migrated to docusite; Solid guides added; new Error Version Packages #4 (view already wrapped); v9/v10 versioned content.

Migration/Review notes

  • Import React bindings from mobx-view-model-react; keep core types in mobx-view-model. Use mobx-view-model-solid for Solid.
  • Call withViewModel(VM, View, config?) and pass a plain View; do not pre-wrap with observer or React.memo.
  • In custom stores, override create() instead of createViewModel() and provide an ID when customizing the factory flow.
  • Base implementations now always apply MobX annotations; provide a custom annotation function if you previously disabled wrapping.

Written for commit 35e9336. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 existing issues remain and 8 new issues found across 416 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/vite-plugin/package.json">

<violation number="1" location="packages/vite-plugin/package.json:52">
P2: This range now advertises v11 support, but nothing in this PR verifies the plugin works against v11. The plugin injects runtime code that depends on mobx-view-model internals (`viewModelsConfig.hooks.storeCreate`, `sub`, `lastPub`, `store.viewModels` in store-access.ts), and the plugin's tests run only against the v10 workspace packages (no devDependencies here). If the v11 major changed any of those internals, users on v11 get broken HMR/runtime code while npm considers the peer satisfied. Verify the injected API surface against v11, or add a test/CI matrix entry that runs the plugin against the v11 packages before widening the peer contract.</violation>
</file>

<file name="docs/other/dev-tools.md">

<violation number="1" location="docs/other/dev-tools.md:99">
P3: The new rule "The automatic script and the Vite plugin connect stores for you" contradicts the unchanged "Development-only setup" example at the bottom of this file, which loads `auto.global.js` and then manually calls `ViewModelDevtools.connect(viewModelStore)` in `script.onload`. Users following that section will do the opposite of the new guidance (redundant/double connection). Align the sections: if the auto script auto-connects, drop the manual `connect()` call from the "Development-only setup" example; otherwise, drop the new claim.</violation>
</file>

<file name=".changeset/funky-coins-read.md">

<violation number="1" location=".changeset/funky-coins-read.md:7">
P3: The description uses a backslash as a separator: `react\solid contexts creation`. Changeset summaries are published verbatim into the changelog, so the release notes would render the garbled `react\solid`. Use `react/solid` or `react-solid`.</violation>
</file>

<file name="docs/api/view-models/overview.md">

<violation number="1" location="docs/api/view-models/overview.md:22">
P3: The example's `private userData = /* some data source */;` is not valid TypeScript — a class field initializer cannot be empty (`Expression expected` after `=`). The getters below also read `this.userData.fullName`, so `userData` needs a concrete type to compile. Give the field a real or asserted initializer, e.g. `private userData = null as unknown as { fullName?: string; isLoading: boolean };`.</violation>
</file>

<file name="docs/introduction/usage/with-view-model-store.md">

<violation number="1" location="docs/introduction/usage/with-view-model-store.md:23">
P3: This relative import won't resolve from the React root component: the store is defined (per section 1's fence title) at `/src/shared/lib/mobx/view-model-store.ts`, and `App` is not co-located with it. The same doc uses the `@/` alias elsewhere (e.g. section 4's `@/app-layout`), so import via that alias, or qualify the path relative to the reader's App file.</violation>
</file>

<file name="docs/index.md">

<violation number="1" location="docs/index.md:20">
P2: The icon class changed from `i-logos:mobx-icon` to `i-logos:mobx`. The Iconify `logos` collection names this icon `mobx-icon` (the previous value, still used by the v9/v10 home pages next to `typescript-icon`), and plain `mobx` is not a known entry — the icon will render empty or fail the docs build. Verify the icon name in `@iconify-json/logos` and revert to `mobx-icon` if `mobx` is absent.</violation>
</file>

<file name="docs/recipes/integration-with-root-store.md">

<violation number="1" location="docs/recipes/integration-with-root-store.md:51">
P2: This `create` override drops store-level `vmConfig` (and `config.factory`): unlike `super.create`, it passes the raw `config` straight to `new VM(...)`, so `this.vmConfig` set on the store (e.g. `useDecorators`, `startViewTransitions`, `resource`) is silently ignored for these VMs. Follow the library's own example (examples/csr-react18/src/shared/lib/vm-store.ts) and merge store config before constructing.</violation>
</file>

<file name="packages/solid/vitest.config.ts">

<violation number="1" location="packages/solid/vitest.config.ts:20">
P2: `coverage.include: ['src']` is a bare directory pattern, but vitest matches coverage include entries as globs against file paths relative to the package root, so `src/...` files do not match the literal pattern `src` and the coverage report comes back empty. Use `src/**/*.{ts,tsx}` (or at least `src/**`).</violation>
</file>

Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.
Requires human review: Auto-approval blocked because this review re-detected 4 unresolved issues already reported by Cubic.

Re-trigger cubic

Comment thread packages/react/src/contexts/active-view-context.ts Outdated
Comment thread packages/core/src/config/global-config.ts
Comment thread docs/recipes/integration-with-root-store.md Outdated
Comment thread docs/react/integration.md Outdated
Comment thread packages/solid/package.json Outdated
Comment thread docs/introduction/getting-started.md Outdated
Comment thread docs/api/view-model-store/interface.md Outdated
Comment thread docs/api/view-models/view-models-config.md Outdated
Comment thread docs/index.md
Comment thread docs/api/view-model-store/base-implementation.md Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 22 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread docs/api/view-models/overview.md
Comment thread docs/introduction/usage/with-view-model-store.md Outdated
Comment thread docs/react/integration.md
Comment thread .changeset/fair-vites-support.md Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 30 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread docs/introduction/usage/with-view-model-store.md
Repository owner deleted a comment from cubic-dev-ai Bot Oct 3, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 21 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread docs/api/view-models/base-implementation.md Outdated
Comment thread packages/core/src/view-model/view-model.base.ts
Comment thread packages/core/src/view-model/view-model.base.ts
Comment thread .changeset/public-cities-knock.md Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread docs/api/view-models/base-implementation.md

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 24 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/solid/src/hooks/use-create-view-model.ts
Comment thread packages/solid/src/hooks/use-create-view-model.ts Outdated
Comment thread docs/introduction/getting-started.md

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 1 file (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread docs/docusite.config.ts
@js2me
js2me merged commit 3266f80 into master Oct 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants