Skip to content

feat: add @tanstack/marko-store - a Marko v6 adapter for TanStack Store - #340

Open
defunkt-dev wants to merge 38 commits into
TanStack:alphafrom
defunkt-dev:main
Open

defunkt-dev wants to merge 38 commits into
TanStack:alphafrom
defunkt-dev:main

Conversation

@defunkt-dev

@defunkt-dev defunkt-dev commented Jun 30, 2026 •

Copy link
Copy Markdown

Summary

This PR adds @tanstack/marko-store, a Marko v6 adapter for @tanstack/store, alongside the existing react / solid / svelte / vue / angular / preact / lit adapters in the monorepo. It exposes the store API as idiomatic Marko tags, re-exports the framework-agnostic @tanstack/store core, and supports Marko's full rendering model: client rendering, SSR with resume, per-request isolation, and progressive (out-of-order) streaming.

What's added

Package: packages/marko-store

Five tags plus a small internal helper:

  • <store-provider> — provides a per-request bundle of stores to descendants by a context key.
  • <store-context> — reads the provided bundle (for dispatching actions, etc.).
  • <store-selector> — subscribes to a store or atom and projects a slice, in from mode or context mode.
  • <store-atom> — two-way binding to a single writable atom from createAtom().
  • <stream-store-provider> — a provider for progressive streaming that builds a per-request bundle from data awaited inside a late <await> and keeps it live across the server-to-client boundary.
  • store-bus.ts — an internal publish bus (publishStore / subscribeStorePublish) used to reattach selectors when a provider parks its bundle during resume/streaming.
    The package re-exports the full @tanstack/store core (createStore, createAtom, Store, Derived, shallow, and so on) so Marko users have a single import.

Distribution mirrors the Marko-library convention: the tags ship as raw .marko source (files includes src/tags), so the consumer's Marko tooling reads their types directly. Each tag also ships a hand-written .d.marko declaration for robust type resolution in consumer projects under noUnusedLocals and referenced-file checking; only dist/index.d.ts is tsc-emitted (for the core re-export).

