Skip to content

upgrade: map package upgrade for Solid 2.0#937

Open
davedbase wants to merge 5 commits into
solidjs-community:nextfrom
davedbase:update/v2/map
Open

upgrade: map package upgrade for Solid 2.0#937
davedbase wants to merge 5 commits into
solidjs-community:nextfrom
davedbase:update/v2/map

Conversation

@davedbase

@davedbase davedbase commented Jun 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Upgrades @solid-primitives/map to Solid.js ^2.0.0-beta.14
  • Adds interactive Storybook stories
  • Rewrites and expands documentation

Solid 2.0 migration

Implementation (src/index.ts)

  • Removed batch() wrappers from set, delete, and clear — Solid 2.0 auto-batches all signal writes, making them redundant

Tests (test/index.test.ts, test/server.test.ts)

  • Replaced createComputed (removed in 2.0) with createEffect(compute, apply) split form throughout
  • Converted single-argument createEffect calls to the required split form
  • Added flush() after each write before assertions
  • Added test/server.test.ts — 2 SSR safety tests confirming ReactiveMap and ReactiveWeakMap operate correctly on the server (trigger tracking is a no-op via isServer in the underlying TriggerCache)

Package

  • Peer deps: solid-js@^2.0.0-beta.14, @solidjs/web@^2.0.0-beta.14
  • Removed dev script (replaced by Storybook)

Summary by CodeRabbit

  • New Features

    • Added Storybook stories demonstrating ReactiveMap and ReactiveWeakMap usage patterns.
    • Added SSR compatibility verification tests.
  • Documentation

    • Enhanced README with detailed tracking semantics table for all methods.
    • Expanded usage examples emphasizing reference-based updates.
    • Clarified ReactiveWeakMap API constraints and per-key tracking behavior.
  • Chores

    • Updated to support Solid.js v2.0 (beta.14) with improved auto-batching.

@davedbase davedbase added this to the Solid 2.0 Migration milestone Jun 9, 2026
@davedbase davedbase marked this pull request as ready for review June 9, 2026 14:43
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

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

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b6f5b245-b48f-45d8-bec6-5654c1519477

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

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@changeset-bot

changeset-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: aee64ef

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

This PR includes changesets to release 1 package
Name Type
@solid-primitives/map 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

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/map/test/index.test.ts (1)

445-496: ⚡ Quick win

Add a regression case for clear() when an existing key stores undefined.

Please extend this test to assert that get(existingUndefinedKey) does not re-run on clear(). That locks in the intended get() value-change semantics and protects the clear() edge case.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/map/test/index.test.ts` around lines 445 - 496, Add a regression
case that seeds the ReactiveMap with a key whose value is explicitly undefined,
create an effect that depends on map.get(existingUndefinedKey) (use the same
pattern as existingValue/nonexistingValue), call flush and assert the effect ran
once with undefined, then call map.clear() and flush and assert that this
get-effect did NOT re-run (still called once); reference the ReactiveMap
instance, map.get(key) effect, and map.clear() to locate where to add the new
effect and the corresponding expect assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/map/src/index.ts`:
- Around line 121-125: clear() is notifying per-key value subscribers for every
existing key, causing get(key) listeners to run even when the stored value was
already undefined; make clear() mirror delete() semantics by only calling
this.#valueTriggers.dirty(key) for keys whose stored value is not undefined.
Locate the clear() implementation (the loop using for (const key of
super.keys())), and change the logic to check the current value via
this.get(key) (or equivalent) and only call this.#valueTriggers.dirty(key) when
that value !== undefined; still call this.#keyTriggers.dirty(key) for every
existing key as before.

In `@packages/map/stories/map.stories.tsx`:
- Around line 210-222: The clickable row currently implemented as a <div> (the
block using checked.get(item), checked.set(item, !checked.get(item)), colors and
radii) must be changed to a semantic interactive element: replace the <div> with
a <button type="button">, move the inline styles onto the button (preserving
background and border calculations that use checked.get(item)), keep the onClick
handler (checked.set(...)) and also add keyboard/ARIA semantics such as
aria-pressed={checked.get(item)} and remove any default button styles (e.g.,
reset border/background via style) to preserve visuals; this ensures keyboard
users can toggle rows for the element that references checked, item, colors and
radii.

---

Nitpick comments:
In `@packages/map/test/index.test.ts`:
- Around line 445-496: Add a regression case that seeds the ReactiveMap with a
key whose value is explicitly undefined, create an effect that depends on
map.get(existingUndefinedKey) (use the same pattern as
existingValue/nonexistingValue), call flush and assert the effect ran once with
undefined, then call map.clear() and flush and assert that this get-effect did
NOT re-run (still called once); reference the ReactiveMap instance, map.get(key)
effect, and map.clear() to locate where to add the new effect and the
corresponding expect assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1536d47f-7e32-420d-96e0-95def3ed486d

📥 Commits

Reviewing files that changed from the base of the PR and between ce32f63 and 00b75f6.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • .changeset/map-solid2-migration.md
  • packages/map/CHANGELOG.md
  • packages/map/README.md
  • packages/map/dev/index.tsx
  • packages/map/package.json
  • packages/map/src/index.ts
  • packages/map/stories/map.stories.tsx
  • packages/map/test/index.test.ts
  • packages/map/test/server.test.ts
💤 Files with no reviewable changes (1)
  • packages/map/dev/index.tsx

Comment thread packages/map/src/index.ts
Comment thread packages/map/stories/map.stories.tsx Outdated
Comment thread packages/map/src/index.ts
this.#valueTriggers.dirty(key);
}
});
if (hadNoKey || hasChanged) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The surrounding if is actually meaningless.

if (hadNoKey || hasChanged) {
  if (hadNoKey) { ... }
  if (hasChanged) { ... }
}
// has the same effect as:
if (hadNoKey) { ... }
if (hasChanged) { ... }

Comment thread packages/map/src/index.ts
if (hadNoKey) this.#keyTriggers.dirty(key);
if (hasChanged) this.#valueTriggers.dirty(key);
});
if (hadNoKey || hasChanged) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Again, the surrounding if is superfluous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants