Repository navigation
feat: add @tanstack/marko-store - a Marko v6 adapter for TanStack Store - #340
defunkt-dev wants to merge 38 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
* 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
|
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.
|
* 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 detectedLatest commit: 84d099f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
* 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>
|
View your CI Pipeline Execution ↗ for commit a553c37
💡 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 |
@tanstack/angular-store
@tanstack/lit-store
@tanstack/marko-store
@tanstack/octane-store
@tanstack/preact-store
@tanstack/react-store
@tanstack/solid-store
@tanstack/store
@tanstack/svelte-store
@tanstack/vue-store
commit: |
- 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.
# Conflicts: # oxfmt.config.ts # oxlint.config.ts # pnpm-lock.yaml # pnpm-workspace.yaml
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/storecore, 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-storeFive 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, infrommode orcontextmode.<store-atom>— two-way binding to a single writable atom fromcreateAtom().<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/storecore (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
.markosource (filesincludessrc/tags), so the consumer's Marko tooling reads their types directly. Each tag also ships a hand-written.d.markodeclaration for robust type resolution in consumer projects undernoUnusedLocalsand referenced-file checking; onlydist/index.d.tsistsc-emitted (for the core re-export).Examples:
examples/marko/*Five client-only parity examples mirroring the sibling adapters:
simple,atoms,stores,store-actions, andstore-context.Three Marko-specific SSR examples demonstrating server behavior:
ssr-resume(store stays live after resume),ssr-per-request-multi(per-request store isolation), andstreaming(progressive streaming with a live store). These run on the standalone@marko/vitedev server; each README notes that a production deployment uses@marko/run(see Known limitations).Docs:
docs/framework/marko/*A hand-written
quick-start.mdand a hand-authored tag reference (reference/index.mdplus one page per tag underreference/tags/). The reference is hand-authored because the public API is.markotags, which TypeDoc does not read; see the matchingdocs/config.jsonnav entries (Getting Started, Examples, API Reference, Store API Reference).Design notes
<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'sserializedGlobalsis 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 themarko-queryadapter'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.<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.<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.@marko/run. A standalone@marko/viteproduction build does not coordinate resume for the adapter;@marko/rundoes. This was verified by building a minimal@marko/runapp and confirming store liveness and BWD streaming in a production build under real Chromium.Testing
streaming-livenessandstreaming-out-of-order(behavioral), andstreaming-fill-renderandstreaming-fill-onmount(characterization).All suites pass under the monorepo's
test:cipipeline (package build,marko-type-check, knip, oxlint, jsdom tests, real-Chromium e2e).Commands to use to test locally:
Known limitations
@marko/vitedev server; a production Marko v6 app uses@marko/run, and the example READMEs say so. (@marko/runis currently beta at 0.11.)$global+ bus model in the interim. This tracks Marko core discussion (issue #3155);let-globalis the community interim pattern. The adapter solves the constrained case (a serializable bundle plus a live store reference), not general tree-scoped context.<try>+<@placeholder>. Marko v6 removed theclient-reorderattribute 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/compiler5.43.6. The changeset is a major bump so the package publishes as1.0.0-alphawith the other adapters.Checklist
pnpm test:cigreen in the monorepo@tanstack/marko-store)docs/config.jsonNote
packages/marko-store,examples/markoanddocs/framework/marko.package.json,pnpm-lock.yaml,pnpm-workspace.yaml, docs/config.json ,.gitignore,.changeset/,oxfmt.config.ts,oxlint.config.tsandknip.json