diff --git a/packages/react/src/plugin-islands.ts b/packages/react/src/plugin-islands.ts
index b91c731b58..8c20a6dc44 100644
--- a/packages/react/src/plugin-islands.ts
+++ b/packages/react/src/plugin-islands.ts
@@ -64,15 +64,25 @@ export function islandsPlugin(pagesDir: string): Plugin[] {
// Pre-scan island pages to populate the manifest eagerly.
// This is needed because the client build may load the virtual
// islands-client entry before island page transforms run.
- for (const page of pageScan.pages) {
- if (!page.island) continue;
- const filePath = resolve(pagesDir, page.componentPath);
+ const importAttrRe =
+ /import\s+\w+\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*\}/g;
+ // Scan both pages AND layouts for island imports
+ const filesToScan: { filePath: string; island: boolean }[] = [
+ ...pageScan.pages.map((p: any) => ({ filePath: p.componentPath, island: p.island })),
+ ...pageScan.layouts.map((l: any) => ({ filePath: l.filePath, island: l.island })),
+ ...pageScan.namedLayouts.map((nl: any) => ({
+ filePath: nl.filePath,
+ island: nl.island,
+ })),
+ ];
+ for (const entry of filesToScan) {
+ if (!entry.island) continue;
+ const filePath = resolve(pagesDir, entry.filePath);
const code = readFileSync(filePath, "utf-8");
const importerDir = dirname(filePath);
- const re =
- /import\s+\w+\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*\}/g;
+ importAttrRe.lastIndex = 0;
let m;
- while ((m = re.exec(code)) !== null) {
+ while ((m = importAttrRe.exec(code)) !== null) {
const spec = m[1].slice(1, -1);
const strategy = m[2].slice(1, -1);
const absPath = resolveSpecifier(spec, importerDir, COMPONENT_EXTENSIONS);
diff --git a/packages/react/test/unit/plugin-islands.test.ts b/packages/react/test/unit/plugin-islands.test.ts
new file mode 100644
index 0000000000..be3f87baa3
--- /dev/null
+++ b/packages/react/test/unit/plugin-islands.test.ts
@@ -0,0 +1,142 @@
+import { describe, expect, it, beforeEach, afterEach } from "vitest";
+import { mkdirSync, writeFileSync, rmSync } from "node:fs";
+import { join } from "node:path";
+import { islandsPlugin } from "../../src/plugin-islands";
+
+const TMP = join(import.meta.dirname, "__tmp_islands_plugin__");
+const PAGES_DIR = join(TMP, "pages");
+
+function writeFile(relativePath: string, content: string): void {
+ const full = join(PAGES_DIR, relativePath);
+ mkdirSync(join(full, ".."), { recursive: true });
+ writeFileSync(full, content);
+}
+
+function setupPlugin() {
+ const plugins = islandsPlugin(PAGES_DIR);
+ const plugin = plugins[0];
+
+ const config = { root: TMP, command: "build" as const, plugins: [] };
+ (plugin as any).configResolved(config);
+
+ return {
+ async buildStart() {
+ await (plugin as any).buildStart.call({});
+ },
+ loadClientEntry(): string | undefined {
+ return (plugin as any).load.handler("\0virtual:void-islands-client");
+ },
+ };
+}
+
+describe("islandsPlugin — layout island import scanning", () => {
+ beforeEach(() => {
+ mkdirSync(PAGES_DIR, { recursive: true });
+ });
+
+ afterEach(() => {
+ rmSync(TMP, { recursive: true, force: true });
+ });
+
+ it("pre-scans island imports from island layouts into the manifest", async () => {
+ writeFile(
+ "blog/layout.island.tsx",
+ `import Counter from "../_components/Counter" with { island: "load" }
+export default function Layout({ children }) { return
{children}
; }`,
+ );
+ writeFile(
+ "blog/index.island.tsx",
+ `export default function Blog() { return Blog
; }`,
+ );
+ writeFile(
+ "_components/Counter.tsx",
+ `export default function Counter() { return 0 ; }`,
+ );
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ expect(clientEntry).toContain("pages/_components/Counter");
+ });
+
+ it("pre-scans island imports from island pages into the manifest", async () => {
+ writeFile(
+ "index.island.tsx",
+ `import Toggle from "./Toggle" with { island: "idle" }
+export default function Home() { return ; }`,
+ );
+ writeFile("Toggle.tsx", `export default function Toggle() { return off ; }`);
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ expect(clientEntry).toContain("pages/Toggle");
+ });
+
+ it("includes island imports from both pages and layouts", async () => {
+ writeFile(
+ "app/layout.island.tsx",
+ `import Nav from "../_components/Nav" with { island: "load" }
+export default function Layout({ children }) { return {children}
; }`,
+ );
+ writeFile(
+ "app/index.island.tsx",
+ `import Widget from "../_components/Widget" with { island: "idle" }
+export default function Index() { return ; }`,
+ );
+ writeFile("_components/Nav.tsx", `export default function Nav() { return ; }`);
+ writeFile("_components/Widget.tsx", `export default function Widget() { return
; }`);
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ expect(clientEntry).toContain("pages/_components/Nav");
+ expect(clientEntry).toContain("pages/_components/Widget");
+ });
+
+ it("pre-scans island imports from named island layouts into the manifest", async () => {
+ writeFile(
+ "_layouts/sidebar.island.tsx",
+ `import Clock from "../_components/Clock" with { island: "load" }
+export default function Sidebar({ children }) { return {children}
; }`,
+ );
+ writeFile(
+ "_components/Clock.tsx",
+ `export default function Clock() { return 12:00 ; }`,
+ );
+ writeFile(
+ "index.island.tsx",
+ `export const layout = "sidebar"
+export default function Home() { return Home
; }`,
+ );
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ expect(clientEntry).toContain("pages/_components/Clock");
+ });
+
+ it("skips non-island layouts during pre-scan", async () => {
+ writeFile(
+ "layout.tsx",
+ `import Sidebar from "./Sidebar" with { island: "load" }
+export default function Layout({ children }) { return {children}
; }`,
+ );
+ writeFile("index.island.tsx", `export default function Home() { return Home
; }`);
+ writeFile("Sidebar.tsx", `export default function Sidebar() { return ; }`);
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).not.toContain("Sidebar");
+ });
+});
diff --git a/packages/solid/src/plugin-islands.ts b/packages/solid/src/plugin-islands.ts
index 8d346a3e05..0b55da4bab 100644
--- a/packages/solid/src/plugin-islands.ts
+++ b/packages/solid/src/plugin-islands.ts
@@ -84,9 +84,18 @@ export function islandsPlugin(pagesDir: string): Plugin[] {
// islands-client entry before island page transforms run.
const importAttrRe =
/import\s+\w+\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*\}/g;
- for (const page of pageScan.pages) {
- if (!page.island) continue;
- const filePath = resolve(pagesDir, page.componentPath);
+ // Scan both pages AND layouts for island imports
+ const filesToScan: { filePath: string; island: boolean }[] = [
+ ...pageScan.pages.map((p: any) => ({ filePath: p.componentPath, island: p.island })),
+ ...pageScan.layouts.map((l: any) => ({ filePath: l.filePath, island: l.island })),
+ ...pageScan.namedLayouts.map((nl: any) => ({
+ filePath: nl.filePath,
+ island: nl.island,
+ })),
+ ];
+ for (const entry of filesToScan) {
+ if (!entry.island) continue;
+ const filePath = resolve(pagesDir, entry.filePath);
const code = readFileSync(filePath, "utf-8");
const importerDir = dirname(filePath);
importAttrRe.lastIndex = 0;
diff --git a/packages/solid/test/unit/plugin-islands.test.ts b/packages/solid/test/unit/plugin-islands.test.ts
new file mode 100644
index 0000000000..9bd34bf568
--- /dev/null
+++ b/packages/solid/test/unit/plugin-islands.test.ts
@@ -0,0 +1,142 @@
+import { describe, expect, it, beforeEach, afterEach } from "vitest";
+import { mkdirSync, writeFileSync, rmSync } from "node:fs";
+import { join } from "node:path";
+import { islandsPlugin } from "../../src/plugin-islands";
+
+const TMP = join(import.meta.dirname, "__tmp_islands_plugin__");
+const PAGES_DIR = join(TMP, "pages");
+
+function writeFile(relativePath: string, content: string): void {
+ const full = join(PAGES_DIR, relativePath);
+ mkdirSync(join(full, ".."), { recursive: true });
+ writeFileSync(full, content);
+}
+
+function setupPlugin() {
+ const plugins = islandsPlugin(PAGES_DIR);
+ const plugin = plugins[0];
+
+ const config = { root: TMP, command: "build" as const, plugins: [] };
+ (plugin as any).configResolved(config);
+
+ return {
+ async buildStart() {
+ await (plugin as any).buildStart.call({});
+ },
+ loadClientEntry(): string | undefined {
+ return (plugin as any).load.handler("\0virtual:void-islands-client");
+ },
+ };
+}
+
+describe("islandsPlugin — layout island import scanning", () => {
+ beforeEach(() => {
+ mkdirSync(PAGES_DIR, { recursive: true });
+ });
+
+ afterEach(() => {
+ rmSync(TMP, { recursive: true, force: true });
+ });
+
+ it("pre-scans island imports from island layouts into the manifest", async () => {
+ writeFile(
+ "blog/layout.island.tsx",
+ `import Counter from "../_components/Counter" with { island: "load" }
+export default function Layout(props) { return {props.children}
; }`,
+ );
+ writeFile(
+ "blog/index.island.tsx",
+ `export default function Blog() { return Blog
; }`,
+ );
+ writeFile(
+ "_components/Counter.tsx",
+ `export default function Counter() { return 0 ; }`,
+ );
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ expect(clientEntry).toContain("pages/_components/Counter");
+ });
+
+ it("pre-scans island imports from island pages into the manifest", async () => {
+ writeFile(
+ "index.island.tsx",
+ `import Toggle from "./Toggle" with { island: "idle" }
+export default function Home() { return ; }`,
+ );
+ writeFile("Toggle.tsx", `export default function Toggle() { return off ; }`);
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ expect(clientEntry).toContain("pages/Toggle");
+ });
+
+ it("includes island imports from both pages and layouts", async () => {
+ writeFile(
+ "app/layout.island.tsx",
+ `import Nav from "../_components/Nav" with { island: "load" }
+export default function Layout(props) { return {props.children}
; }`,
+ );
+ writeFile(
+ "app/index.island.tsx",
+ `import Widget from "../_components/Widget" with { island: "idle" }
+export default function Index() { return ; }`,
+ );
+ writeFile("_components/Nav.tsx", `export default function Nav() { return ; }`);
+ writeFile("_components/Widget.tsx", `export default function Widget() { return
; }`);
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ expect(clientEntry).toContain("pages/_components/Nav");
+ expect(clientEntry).toContain("pages/_components/Widget");
+ });
+
+ it("pre-scans island imports from named island layouts into the manifest", async () => {
+ writeFile(
+ "_layouts/sidebar.island.tsx",
+ `import Clock from "../_components/Clock" with { island: "load" }
+export default function Sidebar(props) { return {props.children}
; }`,
+ );
+ writeFile(
+ "_components/Clock.tsx",
+ `export default function Clock() { return 12:00 ; }`,
+ );
+ writeFile(
+ "index.island.tsx",
+ `export const layout = "sidebar"
+export default function Home() { return Home
; }`,
+ );
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ expect(clientEntry).toContain("pages/_components/Clock");
+ });
+
+ it("skips non-island layouts during pre-scan", async () => {
+ writeFile(
+ "layout.tsx",
+ `import Sidebar from "./Sidebar" with { island: "load" }
+export default function Layout(props) { return {props.children}
; }`,
+ );
+ writeFile("index.island.tsx", `export default function Home() { return Home
; }`);
+ writeFile("Sidebar.tsx", `export default function Sidebar() { return ; }`);
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).not.toContain("Sidebar");
+ });
+});
diff --git a/packages/svelte/src/plugin-islands.ts b/packages/svelte/src/plugin-islands.ts
index ea0c8824e4..d62c633713 100644
--- a/packages/svelte/src/plugin-islands.ts
+++ b/packages/svelte/src/plugin-islands.ts
@@ -74,9 +74,18 @@ export function islandsPlugin(pagesDir: string): Plugin[] {
// islands-client entry before island page transforms run.
const importAttrRe =
/import\s+\w+\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*\}/g;
- for (const page of pageScan.pages) {
- if (!page.island) continue;
- const filePath = resolve(pagesDir, page.componentPath);
+ // Scan both pages AND layouts for island imports
+ const filesToScan: { filePath: string; island: boolean }[] = [
+ ...pageScan.pages.map((p: any) => ({ filePath: p.componentPath, island: p.island })),
+ ...pageScan.layouts.map((l: any) => ({ filePath: l.filePath, island: l.island })),
+ ...pageScan.namedLayouts.map((nl: any) => ({
+ filePath: nl.filePath,
+ island: nl.island,
+ })),
+ ];
+ for (const entry of filesToScan) {
+ if (!entry.island) continue;
+ const filePath = resolve(pagesDir, entry.filePath);
const code = readFileSync(filePath, "utf-8");
const importerDir = dirname(filePath);
importAttrRe.lastIndex = 0;
diff --git a/packages/svelte/test/unit/plugin-islands.test.ts b/packages/svelte/test/unit/plugin-islands.test.ts
new file mode 100644
index 0000000000..ad7e6ca4b6
--- /dev/null
+++ b/packages/svelte/test/unit/plugin-islands.test.ts
@@ -0,0 +1,155 @@
+import { describe, expect, it, beforeEach, afterEach } from "vitest";
+import { mkdirSync, writeFileSync, rmSync } from "node:fs";
+import { join } from "node:path";
+import { islandsPlugin } from "../../src/plugin-islands";
+
+const TMP = join(import.meta.dirname, "__tmp_islands_plugin__");
+const PAGES_DIR = join(TMP, "pages");
+
+function writeFile(relativePath: string, content: string): void {
+ const full = join(PAGES_DIR, relativePath);
+ mkdirSync(join(full, ".."), { recursive: true });
+ writeFileSync(full, content);
+}
+
+function setupPlugin() {
+ const plugins = islandsPlugin(PAGES_DIR);
+ const plugin = plugins[0];
+
+ const config = { root: TMP, command: "build" as const, plugins: [] };
+ (plugin as any).configResolved(config);
+
+ return {
+ async buildStart() {
+ await (plugin as any).buildStart.call({});
+ },
+ loadClientEntry(): string | undefined {
+ return (plugin as any).load.handler("\0virtual:void-islands-client");
+ },
+ };
+}
+
+describe("islandsPlugin — layout island import scanning", () => {
+ beforeEach(() => {
+ mkdirSync(PAGES_DIR, { recursive: true });
+ });
+
+ afterEach(() => {
+ rmSync(TMP, { recursive: true, force: true });
+ });
+
+ it("pre-scans island imports from island layouts into the manifest", async () => {
+ writeFile(
+ "blog/layout.island.svelte",
+ `
+ `,
+ );
+ writeFile("blog/index.island.svelte", `Blog
`);
+ writeFile(
+ "_components/Counter.svelte",
+ `
+ count++}>{count} `,
+ );
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ expect(clientEntry).toContain("pages/_components/Counter");
+ });
+
+ it("pre-scans island imports from island pages into the manifest", async () => {
+ writeFile(
+ "index.island.svelte",
+ `
+ `,
+ );
+ writeFile(
+ "Toggle.svelte",
+ `
+ on = !on}>{on} `,
+ );
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ expect(clientEntry).toContain("pages/Toggle");
+ });
+
+ it("includes island imports from both pages and layouts", async () => {
+ writeFile(
+ "app/layout.island.svelte",
+ `
+ `,
+ );
+ writeFile(
+ "app/index.island.svelte",
+ `
+ `,
+ );
+ writeFile("_components/Nav.svelte", `Nav `);
+ writeFile("_components/Widget.svelte", `Widget
`);
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ expect(clientEntry).toContain("pages/_components/Nav");
+ expect(clientEntry).toContain("pages/_components/Widget");
+ });
+
+ it("pre-scans island imports from named island layouts into the manifest", async () => {
+ writeFile(
+ "_layouts/sidebar.island.svelte",
+ `
+ `,
+ );
+ writeFile("_components/Clock.svelte", `12:00 `);
+ writeFile(
+ "index.island.svelte",
+ `
+Home
`,
+ );
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ expect(clientEntry).toContain("pages/_components/Clock");
+ });
+
+ it("skips non-island layouts during pre-scan", async () => {
+ writeFile(
+ "layout.svelte",
+ `
+ `,
+ );
+ writeFile("index.island.svelte", `Home
`);
+ writeFile("Sidebar.svelte", ``);
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).not.toContain("Sidebar");
+ });
+});
diff --git a/packages/vue/src/plugin-islands.ts b/packages/vue/src/plugin-islands.ts
index b65ea45e2e..ce2365a46a 100644
--- a/packages/vue/src/plugin-islands.ts
+++ b/packages/vue/src/plugin-islands.ts
@@ -103,9 +103,18 @@ export function islandsPlugin(pagesDir: string): Plugin[] {
// islands-client entry before island page transforms run.
const importAttrRe =
/import\s+\w+\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*\}/g;
- for (const page of pageScan.pages) {
- if (!page.island) continue;
- const filePath = resolve(pagesDir, page.componentPath);
+ // Scan both pages AND layouts for island imports
+ const filesToScan: { filePath: string; island: boolean }[] = [
+ ...pageScan.pages.map((p: any) => ({ filePath: p.componentPath, island: p.island })),
+ ...pageScan.layouts.map((l: any) => ({ filePath: l.filePath, island: l.island })),
+ ...pageScan.namedLayouts.map((nl: any) => ({
+ filePath: nl.filePath,
+ island: nl.island,
+ })),
+ ];
+ for (const entry of filesToScan) {
+ if (!entry.island) continue;
+ const filePath = resolve(pagesDir, entry.filePath);
const code = readFileSync(filePath, "utf-8");
const importerDir = dirname(filePath);
importAttrRe.lastIndex = 0;
diff --git a/packages/vue/test/unit/plugin-islands.test.ts b/packages/vue/test/unit/plugin-islands.test.ts
new file mode 100644
index 0000000000..dc41e34984
--- /dev/null
+++ b/packages/vue/test/unit/plugin-islands.test.ts
@@ -0,0 +1,185 @@
+import { describe, expect, it, beforeEach, afterEach } from "vitest";
+import { mkdirSync, writeFileSync, rmSync } from "node:fs";
+import { join } from "node:path";
+import { islandsPlugin } from "../../src/plugin-islands";
+
+const TMP = join(import.meta.dirname, "__tmp_islands_plugin__");
+const PAGES_DIR = join(TMP, "pages");
+
+function writeFile(relativePath: string, content: string): void {
+ const full = join(PAGES_DIR, relativePath);
+ mkdirSync(join(full, ".."), { recursive: true });
+ writeFileSync(full, content);
+}
+
+/** Extract the plugin's buildStart and load hooks, simulating a minimal Vite lifecycle. */
+function setupPlugin() {
+ const plugins = islandsPlugin(PAGES_DIR);
+ const plugin = plugins[0];
+
+ // Call configResolved with minimal config
+ const config = { root: TMP, command: "build" as const, plugins: [] };
+ (plugin as any).configResolved(config);
+
+ return {
+ async buildStart() {
+ await (plugin as any).buildStart.call({});
+ },
+ loadClientEntry(): string | undefined {
+ return (plugin as any).load.handler("\0virtual:void-islands-client");
+ },
+ };
+}
+
+describe("islandsPlugin — layout island import scanning", () => {
+ beforeEach(() => {
+ mkdirSync(PAGES_DIR, { recursive: true });
+ });
+
+ afterEach(() => {
+ rmSync(TMP, { recursive: true, force: true });
+ });
+
+ it("pre-scans island imports from island layouts into the manifest", async () => {
+ // Island layout with an island import — component lives outside the
+ // island directory (files under an island layout must use .island suffix)
+ writeFile(
+ "blog/layout.island.vue",
+ `
+ `,
+ );
+ // Island page under the layout (required by scan rules)
+ writeFile(
+ "blog/index.island.vue",
+ `
+Blog
`,
+ );
+ // The island component itself (under _ prefix so scanPages ignores it)
+ writeFile(
+ "_components/Counter.vue",
+ `
+{{ count }} `,
+ );
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ // The island manifest should contain the Counter component from the layout
+ expect(clientEntry).toContain("pages/_components/Counter");
+ });
+
+ it("pre-scans island imports from island pages into the manifest", async () => {
+ // Island page with an island import (no layout)
+ writeFile(
+ "index.island.vue",
+ `
+ `,
+ );
+ // The island component
+ writeFile(
+ "Toggle.vue",
+ `
+{{ on }} `,
+ );
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ expect(clientEntry).toContain("pages/Toggle");
+ });
+
+ it("includes island imports from both pages and layouts", async () => {
+ // Island layout with one island import
+ writeFile(
+ "app/layout.island.vue",
+ `
+ `,
+ );
+ // Island page with a different island import
+ writeFile(
+ "app/index.island.vue",
+ `
+ `,
+ );
+ // Both island components (under _ prefix so scanPages ignores them)
+ writeFile("_components/Nav.vue", `Nav `);
+ writeFile("_components/Widget.vue", `Widget
`);
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ // Both should be in the manifest
+ expect(clientEntry).toContain("pages/_components/Nav");
+ expect(clientEntry).toContain("pages/_components/Widget");
+ });
+
+ it("pre-scans island imports from named island layouts into the manifest", async () => {
+ writeFile(
+ "_layouts/sidebar.island.vue",
+ `
+ `,
+ );
+ writeFile("_components/Clock.vue", `12:00 `);
+ writeFile(
+ "index.island.vue",
+ `
+Home
`,
+ );
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ expect(clientEntry).toBeDefined();
+ expect(clientEntry).toContain("pages/_components/Clock");
+ });
+
+ it("skips non-island layouts during pre-scan", async () => {
+ // Regular (non-island) layout — should NOT be scanned
+ writeFile(
+ "layout.vue",
+ `
+ `,
+ );
+ // Island page
+ writeFile(
+ "index.island.vue",
+ `
+Home
`,
+ );
+ writeFile("Sidebar.vue", ` `);
+
+ const { buildStart, loadClientEntry } = setupPlugin();
+ await buildStart();
+ const clientEntry = loadClientEntry();
+
+ // Sidebar should NOT be in the manifest since the layout is not an island layout
+ expect(clientEntry).not.toContain("Sidebar");
+ });
+});