Skip to content

refactor(pages): share adapter build-plugin code that must stay in sync - #673

Merged
cpojer merged 1 commit into
voidzero-dev:mainfrom
yangshun:refactor/shared-adapter-build-plugins
Nov 3, 2026
Merged

cpojer merged 1 commit into
voidzero-dev:mainfrom
yangshun:refactor/shared-adapter-build-plugins

Conversation

@yangshun

@yangshun yangshun commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

The React, Vue, Svelte and Solid adapters each kept their own copy of build-plugin logic that is tied to core contracts. This moves those parts into core as plain helpers. Each adapter keeps its own Vite plugin object and its framework rendering and hydration codegen.

void/pages-islands-plugin

  • createIslandManifest(root, extensions): resolves island imports to ids and pre-scans island pages and layouts. It follows the page scan model, so a new layout kind now needs one change instead of four.
  • islandCssFiles(...) and generateIslandClientEntry(...): the islands client entry's CSS strategy (dev skip, server-recorded styles, fallback) and the initIslands runtime. Adapters pass in what is framework-specific: style-block imports for Vue and Svelte, and the hydrateIsland source.
  • islandsBuildConfig(root, pagesDir): the islands-client build input.
  • mdClientScriptIds(resolvedConfig): the void-md plugin API lookup. computePagesNeedingClientJS now uses it too.

void/pages

  • PrefetchConfig (its cacheFor is now CacheForInput) and PagesPluginOptions. Each adapter's plugin-pages.ts re-exports PrefetchConfig, so the name stays the same.
  • resolvePrefetchConfig(prefetch): the 75 ms / '30s' defaults, which were repeated in four codegen strings.

The adapter plugin-islands.ts files shrink by about 130–180 lines each.

Left in the adapters on purpose

Some code is repeated but differs by framework, or isn't tied to a core contract, so it stays where it is:

  • the island renderer and page renderer/client codegen
  • the island-import transforms and wrapper modules (Svelte's query-encoded wrapper ids, Solid's wrapper metadata, Vue's <script setup> injection)
  • Svelte's style compile plugin and Vue's cssScopeTo handling
  • the useForm warning
  • Vue and Svelte's filename-based hasNonIslandPages (React and Solid use the scan). pages-plugin-adapters.test.ts pins this difference, so unifying it would be a separate behavior change.

Behavior changes

  • In the no-server-build fallback, the list of island CSS files is now recomputed on each buildStart instead of accumulating across buildStart calls. In vite build --watch, a deleted island page's styles stop being imported. A single build is unchanged.
  • Solid's generated islands client entry names its hydrate function hydrateIsland instead of mountIsland. This only changes generated code.
  • resolveSpecifier now accepts a ReadonlyArray of extensions (type widening only).

Generated client and renderer output is otherwise unchanged.

Verification

  • vp run --filter './packages/**' typecheck: all 12 packages pass. A full vp run check also typechecks playgrounds, which need vp run build:all first; I didn't run that locally.
  • Unit tests for every adapter's plugin-islands and plugin-pages, plus pages-plugin-adapters, pages-islands-rescan and island-css-rewrite: 11 files, 175 tests pass.
  • Every islands and pages integration test in the adapter packages and @void/md: 18 files, 259 tests pass.
  • Full vp test run: 732 files pass and 31 fail. None of the failures come from this change:
    • 26 platform suites fail to load because this fresh worktree has no generated platform/packages/dashboard/.void/tsconfig.json.
    • astro dev, vinext-pages dev and cf-build-output timed out under full-suite load. All 3 files pass on their own (54 tests).
    • The health-script failure has the same tsconfig cause.

🤖 Generated with Claude Code

The React, Vue, Svelte and Solid islands and pages plugins each kept their
own copy of logic that is tied to core contracts. Move those parts into
`void/pages-islands-plugin` and `void/pages` as plain helpers; each adapter
keeps its Vite plugin object and its framework rendering and hydration code.

- `createIslandManifest`: island id resolution and the island page/layout
  pre-scan, which follow the page scan model.
- `islandCssFiles`, `generateIslandClientEntry`: the islands client entry's
  CSS strategy and `initIslands` runtime; adapters pass their style-block
  imports and `hydrateIsland` source.
- `islandsBuildConfig`: the `islands-client` build input.
- `mdClientScriptIds`: the `void-md` plugin API lookup.
- `PrefetchConfig`, `PagesPluginOptions`, `resolvePrefetchConfig`: the
  public adapter options and their defaults. Adapters re-export
  `PrefetchConfig`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yangshun
yangshun marked this pull request as draft November 2, 2026 12:48
@yangshun
yangshun marked this pull request as ready for review November 2, 2026 13:13

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

Yay less code.

@cpojer
cpojer merged commit f284a82 into voidzero-dev:main Nov 3, 2026
2 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.

2 participants