Repository navigation
fix(core): watch sandbox plugin entries - #2085
Conversation
🦋 Changeset detectedLatest commit: 9a20ae0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
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 |
There was a problem hiding this comment.
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).
Overlapping PRsThis PR modifies files that are also changed by other open PRs:
This may cause merge conflicts or duplicated work. A maintainer will coordinate. |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
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
Checklist
pnpm --filter emdash typecheckpassesValidation
vitest run tests/unit/astro/integration/virtual-modules.test.ts tests/unit/astro/virtual-modules-sandbox.test.ts- 22 tests passedpnpm --filter emdash typecheckoxlint --type-aware --deny-warningsoxfmt --checkgit diff --check