Skip to content

fix(core): watch sandbox plugin entries - #2085

Merged
ascorbic merged 1 commit into
emdash-cms:mainfrom
logelog:fix/watch-sandbox-plugin-entries
Jul 17, 2026
Merged

ascorbic merged 1 commit into
emdash-cms:mainfrom
logelog:fix/watch-sandbox-plugin-entries

Conversation

@logelog

@logelog logelog commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Registers each resolved sandbox plugin entry file with Vite's watch graph while generating virtual:emdash/sandboxed-plugins.

Sandbox plugin code is read from disk and embedded into a virtual module. Because the resolved entry was neither statically imported nor registered with addWatchFile, rebuilding a sandbox plugin during development did not invalidate that module. The dev server could therefore continue executing the previous bundle until it was restarted.

The fix keeps module generation unchanged while notifying the Vite load hook about every resolved, built JavaScript entry. A regression test invokes the virtual-module load hook and verifies that the exact resolved entry is watched.

Type of change

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

Checklist

  • I have read CONTRIBUTING.md
  • pnpm --filter emdash typecheck passes
  • Type-aware lint passes for the changed source and test files
  • Targeted tests pass
  • Formatting checks pass
  • I added regression coverage
  • No user-visible strings were added
  • A patch changeset is included

Validation

  • vitest run tests/unit/astro/integration/virtual-modules.test.ts tests/unit/astro/virtual-modules-sandbox.test.ts - 22 tests passed
  • pnpm --filter emdash typecheck
  • changed-file oxlint --type-aware --deny-warnings
  • changed-file oxfmt --check
  • git diff --check

@changeset-bot

changeset-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9a20ae0

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

@logelog
logelog marked this pull request as ready for review July 16, 2026 22:13
@github-actions github-actions Bot added the review/needs-review No maintainer or bot review yet label Jul 16, 2026

@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, correct bug fix with good test coverage. The approach is sound: virtual:emdash/sandboxed-plugins reads sandbox plugin bundles from disk and embeds them, so without a static import Vite had no dependency edge to invalidate the virtual module on rebuild. Passing each resolved entry path to this.addWatchFile() in the load hook is the idiomatic Vite mechanism and keeps module generation untouched.

I checked the changed files, call-sites, the PluginDescriptor shape, the existing sandbox-module tests, and the changeset. The new onEntryResolved callback is optional and backwards-compatible, only invoked after the pre-built-JS guard, and the integration test verifies it is wired to addWatchFile with the exact resolved path. The changeset is correctly named for the emdash package and written for end users. No AGENTS.md violations were found (no DB queries, UI strings, API routes, auth, or localization concerns in this change).

@github-actions

Copy link
Copy Markdown
Contributor

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Jul 17, 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!

@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/auth-atproto

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

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

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

emdash

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

create-emdash

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

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

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

@emdash-cms/plugin-cli

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

@emdash-cms/plugin-types

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

@emdash-cms/registry-client

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

@emdash-cms/registry-lexicons

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

@emdash-cms/registry-verification

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/registry-verification@2085

@emdash-cms/sandbox-workerd

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-field-kit

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: 9a20ae0

@ascorbic
ascorbic merged commit 84173dd into emdash-cms:main Jul 17, 2026
49 checks passed
@emdashbot emdashbot Bot mentioned this pull request Jul 17, 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