Skip to content

V5 : Split package, formatter support and Jotai 2.20 support#5

Merged
Wendystraite merged 40 commits into
mainfrom
v5_split_core_react_format
May 9, 2026
Merged

V5 : Split package, formatter support and Jotai 2.20 support#5
Wendystraite merged 40 commits into
mainfrom
v5_split_core_react_format

Conversation

@Wendystraite
Copy link
Copy Markdown
Owner

@Wendystraite Wendystraite commented May 2, 2026

Future V5 API.

Checks

  • Splitting Vanilla and React imports
  • Ability to provide a custom formatter
  • Future Jotai 2.20 "rev3" API support
  • Replace jotai and jotai-devtools packages versions in package.json when jotai is out
  • Internal refactor with less hacks to track states

What's new ?

Split the package into vanilla/react/formatter entry points

  • Split the core logger from its console formatter.
  • The core handle only scheduling and filtering options and accepts a new formatter option.
  • The new consoleFormatter factory creates the built in console formatter and accepts the old display options (domain, logger, colorScheme, etc.).
  • Add the formatter option to bindAtomsLoggerToStore and useAtomsLogger to replace the default console output with any custom function.

Replace the mutation-based API with a derived-store API

  • The store is no longer mutated. Instead, createLoggedStore returns a new store that shares all internal state with the parent but intercepts get, set and sub for logging.
  • On the React side, AtomLoggerProvider propagates the logged store to children via a Jotai <Provider>, retrieving the parent store from context automatically.
  • This approach aligns with Jotai's internal INTERNAL_buildStoreRev2 API introduced in jotai v2.15 (see feat(internals): External building blocks surface pmndrs/jotai#3149)).

Jotai 2.20 "Rev3" API support

Waiting for Jotai 2.20 due to a future breaking change in pmndrs/jotai#3293.

See milestone: https://github.com/pmndrs/jotai/milestone/120.

Breaking changes

A migration guide from v4 to v5 is present in the README.

Migration:

  • only jotai 2.20.0 and up is supported due to changes in their internal APIs.
  • formatting options that were present in bindAtomsLoggerToStore and useAtomsLogger are now moved to the new consoleFormatter factory options.
    • Before: bindAtomsLoggerToStore(store, { stringifyLimit: 100 })
    • After: createLoggedStore(store, { formatter: consoleFormatter({ stringifyLimit: 100 }) })
  • useAtomsLogger is replaced by AtomLoggerProvider, a Provider-like component that automatically picks up the nearest Jotai store from context and wraps children in a new logged store.
  • bindAtomsLoggerToStore is replaced by createLoggedStore that creates and return a new store.
  • isAtomsLoggerBoundToStore removed → use isLoggedStore
  • createLoggedStore throws instead of returning false

Split the core logger from its console formatter.
The core handle only scheduling and filtering options and accepts a new `formatter` option.
The new `consoleFormatter` factory creates the built in console formatter and accepts the old display options (`domain`, `logger`, `colorScheme`, etc.).
Add the `formatter` option to `bindAtomsLoggerToStore` and `useAtomsLogger` to replace the default console output with any custom function.

BREAKING CHANGE: formatting options that were present in `bindAtomsLoggerToStore` and `useAtomsLogger` are now moved to the new `consoleFormatter` factory options.
Migration:
Before: `bindAtomsLoggerToStore(store, { stringifyLimit: 100 })`
After: `bindAtomsLoggerToStore(store, { formatter: consoleFormatter({ stringifyLimit: 100 }) })`
@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

BREAKING CHANGE: rename logger's type AtomsLoggerOptions to AtomLoggerOptions
The store is no longer mutated. Instead, `createLoggedStore` returns a **new** store that shares all internal state with the parent but intercepts `get`, `set` and `sub` for logging.
On the React side, `AtomLoggerProvider` propagates the logged store to children via a Jotai `<Provider>`, retrieving the parent store from context automatically.

This approach aligns with Jotai's internal `INTERNAL_buildStoreRev2` API introduced in
jotai v2.15 (see [pmndrs/jotai#3149](pmndrs/jotai#3149)).

BREAKING CHANGE: A migration guide from v4 to v5 is present in the README.
TLDR :
- `useAtomsLogger` is replaced by `AtomLoggerProvider`, a Provider-like component that
automatically picks up the nearest Jotai store from context and wraps children in a new logged store.
- `bindAtomsLoggerToStore` is replaced by `createLoggedStore` that creates and return a new store.
- `isAtomsLoggerBoundToStore` removed → use `isLoggedStore`
- `createLoggedStore` **throws** instead of returning `false`
@Wendystraite Wendystraite force-pushed the v5_split_core_react_format branch from 81dec2c to 934fe14 Compare May 3, 2026 15:17
@Wendystraite Wendystraite changed the title V5 split core react format V5 : Split package, formatter support and Jotai 2.20 support May 3, 2026
Comment thread src/formatters/console/index.ts Outdated
Comment thread package.json Outdated
Comment thread .changeset/sixty-sheep-fetch.md Outdated
Comment thread .changeset/real-cars-nail.md Outdated
Comment thread .changeset/neat-pens-appear.md Outdated
Comment thread src/vanilla/types/transaction.ts Outdated
Comment thread tests/atom-logger.test.ts Outdated
Comment thread src/vanilla/types/event.ts Outdated
Comment thread src/vanilla/types/event.ts
Comment thread src/vanilla/types/event.ts Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md
@Wendystraite Wendystraite force-pushed the v5_split_core_react_format branch from bc683a0 to 62082f6 Compare May 6, 2026 20:38
Comment thread package.json Outdated
Comment thread src/vanilla/callbacks/on-atom-state-map-set.ts Outdated
Comment thread src/vanilla/create-logged-store.ts Outdated
Comment thread src/vanilla/create-logged-store.ts Outdated
Comment thread src/vanilla/create-logged-store.ts Outdated
Comment thread src/vanilla/create-logged-store.ts Outdated
Comment thread src/vanilla/create-logged-store.ts Outdated
Comment thread README.md
Comment thread README.md
Comment thread README.md Outdated
Comment thread src/vanilla/transactions/add-event-to-transaction.ts Outdated
Comment thread src/vanilla/create-logged-store.ts Outdated
Comment thread src/vanilla/transactions/add-event-to-transaction.ts Outdated
Comment thread src/vanilla/callbacks/on-store-sub.ts Outdated
Comment thread src/vanilla/transactions/add-event-to-transaction.ts
Comment thread src/vanilla/transactions/debounce-end-transaction.ts
@Wendystraite Wendystraite marked this pull request as ready for review May 7, 2026 20:13
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 7, 2026

Open in StackBlitz

npm i https://pkg.pr.new/jotai-logger@d363290

commit: d363290

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 7, 2026

🦋 Changeset detected

Latest commit: d363290

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

This PR includes changesets to release 1 package
Name Type
jotai-logger 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

@Wendystraite Wendystraite force-pushed the v5_split_core_react_format branch 4 times, most recently from 0ee3840 to b24ac67 Compare May 7, 2026 20:54
@Wendystraite Wendystraite marked this pull request as draft May 8, 2026 12:21
…mounted events

Initialized, changed and mounted events now show their dependents and pending promises atoms that were added later in the transaction.
This act like how dependencies were tracked.
@Wendystraite Wendystraite marked this pull request as ready for review May 8, 2026 22:10
@Wendystraite Wendystraite force-pushed the v5_split_core_react_format branch from 8849139 to e08d6c1 Compare May 8, 2026 23:26
@Wendystraite Wendystraite force-pushed the v5_split_core_react_format branch from fcf33af to c71a205 Compare May 9, 2026 09:45
@Wendystraite Wendystraite merged commit 5de8975 into main May 9, 2026
3 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.

1 participant