feat: reduce number of island bundles (#2082)
This commit is contained in:
+10
-43
@@ -1,4 +1,7 @@
|
||||
import { isIdentifierChar, isIdentifierStart } from "$fresh/src/server/deps.ts";
|
||||
import {
|
||||
isIdentifierChar,
|
||||
isIdentifierStart,
|
||||
} from "../server/init_safe_deps.ts";
|
||||
import { extname, join, normalize } from "./deps.ts";
|
||||
|
||||
/**
|
||||
@@ -72,18 +75,12 @@ export async function generate(directory: string, manifest: Manifest) {
|
||||
normalizedRoutes.set(specifier, identifier);
|
||||
}
|
||||
|
||||
type islandManifest = {
|
||||
specifier: string;
|
||||
identifier: string;
|
||||
importLine: string;
|
||||
};
|
||||
const normalizedIslands: islandManifest[] = [];
|
||||
const normalizedIslands: { specifier: string; identifier: string }[] = [];
|
||||
for (let i = 0; i < islands.length; i++) {
|
||||
const file = islands[i];
|
||||
const specifier = toImportSpecifier(file);
|
||||
const identifier = specifierToIdentifier(specifier, used);
|
||||
const importLine = await islandImportLine(specifier, identifier, directory);
|
||||
normalizedIslands.push({ specifier, identifier, importLine });
|
||||
normalizedIslands.push({ specifier, identifier });
|
||||
}
|
||||
|
||||
const output = `// DO NOT EDIT. This file is generated by Fresh.
|
||||
@@ -99,11 +96,11 @@ ${
|
||||
}
|
||||
${
|
||||
normalizedIslands.map(({ specifier, identifier }) =>
|
||||
`import * as $$${identifier} from "${specifier}";`
|
||||
`import * as $${identifier} from "${specifier}";`
|
||||
)
|
||||
.join("\n")
|
||||
}
|
||||
import { Manifest } from "$fresh/server.ts";
|
||||
import { type Manifest } from "$fresh/server.ts";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
@@ -116,8 +113,8 @@ const manifest = {
|
||||
},
|
||||
islands: {
|
||||
${
|
||||
normalizedIslands.map(({ specifier, importLine }) =>
|
||||
`${JSON.stringify(`${specifier}`)}: ${importLine},`
|
||||
normalizedIslands.map(({ specifier, identifier }) =>
|
||||
`${JSON.stringify(`${specifier}`)}: $${identifier},`
|
||||
)
|
||||
.join("\n ")
|
||||
}
|
||||
@@ -153,33 +150,3 @@ export default manifest;
|
||||
"color: blue; font-weight: bold",
|
||||
);
|
||||
}
|
||||
|
||||
async function islandImportLine(
|
||||
specifier: string,
|
||||
identifier: string,
|
||||
directory: string,
|
||||
): Promise<string> {
|
||||
const moduleURL = new URL(`file://${directory}/${specifier}`);
|
||||
const module = await import(moduleURL.href);
|
||||
const entries = Object.entries(module);
|
||||
|
||||
const allExportsAreComponents = entries.every(
|
||||
([, exportedEntity]) => typeof exportedEntity === "function",
|
||||
);
|
||||
|
||||
// if all exports are components, we can use the simple, existing form
|
||||
if (allExportsAreComponents) {
|
||||
return `$$${identifier}`;
|
||||
}
|
||||
|
||||
// if not all exports are components, list the component exports explicitly
|
||||
const componentExports = entries
|
||||
.filter(([, exportedEntity]) => typeof exportedEntity === "function")
|
||||
.map(([exportName]) => exportName);
|
||||
|
||||
const exportsString = componentExports
|
||||
.map((exp) => `${exp}: $$${identifier}.${exp}`)
|
||||
.join(", ");
|
||||
|
||||
return `{ ${exportsString} }`;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ function isElementNode(node: Node): node is HTMLElement {
|
||||
return node.nodeType === Node.ELEMENT_NODE && !("_frshRootFrag" in node);
|
||||
}
|
||||
|
||||
type IslandRegistry = Record<string, Record<string, ComponentType>>;
|
||||
type IslandRegistry = Record<string, ComponentType>;
|
||||
|
||||
export function revive(
|
||||
islands: IslandRegistry,
|
||||
@@ -212,7 +212,7 @@ function hideMarker(marker: Marker) {
|
||||
* the client. This function checks for that
|
||||
*/
|
||||
function addChildrenFromTemplate(
|
||||
islands: Record<string, Record<string, ComponentType>>,
|
||||
islands: IslandRegistry,
|
||||
// deno-lint-ignore no-explicit-any
|
||||
props: any[],
|
||||
markerStack: Marker[],
|
||||
@@ -220,11 +220,11 @@ function addChildrenFromTemplate(
|
||||
comment: string,
|
||||
result: RenderRequest[],
|
||||
) {
|
||||
const [id, exportName, n] = comment.slice("/frsh-".length).split(
|
||||
const [id, n] = comment.slice("/frsh-".length).split(
|
||||
":",
|
||||
);
|
||||
|
||||
const sel = `#frsh-slot-${id}-${exportName}-${n}-children`;
|
||||
const sel = `#frsh-slot-${id}-${n}-children`;
|
||||
const template = document.querySelector(sel) as
|
||||
| HTMLTemplateElement
|
||||
| null;
|
||||
@@ -280,7 +280,7 @@ function addChildrenFromTemplate(
|
||||
* fashion over an HTMLElement's children list.
|
||||
*/
|
||||
function _walkInner(
|
||||
islands: Record<string, Record<string, ComponentType>>,
|
||||
islands: IslandRegistry,
|
||||
// deno-lint-ignore no-explicit-any
|
||||
props: any[],
|
||||
markerStack: Marker[],
|
||||
@@ -437,7 +437,7 @@ function _walkInner(
|
||||
}
|
||||
} else if (comment.startsWith("frsh")) {
|
||||
// We're opening a new island
|
||||
const [id, exportName, n, key] = comment.slice(5).split(":");
|
||||
const [id, n, key] = comment.slice(5).split(":");
|
||||
const islandProps = props[Number(n)];
|
||||
|
||||
markerStack.push({
|
||||
@@ -447,7 +447,7 @@ function _walkInner(
|
||||
kind: MarkerKind.Island,
|
||||
});
|
||||
|
||||
const vnode = h(islands[id][exportName], islandProps) as VNode;
|
||||
const vnode = h(islands[id], islandProps) as VNode;
|
||||
if (key) vnode.key = key;
|
||||
vnodeStack.push(vnode);
|
||||
}
|
||||
@@ -654,7 +654,7 @@ export async function applyPartials(res: Response): Promise<void> {
|
||||
const islands: IslandRegistry = {};
|
||||
const dataRaw = doc.getElementById("__FRSH_PARTIAL_DATA")!;
|
||||
let data: {
|
||||
islands: Record<string, string>;
|
||||
islands: Record<string, { export: string; url: string }>;
|
||||
signals: string | null;
|
||||
deserializer: string | null;
|
||||
} | null = null;
|
||||
@@ -663,7 +663,8 @@ export async function applyPartials(res: Response): Promise<void> {
|
||||
|
||||
promises.push(
|
||||
...Array.from(Object.entries(data!.islands)).map(async (entry) => {
|
||||
islands[entry[0]] = await import(`${entry[1]}`);
|
||||
const mod = await import(`${entry[1].url}`);
|
||||
islands[entry[0]] = mod[entry[1].export];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -702,9 +702,14 @@ function collectEntrypoints(
|
||||
? import.meta.resolve(`${entrypointBase}/main_dev.ts`)
|
||||
: import.meta.resolve(`${entrypointBase}/main.ts`),
|
||||
deserializer: import.meta.resolve(`${entrypointBase}/deserializer.ts`),
|
||||
fresh_dev_client: import.meta.resolve(`${entrypointBase}/client.ts`),
|
||||
};
|
||||
|
||||
if (dev) {
|
||||
entryPoints.fresh_dev_client = import.meta.resolve(
|
||||
`${entrypointBase}/client.ts`,
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
import.meta.resolve("@preact/signals");
|
||||
entryPoints.signals = import.meta.resolve(`${entrypointBase}/signals.ts`);
|
||||
@@ -713,7 +718,7 @@ function collectEntrypoints(
|
||||
}
|
||||
|
||||
for (const island of islands) {
|
||||
entryPoints[`island-${island.id}`] = island.url;
|
||||
entryPoints[`island-${island.name}`] = island.url;
|
||||
}
|
||||
|
||||
for (const plugin of plugins) {
|
||||
|
||||
@@ -26,7 +26,3 @@ export {
|
||||
assertEquals,
|
||||
assertThrows,
|
||||
} from "https://deno.land/std@0.205.0/assert/mod.ts";
|
||||
export {
|
||||
isIdentifierChar,
|
||||
isIdentifierStart,
|
||||
} from "https://esm.sh/@babel/helper-validator-identifier@7.22.20";
|
||||
|
||||
@@ -289,8 +289,8 @@ export async function extractRoutes(
|
||||
)
|
||||
) {
|
||||
if (typeof exportedFunction !== "function") continue;
|
||||
const name = processedIsland.name;
|
||||
const id = `${name}_${exportName}`.toLowerCase();
|
||||
const name = processedIsland.name.toLowerCase();
|
||||
const id = `${name}_${exportName.toLowerCase()}`;
|
||||
islands.push({
|
||||
id,
|
||||
name,
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// This file includes dependencies that are safe to use even
|
||||
// when the user has no `deno.json` in their project folder.
|
||||
// This commonly occurs when the user is bootstrapping a new
|
||||
// project.
|
||||
|
||||
export {
|
||||
isIdentifierChar,
|
||||
isIdentifierStart,
|
||||
} from "https://esm.sh/@babel/helper-validator-identifier@7.22.20";
|
||||
@@ -131,15 +131,19 @@ export function renderFreshTags(
|
||||
// Finally, it loads all island scripts and hydrates the islands using the
|
||||
// reviver from the "main" script.
|
||||
let islandRegistry = "";
|
||||
const islandMapping: Record<string, string> = {};
|
||||
const islandMapping: Record<string, { url: string; export: string }> = {};
|
||||
if (renderState.encounteredIslands.size > 0) {
|
||||
// Prepare the inline script that loads and revives the islands
|
||||
for (const island of renderState.encounteredIslands) {
|
||||
const url = addImport(`island-${island.id}.js`);
|
||||
script +=
|
||||
`import * as ${island.name}_${island.exportName} from "${url}";`;
|
||||
const url = addImport(`island-${island.name}.js`);
|
||||
script += island.exportName === "default"
|
||||
? `import ${island.name}_${island.exportName} from "${url}";`
|
||||
: `import { ${island.exportName} as ${island.name}_${island.exportName} } from "${url}";`;
|
||||
islandRegistry += `${island.id}:${island.name}_${island.exportName},`;
|
||||
islandMapping[island.id] = url;
|
||||
islandMapping[island.id] = {
|
||||
export: island.exportName,
|
||||
url,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -331,8 +331,7 @@ options.__b = (vnode: VNode<Record<string, unknown>>) => {
|
||||
);
|
||||
}
|
||||
|
||||
const markerText =
|
||||
`frsh-slot-${island.id}:${island.exportName}:${id}:children`;
|
||||
const markerText = `frsh-slot-${island.id}:${id}:children`;
|
||||
// @ts-ignore nonono
|
||||
props.children = wrapWithMarker(
|
||||
children,
|
||||
@@ -354,9 +353,7 @@ options.__b = (vnode: VNode<Record<string, unknown>>) => {
|
||||
|
||||
return wrapWithMarker(
|
||||
child,
|
||||
`frsh-${island.id}:${island.exportName}:${islandProps.length - 1}:${
|
||||
vnode.key ?? ""
|
||||
}`,
|
||||
`frsh-${island.id}:${islandProps.length - 1}:${vnode.key ?? ""}`,
|
||||
);
|
||||
};
|
||||
// deno-lint-ignore no-explicit-any
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { PARTIAL_SEARCH_PARAM } from "../constants.ts";
|
||||
import { BaseRoute, ErrorHandlerContext, ServeHandlerInfo } from "./types.ts";
|
||||
import { isIdentifierChar, isIdentifierStart } from "./deps.ts";
|
||||
import { isIdentifierChar, isIdentifierStart } from "./init_safe_deps.ts";
|
||||
|
||||
type HandlerContext<T = unknown> = T & ServeHandlerInfo & {
|
||||
isPartial: boolean;
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ async function testBuild(
|
||||
|
||||
await t.step("check snapshot file", async () => {
|
||||
assert(
|
||||
Array.isArray(snapshot.files["island-counter_default.js"]),
|
||||
Array.isArray(snapshot.files["island-counter.js"]),
|
||||
"Island output file not found in snapshot",
|
||||
);
|
||||
assert(
|
||||
@@ -252,7 +252,7 @@ Deno.test("pass target options", async () => {
|
||||
|
||||
const { stdout, stderr } = getStdOutput(out);
|
||||
const txt = await Deno.readTextFile(
|
||||
path.join(fixture, "_fresh", "island-counter_default.js"),
|
||||
path.join(fixture, "_fresh", "island-counter.js"),
|
||||
);
|
||||
|
||||
assertNotMatch(
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
// This file is automatically updated during development when running `dev.ts`.
|
||||
|
||||
import * as $index from "./routes/index.tsx";
|
||||
import * as $$Counter from "./islands/Counter.tsx";
|
||||
import { Manifest } from "$fresh/server.ts";
|
||||
import * as $Counter from "./islands/Counter.tsx";
|
||||
import { type Manifest } from "$fresh/server.ts";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
"./routes/index.tsx": $index,
|
||||
},
|
||||
islands: {
|
||||
"./islands/Counter.tsx": $$Counter,
|
||||
"./islands/Counter.tsx": $Counter,
|
||||
},
|
||||
baseUrl: import.meta.url,
|
||||
} satisfies Manifest;
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
// This file is automatically updated during development when running `dev.ts`.
|
||||
|
||||
import * as $index from "./routes/index.tsx";
|
||||
import * as $$Counter from "./islands/Counter.tsx";
|
||||
import { Manifest } from "$fresh/server.ts";
|
||||
import * as $Counter from "./islands/Counter.tsx";
|
||||
import { type Manifest } from "$fresh/server.ts";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
"./routes/index.tsx": $index,
|
||||
},
|
||||
islands: {
|
||||
"./islands/Counter.tsx": $$Counter,
|
||||
"./islands/Counter.tsx": $Counter,
|
||||
},
|
||||
baseUrl: import.meta.url,
|
||||
} satisfies Manifest;
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
// This file is automatically updated during development when running `dev.ts`.
|
||||
|
||||
import * as $index from "./routes/index.tsx";
|
||||
import * as $$Counter from "./islands/Counter.tsx";
|
||||
import { Manifest } from "$fresh/server.ts";
|
||||
import * as $Counter from "./islands/Counter.tsx";
|
||||
import { type Manifest } from "$fresh/server.ts";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
"./routes/index.tsx": $index,
|
||||
},
|
||||
islands: {
|
||||
"./islands/Counter.tsx": $$Counter,
|
||||
"./islands/Counter.tsx": $Counter,
|
||||
},
|
||||
baseUrl: import.meta.url,
|
||||
} satisfies Manifest;
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
// This file is automatically updated during development when running `dev.ts`.
|
||||
|
||||
import * as $index from "./routes/index.tsx";
|
||||
import * as $$Counter from "./islands/Counter.tsx";
|
||||
import { Manifest } from "$fresh/server.ts";
|
||||
import * as $Counter from "./islands/Counter.tsx";
|
||||
import { type Manifest } from "$fresh/server.ts";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
"./routes/index.tsx": $index,
|
||||
},
|
||||
islands: {
|
||||
"./islands/Counter.tsx": $$Counter,
|
||||
"./islands/Counter.tsx": $Counter,
|
||||
},
|
||||
baseUrl: import.meta.url,
|
||||
} satisfies Manifest;
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
// This file is automatically updated during development when running `dev.ts`.
|
||||
|
||||
import * as $index from "./routes/index.tsx";
|
||||
import * as $$Counter from "./islands/Counter.tsx";
|
||||
import { Manifest } from "$fresh/server.ts";
|
||||
import * as $Counter from "./islands/Counter.tsx";
|
||||
import { type Manifest } from "$fresh/server.ts";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
"./routes/index.tsx": $index,
|
||||
},
|
||||
islands: {
|
||||
"./islands/Counter.tsx": $$Counter,
|
||||
"./islands/Counter.tsx": $Counter,
|
||||
},
|
||||
baseUrl: import.meta.url,
|
||||
} satisfies Manifest;
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
// This file is automatically updated during development when running `dev.ts`.
|
||||
|
||||
import * as $index from "./routes/index.tsx";
|
||||
import * as $$Counter from "./islands/Counter.tsx";
|
||||
import { Manifest } from "$fresh/server.ts";
|
||||
import * as $Counter from "./islands/Counter.tsx";
|
||||
import { type Manifest } from "$fresh/server.ts";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
"./routes/index.tsx": $index,
|
||||
},
|
||||
islands: {
|
||||
"./islands/Counter.tsx": $$Counter,
|
||||
"./islands/Counter.tsx": $Counter,
|
||||
},
|
||||
baseUrl: import.meta.url,
|
||||
} satisfies Manifest;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import * as $index from "./routes/index.tsx";
|
||||
|
||||
import { Manifest } from "$fresh/server.ts";
|
||||
import { type Manifest } from "$fresh/server.ts";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"lock": false,
|
||||
"imports": {
|
||||
"$fresh/": "../../",
|
||||
"preact": "https://esm.sh/preact@10.19.2",
|
||||
"preact/": "https://esm.sh/preact@10.19.2/",
|
||||
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.2",
|
||||
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.5.0"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact"
|
||||
}
|
||||
}
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env -S deno run -A --watch=static/,routes/
|
||||
|
||||
import dev from "$fresh/dev.ts";
|
||||
|
||||
await dev(import.meta.url, "./main.ts");
|
||||
@@ -0,0 +1,23 @@
|
||||
// DO NOT EDIT. This file is generated by Fresh.
|
||||
// This file SHOULD be checked into source version control.
|
||||
// This file is automatically updated during development when running `dev.ts`.
|
||||
|
||||
import * as $index from "./routes/index.tsx";
|
||||
import * as $Multiple from "./islands/Multiple.tsx";
|
||||
import * as $MultipleDefault from "./islands/MultipleDefault.tsx";
|
||||
import * as $Single from "./islands/Single.tsx";
|
||||
import { type Manifest } from "$fresh/server.ts";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
"./routes/index.tsx": $index,
|
||||
},
|
||||
islands: {
|
||||
"./islands/Multiple.tsx": $Multiple,
|
||||
"./islands/MultipleDefault.tsx": $MultipleDefault,
|
||||
"./islands/Single.tsx": $Single,
|
||||
},
|
||||
baseUrl: import.meta.url,
|
||||
} satisfies Manifest;
|
||||
|
||||
export default manifest;
|
||||
@@ -0,0 +1,21 @@
|
||||
import { useSignal } from "@preact/signals";
|
||||
|
||||
export function Multiple1() {
|
||||
const sig = useSignal(0);
|
||||
return (
|
||||
<div class="island multiple1">
|
||||
<p>Multiple1 Island: {sig}</p>
|
||||
<button onClick={() => sig.value += 1}>update</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function Multiple2() {
|
||||
const sig = useSignal(0);
|
||||
return (
|
||||
<div class="island multiple2">
|
||||
<p>Multiple2 Island: {sig}</p>
|
||||
<button onClick={() => sig.value += 1}>update</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { useSignal } from "@preact/signals";
|
||||
|
||||
export default function MultipleDefault() {
|
||||
const sig = useSignal(0);
|
||||
return (
|
||||
<div class="island multipledefault">
|
||||
<p>MultipleDefault Island: {sig}</p>
|
||||
<button onClick={() => sig.value += 1}>update</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function MultipleDefault1() {
|
||||
const sig = useSignal(0);
|
||||
return (
|
||||
<div class="island multipledefault1">
|
||||
<p>MultipleDefault1 Island: {sig}</p>
|
||||
<button onClick={() => sig.value += 1}>update</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function MultipleDefault2() {
|
||||
const sig = useSignal(0);
|
||||
return (
|
||||
<div class="island multipledefault2">
|
||||
<p>MultipleDefault2 Island: {sig}</p>
|
||||
<button onClick={() => sig.value += 1}>update</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { useSignal } from "@preact/signals";
|
||||
|
||||
export default function Single() {
|
||||
const sig = useSignal(0);
|
||||
|
||||
return (
|
||||
<div class="island single">
|
||||
<p>Single Island: {sig}</p>
|
||||
<button onClick={() => sig.value += 1}>update</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/// <reference no-default-lib="true" />
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
/// <reference lib="dom.asynciterable" />
|
||||
/// <reference lib="deno.ns" />
|
||||
|
||||
import { start } from "$fresh/server.ts";
|
||||
import manifest from "./fresh.gen.ts";
|
||||
|
||||
await start(manifest);
|
||||
@@ -0,0 +1,22 @@
|
||||
import Single from "../islands/Single.tsx";
|
||||
import { Multiple1, Multiple2 } from "../islands/Multiple.tsx";
|
||||
import MultipleDefault, {
|
||||
MultipleDefault1,
|
||||
MultipleDefault2,
|
||||
} from "../islands/MultipleDefault.tsx";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div>
|
||||
<h2>Single</h2>
|
||||
<Single />
|
||||
<h2>Multiple</h2>
|
||||
<Multiple1 />
|
||||
<Multiple2 />
|
||||
<h2>Multiple Default</h2>
|
||||
<MultipleDefault />
|
||||
<MultipleDefault1 />
|
||||
<MultipleDefault2 />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -116,22 +116,22 @@ import * as $relative_link_index from "./routes/relative_link/index.tsx";
|
||||
import * as $scroll_restoration_index from "./routes/scroll_restoration/index.tsx";
|
||||
import * as $scroll_restoration_injected from "./routes/scroll_restoration/injected.tsx";
|
||||
import * as $scroll_restoration_update from "./routes/scroll_restoration/update.tsx";
|
||||
import * as $$Counter from "./islands/Counter.tsx";
|
||||
import * as $$CounterA from "./islands/CounterA.tsx";
|
||||
import * as $$CounterB from "./islands/CounterB.tsx";
|
||||
import * as $$Fader from "./islands/Fader.tsx";
|
||||
import * as $$InvalidSlot from "./islands/InvalidSlot.tsx";
|
||||
import * as $$KeyExplorer from "./islands/KeyExplorer.tsx";
|
||||
import * as $$LazyLink from "./islands/LazyLink.tsx";
|
||||
import * as $$Logger from "./islands/Logger.tsx";
|
||||
import * as $$Other from "./islands/Other.tsx";
|
||||
import * as $$PartialTrigger from "./islands/PartialTrigger.tsx";
|
||||
import * as $$PassThrough from "./islands/PassThrough.tsx";
|
||||
import * as $$PropIsland from "./islands/PropIsland.tsx";
|
||||
import * as $$SignalProp from "./islands/SignalProp.tsx";
|
||||
import * as $$Spinner from "./islands/Spinner.tsx";
|
||||
import * as $$Stateful from "./islands/Stateful.tsx";
|
||||
import { Manifest } from "$fresh/server.ts";
|
||||
import * as $Counter from "./islands/Counter.tsx";
|
||||
import * as $CounterA from "./islands/CounterA.tsx";
|
||||
import * as $CounterB from "./islands/CounterB.tsx";
|
||||
import * as $Fader from "./islands/Fader.tsx";
|
||||
import * as $InvalidSlot from "./islands/InvalidSlot.tsx";
|
||||
import * as $KeyExplorer from "./islands/KeyExplorer.tsx";
|
||||
import * as $LazyLink from "./islands/LazyLink.tsx";
|
||||
import * as $Logger from "./islands/Logger.tsx";
|
||||
import * as $Other from "./islands/Other.tsx";
|
||||
import * as $PartialTrigger from "./islands/PartialTrigger.tsx";
|
||||
import * as $PassThrough from "./islands/PassThrough.tsx";
|
||||
import * as $PropIsland from "./islands/PropIsland.tsx";
|
||||
import * as $SignalProp from "./islands/SignalProp.tsx";
|
||||
import * as $Spinner from "./islands/Spinner.tsx";
|
||||
import * as $Stateful from "./islands/Stateful.tsx";
|
||||
import { type Manifest } from "$fresh/server.ts";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
@@ -262,21 +262,21 @@ const manifest = {
|
||||
"./routes/scroll_restoration/update.tsx": $scroll_restoration_update,
|
||||
},
|
||||
islands: {
|
||||
"./islands/Counter.tsx": $$Counter,
|
||||
"./islands/CounterA.tsx": $$CounterA,
|
||||
"./islands/CounterB.tsx": $$CounterB,
|
||||
"./islands/Fader.tsx": $$Fader,
|
||||
"./islands/InvalidSlot.tsx": $$InvalidSlot,
|
||||
"./islands/KeyExplorer.tsx": $$KeyExplorer,
|
||||
"./islands/LazyLink.tsx": $$LazyLink,
|
||||
"./islands/Logger.tsx": $$Logger,
|
||||
"./islands/Other.tsx": $$Other,
|
||||
"./islands/PartialTrigger.tsx": $$PartialTrigger,
|
||||
"./islands/PassThrough.tsx": $$PassThrough,
|
||||
"./islands/PropIsland.tsx": $$PropIsland,
|
||||
"./islands/SignalProp.tsx": $$SignalProp,
|
||||
"./islands/Spinner.tsx": $$Spinner,
|
||||
"./islands/Stateful.tsx": $$Stateful,
|
||||
"./islands/Counter.tsx": $Counter,
|
||||
"./islands/CounterA.tsx": $CounterA,
|
||||
"./islands/CounterB.tsx": $CounterB,
|
||||
"./islands/Fader.tsx": $Fader,
|
||||
"./islands/InvalidSlot.tsx": $InvalidSlot,
|
||||
"./islands/KeyExplorer.tsx": $KeyExplorer,
|
||||
"./islands/LazyLink.tsx": $LazyLink,
|
||||
"./islands/Logger.tsx": $Logger,
|
||||
"./islands/Other.tsx": $Other,
|
||||
"./islands/PartialTrigger.tsx": $PartialTrigger,
|
||||
"./islands/PassThrough.tsx": $PassThrough,
|
||||
"./islands/PropIsland.tsx": $PropIsland,
|
||||
"./islands/SignalProp.tsx": $SignalProp,
|
||||
"./islands/Spinner.tsx": $Spinner,
|
||||
"./islands/Stateful.tsx": $Stateful,
|
||||
},
|
||||
baseUrl: import.meta.url,
|
||||
} satisfies Manifest;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import * as $index from "./routes/index.tsx";
|
||||
|
||||
import { Manifest } from "$fresh/server.ts";
|
||||
import { type Manifest } from "$fresh/server.ts";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import * as $_app from "./routes/_app.tsx";
|
||||
import * as $index from "./routes/index.tsx";
|
||||
|
||||
import { Manifest } from "$fresh/server.ts";
|
||||
import { type Manifest } from "$fresh/server.ts";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
|
||||
+8
-3
@@ -38,6 +38,7 @@ Deno.test({
|
||||
args: [
|
||||
"run",
|
||||
"-A",
|
||||
"--no-config",
|
||||
"init.ts",
|
||||
tmpDirName,
|
||||
],
|
||||
@@ -155,6 +156,7 @@ Deno.test({
|
||||
args: [
|
||||
"run",
|
||||
"-A",
|
||||
"--no-config",
|
||||
"init.ts",
|
||||
tmpDirName,
|
||||
"--tailwind",
|
||||
@@ -245,7 +247,7 @@ Deno.test("fresh-init error(help)", async function (t) {
|
||||
"execute invalid init command (deno run -A init.ts)",
|
||||
async () => {
|
||||
const cliProcess = new Deno.Command(Deno.execPath(), {
|
||||
args: ["run", "-A", "init.ts"],
|
||||
args: ["run", "-A", "--no-config", "init.ts"],
|
||||
stdin: "null",
|
||||
stderr: "piped",
|
||||
});
|
||||
@@ -261,7 +263,7 @@ Deno.test("fresh-init error(help)", async function (t) {
|
||||
"execute invalid init command (deno run -A init.ts -f)",
|
||||
async () => {
|
||||
const cliProcess = new Deno.Command(Deno.execPath(), {
|
||||
args: ["run", "-A", "init.ts", "-f"],
|
||||
args: ["run", "-A", "--no-config", "init.ts", "-f"],
|
||||
});
|
||||
const { code, stderr } = await cliProcess.output();
|
||||
assertEquals(code, 1);
|
||||
@@ -275,7 +277,7 @@ Deno.test("fresh-init error(help)", async function (t) {
|
||||
"execute invalid init command (deno run -A init.ts --foo)",
|
||||
async () => {
|
||||
const cliProcess = new Deno.Command(Deno.execPath(), {
|
||||
args: ["run", "-A", "init.ts", "--foo"],
|
||||
args: ["run", "-A", "--no-config", "init.ts", "--foo"],
|
||||
});
|
||||
const { code, stderr } = await cliProcess.output();
|
||||
assertEquals(code, 1);
|
||||
@@ -295,6 +297,7 @@ Deno.test("fresh-init .", async function (t) {
|
||||
args: [
|
||||
"run",
|
||||
"-A",
|
||||
"--no-config",
|
||||
path.join(Deno.cwd(), "init.ts"),
|
||||
".",
|
||||
],
|
||||
@@ -322,6 +325,7 @@ Deno.test({
|
||||
args: [
|
||||
"run",
|
||||
"-A",
|
||||
"--no-config",
|
||||
path.join(Deno.cwd(), "init.ts"),
|
||||
"subdirectory/subsubdirectory",
|
||||
],
|
||||
@@ -379,6 +383,7 @@ Deno.test({
|
||||
args: [
|
||||
"run",
|
||||
"-A",
|
||||
"--no-config",
|
||||
"init.ts",
|
||||
tmpDirName,
|
||||
"--tailwind",
|
||||
|
||||
@@ -442,3 +442,39 @@ Deno.test("throws when passing non-jsx children to an island", async (t) => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("serves multiple islands in one file", async () => {
|
||||
await withPageName(
|
||||
"./tests/fixture_islands_multiple/dev.ts",
|
||||
async (page, address) => {
|
||||
await page.goto(address, { waitUntil: "networkidle2" });
|
||||
|
||||
await page.click(".single button");
|
||||
await waitForText(page, ".single p", "Single Island: 1");
|
||||
|
||||
await page.click(".multiple1 button");
|
||||
await waitForText(page, ".multiple1 p", "Multiple1 Island: 1");
|
||||
await page.click(".multiple2 button");
|
||||
await waitForText(page, ".multiple2 p", "Multiple2 Island: 1");
|
||||
|
||||
await page.click(".multipledefault button");
|
||||
await waitForText(
|
||||
page,
|
||||
".multipledefault p",
|
||||
"MultipleDefault Island: 1",
|
||||
);
|
||||
await page.click(".multipledefault1 button");
|
||||
await waitForText(
|
||||
page,
|
||||
".multipledefault1 p",
|
||||
"MultipleDefault1 Island: 1",
|
||||
);
|
||||
await page.click(".multipledefault2 button");
|
||||
await waitForText(
|
||||
page,
|
||||
".multipledefault2 p",
|
||||
"MultipleDefault2 Island: 1",
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ Deno.test("/ page prerender", async () => {
|
||||
assertEquals(resp.headers.get("server"), "fresh test server");
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, `<html lang="en">`);
|
||||
assertStringIncludes(body, "test_default.js");
|
||||
assertStringIncludes(body, "test.js");
|
||||
assertStringIncludes(body, "<p>Hello!</p>");
|
||||
assertStringIncludes(body, "<p>Viewing JIT render.</p>");
|
||||
assertStringIncludes(body, `>{"v":[[{"message":"Hello!"}],[]]}</script>`);
|
||||
|
||||
@@ -15,6 +15,7 @@ async function updateAndVerify(cwd: string | URL, expected: RegExp) {
|
||||
args: [
|
||||
"run",
|
||||
"-A",
|
||||
"--no-config",
|
||||
path.join(Deno.cwd(), "update.ts"),
|
||||
".",
|
||||
],
|
||||
@@ -40,6 +41,7 @@ async function initProject() {
|
||||
args: [
|
||||
"run",
|
||||
"-A",
|
||||
"--no-config",
|
||||
path.join(Deno.cwd(), "init.ts"),
|
||||
".",
|
||||
],
|
||||
|
||||
+13
-13
@@ -13,13 +13,13 @@ import * as $index from "./routes/index.tsx";
|
||||
import * as $raw from "./routes/raw.ts";
|
||||
import * as $showcase from "./routes/showcase.tsx";
|
||||
import * as $update from "./routes/update.tsx";
|
||||
import * as $$ComponentGallery from "./islands/ComponentGallery.tsx";
|
||||
import * as $$CopyArea from "./islands/CopyArea.tsx";
|
||||
import * as $$Counter from "./islands/Counter.tsx";
|
||||
import * as $$LemonDrop from "./islands/LemonDrop.tsx";
|
||||
import * as $$SearchButton from "./islands/SearchButton.tsx";
|
||||
import * as $$VersionSelect from "./islands/VersionSelect.tsx";
|
||||
import { Manifest } from "$fresh/server.ts";
|
||||
import * as $ComponentGallery from "./islands/ComponentGallery.tsx";
|
||||
import * as $CopyArea from "./islands/CopyArea.tsx";
|
||||
import * as $Counter from "./islands/Counter.tsx";
|
||||
import * as $LemonDrop from "./islands/LemonDrop.tsx";
|
||||
import * as $SearchButton from "./islands/SearchButton.tsx";
|
||||
import * as $VersionSelect from "./islands/VersionSelect.tsx";
|
||||
import { type Manifest } from "$fresh/server.ts";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
@@ -36,12 +36,12 @@ const manifest = {
|
||||
"./routes/update.tsx": $update,
|
||||
},
|
||||
islands: {
|
||||
"./islands/ComponentGallery.tsx": $$ComponentGallery,
|
||||
"./islands/CopyArea.tsx": $$CopyArea,
|
||||
"./islands/Counter.tsx": $$Counter,
|
||||
"./islands/LemonDrop.tsx": $$LemonDrop,
|
||||
"./islands/SearchButton.tsx": $$SearchButton,
|
||||
"./islands/VersionSelect.tsx": $$VersionSelect,
|
||||
"./islands/ComponentGallery.tsx": $ComponentGallery,
|
||||
"./islands/CopyArea.tsx": $CopyArea,
|
||||
"./islands/Counter.tsx": $Counter,
|
||||
"./islands/LemonDrop.tsx": $LemonDrop,
|
||||
"./islands/SearchButton.tsx": $SearchButton,
|
||||
"./islands/VersionSelect.tsx": $VersionSelect,
|
||||
},
|
||||
baseUrl: import.meta.url,
|
||||
} satisfies Manifest;
|
||||
|
||||
Reference in New Issue
Block a user