Examples: examples/marko/*

Five client-only parity examples mirroring the sibling adapters: simple, atoms, stores, store-actions, and store-context.

Three Marko-specific SSR examples demonstrating server behavior: ssr-resume (store stays live after resume), ssr-per-request-multi (per-request store isolation), and streaming (progressive streaming with a live store). These run on the standalone @marko/vite dev server; each README notes that a production deployment uses @marko/run (see Known limitations).

Docs: docs/framework/marko/*

A hand-written quick-start.md and a hand-authored tag reference (reference/index.md plus one page per tag under reference/tags/). The reference is hand-authored because the public API is .marko tags, which TypeDoc does not read; see the matching docs/config.json nav entries (Getting Started, Examples, API Reference, Store API Reference).

Design notes

  • Born-with-data (BWD) transport for streamed state. For data that resolves inside a late <await>, the store is created from the awaited value inside the await body; the value crosses to the client through the await subtree's resume scope. Marko's serializedGlobals is unsuitable here because it is written once at the first flush (the shell), before late awaits resolve, so globals set inside a late await read back as null on the client.
  • $global + publish-bus model for context. Context delivery (the bundle) plus a live store reference is modeled on the marko-query adapter's $global + bus pattern, not a tree-scoped context primitive. The bus lets a context-mode <store-selector> reattach the moment its provider parks the bundle during streaming or resume.
  • Content renders after the bundle is parked. <store-provider> and <stream-store-provider> render their content under <if=bundle>. Since Marko 6.4.7 a client-created branch sets up before the values it receives, so without that ordering a child <store-context> could run before the bundle is on the shelf.
  • One provider per key. <store-provider> and <stream-store-provider> share an owner marker on the context key and throw on a duplicate, rather than silently clobbering the same box.
  • Production path is @marko/run. A standalone @marko/vite production build does not coordinate resume for the adapter; @marko/run does. This was verified by building a minimal @marko/run app and confirming store liveness and BWD streaming in a production build under real Chromium.

Testing

  • Unit and characterization tests under jsdom for the tag behaviors.
  • Eight Phase 3 streaming e2e tests in real Chromium across four specs: streaming-liveness and streaming-out-of-order (behavioral), and streaming-fill-render and streaming-fill-onmount (characterization).
  • e2e coverage for SSR resume and per-request isolation.
    All suites pass under the monorepo's test:ci pipeline (package build, marko-type-check, knip, oxlint, jsdom tests, real-Chromium e2e).

Commands to use to test locally:

pnpm --filter @tanstack/marko-store build
pnpm --filter @tanstack/store build && pnpm --filter @tanstack/marko-store test:lib
pnpm --filter @tanstack/marko-store test:oxlint
pnpm --filter @tanstack/marko-store test:types
pnpm run test:ci

## to run e2e tests
cd packages/marko-store
pnpm test:e2e

## use the following to run examples
pnpm --filter @tanstack/store-example-marko-stores dev
pnpm --filter @tanstack/store-example-marko-simple dev
pnpm --filter @tanstack/store-example-marko-atoms dev
pnpm --filter @tanstack/store-example-marko-store-actions dev
pnpm --filter @tanstack/store-example-marko-store-context dev
pnpm --filter @tanstack/store-example-marko-ssr-resume dev
pnpm --filter @tanstack/store-example-marko-ssr-per-request-multi dev
pnpm --filter @tanstack/store-example-marko-streaming dev

Known limitations

  • SSR examples are dev-only. They run under the standalone @marko/vite dev server; a production Marko v6 app uses @marko/run, and the example READMEs say so. (@marko/run is currently beta at 0.11.)
  • No tree-scoped context primitive. Marko v6 has no context primitive that serializes arbitrary values across resume; the adapter uses the $global + bus model in the interim. This tracks Marko core discussion (issue #3155); let-global is the community interim pattern. The adapter solves the constrained case (a serializable bundle plus a live store reference), not general tree-scoped context.
  • Out-of-order streaming uses <try> + <@placeholder>. Marko v6 removed the client-reorder attribute on <await>, so out-of-order streaming is expressed with <try> and a placeholder.

Toolchain

This branch targets alpha, which includes the Oxc and dependency upgrade from #420. marko-store uses oxlint and oxfmt like the other packages, type-checks on TypeScript 6 only, and builds against marko 6.5.2 with @marko/compiler 5.43.6. The changeset is a major bump so the package publishes as 1.0.0-alpha with the other adapters.

Checklist

  • pnpm test:ci green in the monorepo
  • Changeset added (@tanstack/marko-store)
  • Docs nav entries merged into docs/config.json

Note

  • The changeset may look massive, but all of this are under packages/marko-store, examples/marko and docs/framework/marko.
  • A good amount of the files are tests and examples and e2e tests.
  • The actual code is under packages/marko-store/src
  • The additional files are package.json, pnpm-lock.yaml, pnpm-workspace.yaml, docs/config.json , .gitignore, .changeset/, oxfmt.config.ts, oxlint.config.ts and knip.json

@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
Finishing Touches

🧪 Generate unit tests (beta)

  • Create PR with unit tests
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@socket-security

socket-security Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​marko/​language-tools@​3.0.0941007499100
Added@​marko/​type-check@​3.4.0781009599100
Added@​marko/​vite@​6.1.148010010095100
Added@​marko/​run@​0.11.198210010099100
Addedmarko@​6.5.210010094100100
Added@​playwright/​test@​1.65.110010010099100

View full report

* push to show the issue

* fix examples

* fix e2e runs and type checks

* fix builds

* rm consumer-check pkg

* rm consumer-check

* lint

* fix npmrc
@socket-security

socket-security Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Priority Alert  (click "▶" to expand/collapse) Action
Low priority
Low adoption: npm parse-node-args

Location: Package overview

From: examples/marko/atoms/package.json → npm/@marko/run@0.11.19 → npm/parse-node-args@1.1.3

ℹ Read more on: This package | This alert | What are unpopular packages?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Unpopular packages may have less maintenance and contain other problems.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/parse-node-args@1.1.3. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn

View full report

defunkt-dev and others added 3 commits July 16, 2026 01:24
* major reorg, fix files properly for packaging, examples to use marko/run

* update example with more datatypes to denote serialization

* resolve conflicts with main
@changeset-bot

changeset-bot Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 84d099f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/marko-store Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

harry-whorlow and others added 2 commits October 12, 2026 07:10
* feat(core): add compare utils

* ci: apply automated fixes and generate docs

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
@nx-cloud

nx-cloud Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit a553c37

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded <1s View ↗
nx run-many --target=build --exclude=examples/** ✅ Succeeded <1s View ↗

💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-11-23 14:37:20 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
@tanstack/angular-store

npm i https://pkg.pr.new/@tanstack/angular-store@340

@tanstack/lit-store

npm i https://pkg.pr.new/@tanstack/lit-store@340

@tanstack/marko-store

npm i https://pkg.pr.new/@tanstack/marko-store@340

@tanstack/octane-store

npm i https://pkg.pr.new/@tanstack/octane-store@340

@tanstack/preact-store

npm i https://pkg.pr.new/@tanstack/preact-store@340

@tanstack/react-store

npm i https://pkg.pr.new/@tanstack/react-store@340

@tanstack/solid-store

npm i https://pkg.pr.new/@tanstack/solid-store@340

@tanstack/store

npm i https://pkg.pr.new/@tanstack/store@340

@tanstack/svelte-store

npm i https://pkg.pr.new/@tanstack/svelte-store@340

@tanstack/vue-store

npm i https://pkg.pr.new/@tanstack/vue-store@340

commit: a553c37

autofix-ci Bot and others added 5 commits October 17, 2026 15:16
- Update dependencies within the 1-day release-age window (TypeScript stays
  on 6.0.3; Octane 0.23.1 with @tsrx/oxc 0.24.0; Solid 1 kept for the core
  benchmark)
- Drop the TypeScript 5.6-5.8 type-check aliases
- Replace Prettier with oxfmt and ESLint with Oxlint via the shared TanStack
  configs; keep ESLint only for svelte-store template rules
- Port the core benchmark to the Vitest 5 bench fixture and move Octane test
  helpers to octane/internal/client
- Bump nx-set-shas and zizmor action pins
Bring in the alpha branch and the Oxc tooling upgrade. Move marko-store to
oxlint and oxfmt, drop the TypeScript 5.6-5.8 type checks, and update the
Marko toolchain (marko 6.5.2, @marko/compiler 5.43.6, @marko/run 0.11.19,
@marko/language-tools 3, @marko/type-check 3.4).
Marko 6.4.7 sets up a client-created branch before the values it receives,
so a child <store-context> could run before <store-provider> or
<stream-store-provider> put the bundle on the shelf. Render the content
under `<if=bundle>` so Marko orders it after the parking const.

Also release marko-store as a major change so it joins the other adapters
at 1.0.0-alpha, and drop the removed `useStore` from the changeset.
@KevinVandy
KevinVandy requested a review from a team as a code owner November 23, 2026 13:01
@KevinVandy
KevinVandy changed the base branch from main to build/oxc-tooling November 23, 2026 13:01
@KevinVandy
KevinVandy deleted the branch TanStack:build/oxc-tooling November 23, 2026 13:38
@KevinVandy KevinVandy closed this Nov 23, 2026
@KevinVandy KevinVandy reopened this Nov 23, 2026
@KevinVandy
KevinVandy changed the base branch from build/oxc-tooling to alpha November 23, 2026 14:35
# Conflicts:
#	oxfmt.config.ts
#	oxlint.config.ts
#	pnpm-lock.yaml
#	pnpm-workspace.yaml
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.

4 participants