feat(vite): support remote islands (#3294)

This commit is contained in:
Marvin Hagemeister
2025-09-01 12:11:08 +02:00
committed by GitHub
parent 54942987eb
commit 541bc6c6ca
11 changed files with 197 additions and 75 deletions
+25
View File
@@ -350,3 +350,28 @@ Deno.test({
sanitizeOps: false,
sanitizeResources: false,
});
Deno.test({
name: "vite build - remote island",
fn: async () => {
const fixture = path.join(FIXTURE_DIR, "remote_island");
await using res = await buildVite(fixture);
await launchProd(
{ cwd: res.tmp },
async (address) => {
await withBrowser(async (page) => {
await page.goto(`${address}`, {
waitUntil: "networkidle2",
});
await page.locator(".remote-island").wait();
await page.locator(".increment").click();
await waitForText(page, ".result", "Count: 1");
});
},
);
},
sanitizeOps: false,
sanitizeResources: false,
});
@@ -289,3 +289,23 @@ Deno.test({
sanitizeResources: false,
sanitizeOps: false,
});
Deno.test({
name: "vite dev - remote island",
fn: async () => {
const fixture = path.join(FIXTURE_DIR, "remote_island");
await launchDevServer(fixture, async (address) => {
await withBrowser(async (page) => {
await page.goto(`${address}`, {
waitUntil: "networkidle2",
});
await page.locator(".remote-island").wait();
await page.locator(".increment").click();
await waitForText(page, ".result", "Count: 1");
});
});
},
sanitizeResources: false,
sanitizeOps: false,
});
@@ -0,0 +1,5 @@
import { App, staticFiles } from "@fresh/core";
export const app = new App()
.use(staticFiles())
.fsRoutes();
@@ -0,0 +1,5 @@
import { RemoteIsland } from "@marvinh-test/fresh-island";
export default function Hello() {
return <RemoteIsland />;
}
@@ -0,0 +1,8 @@
import { defineConfig } from "vite";
import { fresh } from "@fresh/plugin-vite";
export default defineConfig({
plugins: [fresh({
islandSpecifiers: ["@marvinh-test/fresh-island"],
})],
});