Skip to content

fix(core): silence React 19 external store warning - #1644

Merged
ascorbic merged 1 commit into
emdash-cms:mainfrom
masonjames:fix/use-sync-external-store-react19
Jun 29, 2026
Merged

ascorbic merged 1 commit into
emdash-cms:mainfrom
masonjames:fix/use-sync-external-store-react19

Conversation

@masonjames

@masonjames masonjames commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes React 19 dev-console warnings from the visual editing toolbar's transitive use-sync-external-store/shim imports.

EmDash already aliases the shim because Vite can otherwise serve the raw CJS shim from pnpm's virtual store. The remaining issue is that the shim package entry logs a warning in development on React 18+ because it only re-exports React's built-in hook.

This keeps the CJS workaround but points the shim imports, including shim/with-selector, at small absolute ESM shim files shipped with EmDash. The absolute file paths are intentional: Vite/Rolldown dependency optimization applies aliases without EmDash's virtual module plugin, so virtual IDs can become unloadable during pre-bundling.

Issue: none filed.

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main. N/A: no admin UI strings changed.
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: N/A, bug fix.

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: GPT-5 via Codex

Screenshots / test output

  • pnpm lint:json | jq '.diagnostics | length' -> 0
  • pnpm lint:quick -> clean
  • pnpm typecheck -> pass
  • pnpm lint -> pass
  • pnpm format -> ran
  • pnpm --filter emdash test -- run packages/core/tests/unit/astro/vite-config.test.ts packages/core/tests/unit/astro/integration/virtual-modules.test.ts -> pass
  • pnpm build -> pass
  • node scripts/query-counts.mjs --target sqlite --update --skip-seed -> pass; no query-count snapshot diff

Note: pnpm test was run after pnpm build; all packages passed until @emdash-cms/sandbox-workerd, where the existing workerd integration test failed to bind its fixed local port 127.0.0.1:18788 in enforces wall-time limit. The same fixed-port failure reproduced when rerun in isolation and appears unrelated to this React/Vite alias change.

@changeset-bot

changeset-bot Bot commented Jun 28, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f9a5c78

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

This PR includes changesets to release 16 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

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

@github-actions github-actions Bot added area/core size/M review/needs-review No maintainer or bot review yet labels Jun 28, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 28, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@1644

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@1644

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@1644

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@1644

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@1644

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@1644

emdash

npm i https://pkg.pr.new/emdash@1644

create-emdash

npm i https://pkg.pr.new/create-emdash@1644

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@1644

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@1644

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@1644

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@1644

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@1644

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@1644

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@1644

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@1644

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@1644

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@1644

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@1644

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@1644

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@1644

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@1644

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@1644

commit: f9a5c78

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a focused, well-scoped bug fix. The approach is correct: rather than aliasing use-sync-external-store/shim to the package main entry (which logs a React 18+/19 dev warning because it too is a shim path), it routes both known shim entry points to a tiny EmDash virtual ESM module that re-exports useSyncExternalStore directly from react. Since React is EmDash's peer-dep floor, this is the idiomatic React 18+ resolution and preserves the prior CJS workaround that keeps hydration from breaking with pnpm's virtual store.

I checked the virtual module wiring (resolveId and load both updated), the Vite alias ordering (more-specific /shim/index.js still precedes /shim), the optimizeDeps.exclude coverage for virtual:emdash, the peer dependency range (react >= 18.0.0), the updated tests, and the changeset. The implementation is clean, the existing test pattern is followed, and the changeset is user-facing and appropriate. No AGENTS.md conventions are violated: no UI strings changed, no database code touched, no SQL, no route authorization changes.

@masonjames
masonjames force-pushed the fix/use-sync-external-store-react19 branch from 724f38f to f9a5c78 Compare June 28, 2026 21:02
@github-actions github-actions Bot added review/needs-rereview New commits since the last review cla: signed and removed review/needs-review No maintainer or bot review yet labels Jun 28, 2026

@ascorbic ascorbic left a comment

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.

Thanks

@ascorbic
ascorbic merged commit d64c961 into emdash-cms:main Jun 29, 2026
45 checks passed
@emdashbot emdashbot Bot mentioned this pull request Jun 29, 2026
ascorbic added a commit that referenced this pull request Jun 29, 2026
main is at 0.24.0 in package.json with the 0.24.0 changelog written, but
0.24.0 was never published to npm: the release run that should have
published it found these two changesets had raced onto main and prepared
0.24.1 instead, skipping the 0.24.0 publish.

Temporarily remove the two pending changesets so the next Release run sees
no changesets, makes `changeset version` a no-op, and falls through to
`changeset publish` to release the already-versioned 0.24.0 (npm + tag +
GitHub release + plugin tarballs).

These changesets document #1646 and #1644, which belong in 0.24.1. They
are restored in a follow-up PR immediately after 0.24.0 publishes, which
cuts 0.24.1 with their text and attribution intact.
ascorbic added a commit that referenced this pull request Jun 29, 2026
Restores the two changesets temporarily removed in #1651 to publish the
already-versioned 0.24.0. With 0.24.0 now on npm, these belong in 0.24.1.

Each carries pinned `pr:`/`commit:`/`author:` magic lines so
@changesets/changelog-github credits the original PRs and authors
(#1646 / @mvanhorn, #1644 / @masonjames) rather than this release PR.
Without the override it would attribute to the commit that re-added the
files (this PR), losing the contributors' credit.
@emdashbot emdashbot Bot mentioned this pull request Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants